From 784572c0eb0b68988ea49757f8f78b18495e4a3b Mon Sep 17 00:00:00 2001 From: Greg Kroah-Hartman Date: Mon, 29 Apr 2024 09:38:29 +0000 Subject: [PATCH] Revert "usb: roles: don't get/set_role() when usb_role_switch is unregistered" This reverts commit 256c3e6192ed80f7f67c55c531942f880788c9ed 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. It's not a "real" break, and we can work around it, but this really does not affect Android systems, so it's safe to drop for now. Bug: 161946584 Change-Id: I46a8368cbf844a05ee18cfdfa33b1b8f50b529ef Signed-off-by: Greg Kroah-Hartman --- drivers/usb/roles/class.c | 12 ++---------- 1 file changed, 2 insertions(+), 10 deletions(-) diff --git a/drivers/usb/roles/class.c b/drivers/usb/roles/class.c index a327f8bc5704..d90d16423809 100644 --- a/drivers/usb/roles/class.c +++ b/drivers/usb/roles/class.c @@ -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);