]> git.ipfire.org Git - thirdparty/kernel/linux.git/commit
power: supply: power_supply_show_enum_with_available(): Replace spaces with '_'
authorHans de Goede <hdegoede@redhat.com>
Mon, 9 Dec 2024 20:40:48 +0000 (21:40 +0100)
committerSebastian Reichel <sebastian.reichel@collabora.com>
Wed, 11 Dec 2024 01:53:26 +0000 (02:53 +0100)
commitcc4c34577dbc17729b7e3f1266cf12d043e8c170
treea0778b8e1b1e76f47ad0ffa41e7ba476d09e1ef7
parent72ad51a62389dc99fbe5337ad1821399b23bd78f
power: supply: power_supply_show_enum_with_available(): Replace spaces with '_'

Some enum style power-supply properties have text-values / labels for some
of the enum values containing a space, e.g. "Long Life" for
POWER_SUPPLY_CHARGE_TYPE_LONGLIFE.

Make power_supply_show_enum_with_available() replace these spaces with
'_' when showing the available text-values. After this the output for
a battery which supports "Long Life" will be e.g.:

Fast [Standard] Long_Life

or:

Fast Standard [Long_Life]

Modify power_supply_store_property() to accept both the original text-value
with space and the alternative value with the spaces replaced by '_'.
This allows users to write the value with '_' after seeing this on reading
the property.

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Reviewed-by: Thomas Weißschuh <linux@weissschuh.net>
Link: https://lore.kernel.org/r/20241209204051.8786-2-hdegoede@redhat.com
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
drivers/power/supply/power_supply_sysfs.c