OSDN Git Service

usb: hub: port: add sysfs entry to switch port power
authorMichael Grzeschik <m.grzeschik@pengutronix.de>
Tue, 7 Jun 2022 11:45:22 +0000 (13:45 +0200)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Sun, 12 Jun 2022 04:49:46 +0000 (06:49 +0200)
commitf061f43d7418cb62b8d073e221ec75d3f5b89e17
tree59d311ae1af0105d165ee26ec129c122c9e6e545
parent5fd6c4f0a649c956b2c50c18e0da765b7f5e3eff
usb: hub: port: add sysfs entry to switch port power

In some cases the port of an hub needs to be disabled or switched off
and on again. E.g. when the connected device needs to be re-enumerated.
Or it needs to be explicitly disabled while the rest of the usb tree
stays working.

For this purpose this patch adds an sysfs switch to enable/disable the
port on any hub. In the case the hub is supporting power switching, the
power line will be disabled to the connected device.

When the port gets disabled, the associated device gets disconnected and
removed from the logical usb tree. No further device will be enumerated
on that port until the port gets enabled again.

Reviewed-by: Alan Stern <stern@rowland.harvard.edu>
Signed-off-by: Michael Grzeschik <m.grzeschik@pengutronix.de>
Link: https://lore.kernel.org/r/20220607114522.3359148-1-m.grzeschik@pengutronix.de
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Documentation/ABI/testing/sysfs-bus-usb
drivers/usb/core/hub.c
drivers/usb/core/hub.h
drivers/usb/core/port.c