mirror of
https://github.com/hardkernel/linux.git
synced 2026-06-09 04:10:18 +09:00
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:
@@ -21,7 +21,6 @@ struct usb_role_switch {
|
|||||||
struct mutex lock; /* device lock*/
|
struct mutex lock; /* device lock*/
|
||||||
struct module *module; /* the module this device depends on */
|
struct module *module; /* the module this device depends on */
|
||||||
enum usb_role role;
|
enum usb_role role;
|
||||||
bool registered;
|
|
||||||
|
|
||||||
/* From descriptor */
|
/* From descriptor */
|
||||||
struct device *usb2_port;
|
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))
|
if (IS_ERR_OR_NULL(sw))
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
if (!sw->registered)
|
|
||||||
return -EOPNOTSUPP;
|
|
||||||
|
|
||||||
mutex_lock(&sw->lock);
|
mutex_lock(&sw->lock);
|
||||||
|
|
||||||
ret = sw->set(sw, role);
|
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;
|
enum usb_role role;
|
||||||
|
|
||||||
if (IS_ERR_OR_NULL(sw) || !sw->registered)
|
if (IS_ERR_OR_NULL(sw))
|
||||||
return USB_ROLE_NONE;
|
return USB_ROLE_NONE;
|
||||||
|
|
||||||
mutex_lock(&sw->lock);
|
mutex_lock(&sw->lock);
|
||||||
@@ -360,8 +356,6 @@ usb_role_switch_register(struct device *parent,
|
|||||||
return ERR_PTR(ret);
|
return ERR_PTR(ret);
|
||||||
}
|
}
|
||||||
|
|
||||||
sw->registered = true;
|
|
||||||
|
|
||||||
/* TODO: Symlinks for the host port and the device controller. */
|
/* TODO: Symlinks for the host port and the device controller. */
|
||||||
|
|
||||||
return sw;
|
return sw;
|
||||||
@@ -376,10 +370,8 @@ EXPORT_SYMBOL_GPL(usb_role_switch_register);
|
|||||||
*/
|
*/
|
||||||
void usb_role_switch_unregister(struct usb_role_switch *sw)
|
void usb_role_switch_unregister(struct usb_role_switch *sw)
|
||||||
{
|
{
|
||||||
if (!IS_ERR_OR_NULL(sw)) {
|
if (!IS_ERR_OR_NULL(sw))
|
||||||
sw->registered = false;
|
|
||||||
device_unregister(&sw->dev);
|
device_unregister(&sw->dev);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
EXPORT_SYMBOL_GPL(usb_role_switch_unregister);
|
EXPORT_SYMBOL_GPL(usb_role_switch_unregister);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user