[PATCH 1/6] power: supply: "usb_type" property may be written to
Greg Kroah-Hartman
gregkh at linuxfoundation.org
Tue Sep 3 00:04:02 PDT 2024
On Sat, Aug 31, 2024 at 04:20:34PM +0200, Hans de Goede wrote:
> 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.
Ick, crazy hardware :(
>
> 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 <enric.balletbo at collabora.com>
> Cc: Andrey Smirnov <andrew.smirnov at gmail.com>
> Signed-off-by: Hans de Goede <hdegoede at redhat.com>
Reviewed-by: Greg Kroah-Hartman <gregkh at linuxfoundation.org>
More information about the linux-phy
mailing list