Thank you for your contribution! Sashiko AI review found 1 potential
issue to consider:
- [Medium] HID: logitech-hidpp: unexposed capacity_level for battery
voltage feature
--
commit b4d76869d226ccd595e36b0b248b61047a51210e
Author: Dmitry Torokhov [off-list ref]
HID: logitech-hidpp: expose charge_type property for battery voltage feature
This commit exposes POWER_SUPPLY_PROP_CHARGE_TYPE for devices supporting
the 0x1001 battery voltage feature, refines charge_type mapping based on
battery status, updates change detection in
hidpp20_battery_voltage_event(), and resets charge_type on disconnect.
quoted hunk ↗ jump to hunk
diff --git a/drivers/hid/hid-logitech-hidpp.c b/drivers/hid/hid-logitech-hidpp.c
index dbf8f15f5a5b0..966c5932528de 100644
--- a/drivers/hid/hid-logitech-hidpp.c
+++ b/drivers/hid/hid-logitech-hidpp.c
[ ... ]
quoted hunk ↗ jump to hunk
@@ -1553,7 +1558,10 @@ static int hidpp20_battery_voltage_event(struct hidpp_device *hidpp,
hidpp->battery.online = status != POWER_SUPPLY_STATUS_NOT_CHARGING;
- if (voltage != hidpp->battery.voltage || status != hidpp->battery.status) {
+ if (voltage != hidpp->battery.voltage ||
+ status != hidpp->battery.status ||
+ level != hidpp->battery.level ||
+ charge_type != hidpp->battery.charge_type) {
hidpp->battery.voltage = voltage;
hidpp->battery.capacity = hidpp20_map_battery_capacity(hidpp->hid_dev,
voltage);
[ ... ]
quoted hunk ↗ jump to hunk
@@ -4416,6 +4425,10 @@ static int hidpp_initialize_battery(struct hidpp_device *hidpp)
battery_props[num_battery_props++] =
POWER_SUPPLY_PROP_VOLTAGE_NOW;
+ if (hidpp->capabilities & HIDPP_CAPABILITY_BATTERY_VOLTAGE)
+ battery_props[num_battery_props++] =
+ POWER_SUPPLY_PROP_CHARGE_TYPE;
[Severity: Medium]
Should hidpp_initialize_battery() also register
POWER_SUPPLY_PROP_CAPACITY_LEVEL when HIDPP_CAPABILITY_BATTERY_VOLTAGE is
set?
hidpp20_battery_map_status_voltage() populates battery.level (setting
POWER_SUPPLY_CAPACITY_LEVEL_FULL when full and
POWER_SUPPLY_CAPACITY_LEVEL_CRITICAL when bit 5 of flags is set), and
hidpp20_battery_voltage_event() now checks level != hidpp->battery.level
before calling power_supply_changed(). However, hidpp_initialize_battery()
only appends POWER_SUPPLY_PROP_CAPACITY_LEVEL to battery_props[] for
HIDPP_CAPABILITY_BATTERY_LEVEL_STATUS:
drivers/hid/hid-logitech-hidpp.c:hidpp_initialize_battery() {
...
if (hidpp->capabilities & HIDPP_CAPABILITY_BATTERY_LEVEL_STATUS)
battery_props[num_battery_props++] =
POWER_SUPPLY_PROP_CAPACITY_LEVEL;
...
}
As a result, capacity_level is never exposed in sysfs for 0x1001 battery
voltage devices, and a change in battery.level alone (such as the critical
flag toggling at the same voltage and status) emits a power_supply_changed()
uevent with no user-visible property change.
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261120-hid-logitech-hidpp-v3-0-cfe2caa1d0eb@gmail.com?part=14