1
1
mirror of https://github.com/systemd/systemd-stable.git synced 2025-01-03 01:17:45 +03:00

on-ac-power: ignore devices with scope==Device

My mouse is reported as:

P: /devices/pci0000:00/0000:00:14.0/usb1/1-4/1-4.4/1-4.4:1.2/0003:046D:C52B.001E/0003:046D:4051.001F/power_supply/hidpp_battery_4
M: hidpp_battery_4
R: 4
U: power_supply
E: DEVPATH=/devices/pci0000:00/0000:00:14.0/usb1/1-4/1-4.4/1-4.4:1.2/0003:046D:C52B.001E/0003:046D:4051.001F/power_supply/hidpp_battery_4
E: SUBSYSTEM=power_supply
E: POWER_SUPPLY_NAME=hidpp_battery_4
E: POWER_SUPPLY_TYPE=Battery
E: POWER_SUPPLY_ONLINE=1
E: POWER_SUPPLY_STATUS=Discharging
E: POWER_SUPPLY_SCOPE=Device
E: POWER_SUPPLY_MODEL_NAME=Wireless Mouse M510
E: POWER_SUPPLY_MANUFACTURER=Logitech
E: POWER_SUPPLY_SERIAL_NUMBER=4051-bc-cd-d2-5b
E: POWER_SUPPLY_CAPACITY_LEVEL=Normal

See https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=25a0bc2dfc2ea732f40af2dae52426ead66ae76e
Effectively, "System" and "Unkown" are passed through, "Device" is rejected.
This commit is contained in:
Zbigniew Jędrzejewski-Szmek 2022-08-23 16:48:26 +02:00
parent 4a52514b37
commit 3c69e94a5c

View File

@ -704,6 +704,14 @@ int on_ac_power(void) {
bool is_battery = streq(val, "Battery");
if (is_battery) {
r = sd_device_get_sysattr_value(d, "scope", &val);
if (r < 0)
log_device_debug_errno(d, r, "Failed to read 'scope' sysfs attribute, ignoring: %m");
else if (streq(val, "Device")) {
log_device_debug(d, "The power supply is a device battery, ignoring.");
continue;
}
found_battery = true;
log_device_debug(d, "The power supply is battery.");
continue;