Skip to content

Commit 0d9af1e

Browse files
jwrdegoedesre
authored andcommitted
power: supply: "usb_type" property may be written to
According to Documentation/ABI/testing/sysfs-class-power the "usb_type" property is Read-Only. For power-supplies which consume USB power such as battery charger chips, this is correct. But the UCS1002 USB Port Power Controller driver which is a driver for a chip which is a power-source for USB-A charging ports "usb_type" is actually writable to configure the type of USB charger emulated by the USB-A port. Adjust the docs and the power_supply_sysfs.c code to adjust for this new writeable use of "usb_type": 1. Update Documentation/ABI/testing/sysfs-class-power to document that "usb_type" may be writable 2. Change the power_supply_attr type in power_supply_sysfs.c from POWER_SUPPLY_ATTR() into POWER_SUPPLY_ENUM_ATTR() so that the various usb_type string values from POWER_SUPPLY_TYPE_TEXT[] such as e.g. "SDP" and "USB_PD" can be written to the "usb_type" attribute instead of only accepting integer values. Cc: Enric Balletbo Serra <[email protected]> Cc: Andrey Smirnov <[email protected]> Signed-off-by: Hans de Goede <[email protected]> Reviewed-by: Greg Kroah-Hartman <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Sebastian Reichel <[email protected]>
1 parent 8400291 commit 0d9af1e

File tree

2 files changed

+7
-2
lines changed

2 files changed

+7
-2
lines changed

Documentation/ABI/testing/sysfs-class-power

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -592,7 +592,12 @@ Description:
592592
the supply, for example it can show if USB-PD capable source
593593
is attached.
594594

595-
Access: Read-Only
595+
Access: For power-supplies which consume USB power such
596+
as battery charger chips, this indicates the type of
597+
the connected USB power source and is Read-Only.
598+
599+
For power-supplies which act as a USB power-source such as
600+
e.g. the UCS1002 USB Port Power Controller this is writable.
596601

597602
Valid values:
598603
"Unknown", "SDP", "DCP", "CDP", "ACA", "C", "PD",

drivers/power/supply/power_supply_sysfs.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -209,7 +209,7 @@ static struct power_supply_attr power_supply_attrs[] = {
209209
POWER_SUPPLY_ATTR(TIME_TO_FULL_NOW),
210210
POWER_SUPPLY_ATTR(TIME_TO_FULL_AVG),
211211
POWER_SUPPLY_ENUM_ATTR(TYPE),
212-
POWER_SUPPLY_ATTR(USB_TYPE),
212+
POWER_SUPPLY_ENUM_ATTR(USB_TYPE),
213213
POWER_SUPPLY_ENUM_ATTR(SCOPE),
214214
POWER_SUPPLY_ATTR(PRECHARGE_CURRENT),
215215
POWER_SUPPLY_ATTR(CHARGE_TERM_CURRENT),

0 commit comments

Comments
 (0)