Revert "usb: roles: don't get/set_role() when usb_role_switch is unregistered"

This reverts commit 2f414a56b3 which is
commit b787a3e781759026a6212736ef8e52cf83d1821a upstream.

It breaks the Android kernel abi and can be brought back in the future
in an abi-safe way if it is really needed.

Bug: 161946584
Change-Id: Ia72bbe97772c8e65c2dfe2835b00a49414702dbb
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
This commit is contained in:
Greg Kroah-Hartman
2024-05-02 07:43:31 +00:00
parent 563b8244db
commit 706f6a46d8

View File

@@ -21,7 +21,6 @@ struct usb_role_switch {
struct mutex lock; /* device lock*/
struct module *module; /* the module this device depends on */
enum usb_role role;
bool registered;
/* From descriptor */
struct device *usb2_port;
@@ -48,9 +47,6 @@ int usb_role_switch_set_role(struct usb_role_switch *sw, enum usb_role role)
if (IS_ERR_OR_NULL(sw))
return 0;
if (!sw->registered)
return -EOPNOTSUPP;
mutex_lock(&sw->lock);
ret = sw->set(sw, role);
@@ -76,7 +72,7 @@ enum usb_role usb_role_switch_get_role(struct usb_role_switch *sw)
{
enum usb_role role;
if (IS_ERR_OR_NULL(sw) || !sw->registered)
if (IS_ERR_OR_NULL(sw))
return USB_ROLE_NONE;
mutex_lock(&sw->lock);
@@ -360,8 +356,6 @@ usb_role_switch_register(struct device *parent,
return ERR_PTR(ret);
}
sw->registered = true;
/* TODO: Symlinks for the host port and the device controller. */
return sw;
@@ -376,10 +370,8 @@ EXPORT_SYMBOL_GPL(usb_role_switch_register);
*/
void usb_role_switch_unregister(struct usb_role_switch *sw)
{
if (!IS_ERR_OR_NULL(sw)) {
sw->registered = false;
if (!IS_ERR_OR_NULL(sw))
device_unregister(&sw->dev);
}
}
EXPORT_SYMBOL_GPL(usb_role_switch_unregister);