Message ID | 20240908192303.151562-2-hdegoede@redhat.com |
---|---|
State | New |
Headers | show |
Series | power: supply: Add new "charge_types" property | expand |
diff --git a/drivers/power/supply/power_supply_sysfs.c b/drivers/power/supply/power_supply_sysfs.c index 16b3c5880cd8..ac42784eab11 100644 --- a/drivers/power/supply/power_supply_sysfs.c +++ b/drivers/power/supply/power_supply_sysfs.c @@ -253,7 +253,10 @@ static ssize_t power_supply_show_enum_with_available( count += sysfs_emit_at(buf, count, "[%s] ", labels[i]); match = true; } else if (available) { - count += sysfs_emit_at(buf, count, "%s ", labels[i]); + if (strchr(labels[i], ' ')) + count += sysfs_emit_at(buf, count, "\"%s\" ", labels[i]); + else + count += sysfs_emit_at(buf, count, "%s ", labels[i]); } }
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() surround these label with "" when the label is not for the active enum value to make it clear that this is a single label and not 2 different labels for 2 different enum values. After this the output for a battery which support "Long Life" will be e.g.: Fast [Standard] "Long Life" or: Fast Standard [Long Life] Signed-off-by: Hans de Goede <hdegoede@redhat.com> --- drivers/power/supply/power_supply_sysfs.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)