struct usb_role_switch {
struct device dev;
+ struct lock_class_key key;
struct mutex lock; /* device lock*/
struct module *module; /* the module this device depends on */
enum usb_role role;
usb_role_switch_set_t set;
usb_role_switch_get_t get;
bool allow_userspace_control;
-
- struct lock_class_key key;
};
#define to_role_switch(d) container_of(d, struct usb_role_switch, dev)
{
struct usb_role_switch *sw = to_role_switch(dev);
+ mutex_destroy(&sw->lock);
+ lockdep_unregister_key(&sw->key);
kfree(sw);
}
if (!sw)
return ERR_PTR(-ENOMEM);
- mutex_init(&sw->lock);
+ lockdep_register_key(&sw->key);
+ mutex_init_with_key(&sw->lock, &sw->key);
sw->allow_userspace_control = desc->allow_userspace_control;
sw->usb2_port = desc->usb2_port;
sw->registered = true;
- lockdep_register_key(&sw->key);
- lockdep_set_class(&sw->lock, &sw->key);
-
/* TODO: Symlinks for the host port and the device controller. */
return sw;
{
if (IS_ERR_OR_NULL(sw))
return;
-
- lockdep_unregister_key(&sw->key);
-
sw->registered = false;
if (dev_fwnode(&sw->dev))
component_del(&sw->dev, &connector_ops);