Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

power: supply: core: simplify charge_behaviour formatting

The function power_supply_show_charge_behaviour() is not needed and can
be removed completely.
Removing the function also saves a spurious read of the property from
the driver on each call.

The convulted logic was a leftover from an earlier patch revision.
Some restructuring made this cleanup possible.

Suggested-by: Hans de Goede <hdegoede@redhat.com>
Link: https://lore.kernel.org/all/9e035ae4-cb07-4f84-8336-1a0050855bea@redhat.com/
Fixes: 4e61f1e9d58f ("power: supply: core: fix charge_behaviour formatting")
Signed-off-by: Thomas Weißschuh <linux@weissschuh.net>
Reviewed-by: Hans de Goede <hdegoede@redhat.com>
Link: https://lore.kernel.org/r/20240329-power-supply-simplify-v1-1-416f1002739f@weissschuh.net
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>

authored by

Thomas Weißschuh and committed by
Sebastian Reichel
91b623cd 070c1470

+2 -18
+2 -18
drivers/power/supply/power_supply_sysfs.c
··· 271 271 return count; 272 272 } 273 273 274 - static ssize_t power_supply_show_charge_behaviour(struct device *dev, 275 - struct power_supply *psy, 276 - union power_supply_propval *value, 277 - char *buf) 278 - { 279 - int ret; 280 - 281 - ret = power_supply_get_property(psy, 282 - POWER_SUPPLY_PROP_CHARGE_BEHAVIOUR, 283 - value); 284 - if (ret < 0) 285 - return ret; 286 - 287 - return power_supply_charge_behaviour_show(dev, psy->desc->charge_behaviours, 288 - value->intval, buf); 289 - } 290 - 291 274 static ssize_t power_supply_show_property(struct device *dev, 292 275 struct device_attribute *attr, 293 276 char *buf) { ··· 304 321 &value, buf); 305 322 break; 306 323 case POWER_SUPPLY_PROP_CHARGE_BEHAVIOUR: 307 - ret = power_supply_show_charge_behaviour(dev, psy, &value, buf); 324 + ret = power_supply_charge_behaviour_show(dev, psy->desc->charge_behaviours, 325 + value.intval, buf); 308 326 break; 309 327 case POWER_SUPPLY_PROP_MODEL_NAME ... POWER_SUPPLY_PROP_SERIAL_NUMBER: 310 328 ret = sysfs_emit(buf, "%s\n", value.strval);