• Home
  • Raw
  • Download

Lines Matching full:sw

36  * @sw: USB role switch
39 * Set USB role @role for @sw.
41 int usb_role_switch_set_role(struct usb_role_switch *sw, enum usb_role role) in usb_role_switch_set_role() argument
45 if (IS_ERR_OR_NULL(sw)) in usb_role_switch_set_role()
48 mutex_lock(&sw->lock); in usb_role_switch_set_role()
50 ret = sw->set(sw->dev.parent, role); in usb_role_switch_set_role()
52 sw->role = role; in usb_role_switch_set_role()
54 mutex_unlock(&sw->lock); in usb_role_switch_set_role()
62 * @sw: USB role switch
67 enum usb_role usb_role_switch_get_role(struct usb_role_switch *sw) in usb_role_switch_get_role() argument
71 if (IS_ERR_OR_NULL(sw)) in usb_role_switch_get_role()
74 mutex_lock(&sw->lock); in usb_role_switch_get_role()
76 if (sw->get) in usb_role_switch_get_role()
77 role = sw->get(sw->dev.parent); in usb_role_switch_get_role()
79 role = sw->role; in usb_role_switch_get_role()
81 mutex_unlock(&sw->lock); in usb_role_switch_get_role()
112 struct usb_role_switch *sw; in usb_role_switch_get() local
114 sw = device_connection_find_match(dev, "usb-role-switch", NULL, in usb_role_switch_get()
117 if (!IS_ERR_OR_NULL(sw)) in usb_role_switch_get()
118 WARN_ON(!try_module_get(sw->dev.parent->driver->owner)); in usb_role_switch_get()
120 return sw; in usb_role_switch_get()
126 * @sw: USB Role Switch
128 * Decrement reference count for @sw.
130 void usb_role_switch_put(struct usb_role_switch *sw) in usb_role_switch_put() argument
132 if (!IS_ERR_OR_NULL(sw)) { in usb_role_switch_put()
133 module_put(sw->dev.parent->driver->owner); in usb_role_switch_put()
134 put_device(&sw->dev); in usb_role_switch_put()
143 struct usb_role_switch *sw = to_role_switch(dev); in usb_role_switch_is_visible() local
145 if (sw->allow_userspace_control) in usb_role_switch_is_visible()
160 struct usb_role_switch *sw = to_role_switch(dev); in role_show() local
161 enum usb_role role = usb_role_switch_get_role(sw); in role_show()
169 struct usb_role_switch *sw = to_role_switch(dev); in role_store() local
182 ret = usb_role_switch_set_role(sw, ret); in role_store()
219 struct usb_role_switch *sw = to_role_switch(dev); in usb_role_switch_release() local
221 kfree(sw); in usb_role_switch_release()
249 struct usb_role_switch *sw; in usb_role_switch_register() local
255 sw = kzalloc(sizeof(*sw), GFP_KERNEL); in usb_role_switch_register()
256 if (!sw) in usb_role_switch_register()
259 mutex_init(&sw->lock); in usb_role_switch_register()
261 sw->allow_userspace_control = desc->allow_userspace_control; in usb_role_switch_register()
262 sw->usb2_port = desc->usb2_port; in usb_role_switch_register()
263 sw->usb3_port = desc->usb3_port; in usb_role_switch_register()
264 sw->udc = desc->udc; in usb_role_switch_register()
265 sw->set = desc->set; in usb_role_switch_register()
266 sw->get = desc->get; in usb_role_switch_register()
268 sw->dev.parent = parent; in usb_role_switch_register()
269 sw->dev.class = role_class; in usb_role_switch_register()
270 sw->dev.type = &usb_role_dev_type; in usb_role_switch_register()
271 dev_set_name(&sw->dev, "%s-role-switch", dev_name(parent)); in usb_role_switch_register()
273 ret = device_register(&sw->dev); in usb_role_switch_register()
275 put_device(&sw->dev); in usb_role_switch_register()
281 return sw; in usb_role_switch_register()
287 * @sw: USB Role Switch
291 void usb_role_switch_unregister(struct usb_role_switch *sw) in usb_role_switch_unregister() argument
293 if (!IS_ERR_OR_NULL(sw)) in usb_role_switch_unregister()
294 device_unregister(&sw->dev); in usb_role_switch_unregister()