Commit e5256194 authored by Heikki Krogerus's avatar Heikki Krogerus Committed by Greg Kroah-Hartman

usb: roles: Allow the role switches to be named

The switch devices have been named by using the name of the
parent device as base for now, but if for example the
parent device controls multiple muxes, that will not work.

Adding an optional member "name" to the switch descriptor
that can be used for naming the switch during registration.
Signed-off-by: default avatarHeikki Krogerus <heikki.krogerus@linux.intel.com>
Link: https://lore.kernel.org/r/20200302135353.56659-7-heikki.krogerus@linux.intel.comSigned-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent bce3052f
...@@ -330,7 +330,8 @@ usb_role_switch_register(struct device *parent, ...@@ -330,7 +330,8 @@ usb_role_switch_register(struct device *parent,
sw->dev.class = role_class; sw->dev.class = role_class;
sw->dev.type = &usb_role_dev_type; sw->dev.type = &usb_role_dev_type;
dev_set_drvdata(&sw->dev, desc->driver_data); dev_set_drvdata(&sw->dev, desc->driver_data);
dev_set_name(&sw->dev, "%s-role-switch", dev_name(parent)); dev_set_name(&sw->dev, "%s-role-switch",
desc->name ? desc->name : dev_name(parent));
ret = device_register(&sw->dev); ret = device_register(&sw->dev);
if (ret) { if (ret) {
......
...@@ -27,6 +27,7 @@ typedef enum usb_role (*usb_role_switch_get_t)(struct usb_role_switch *sw); ...@@ -27,6 +27,7 @@ typedef enum usb_role (*usb_role_switch_get_t)(struct usb_role_switch *sw);
* @get: Callback for getting the role (optional) * @get: Callback for getting the role (optional)
* @allow_userspace_control: If true userspace may change the role through sysfs * @allow_userspace_control: If true userspace may change the role through sysfs
* @driver_data: Private data pointer * @driver_data: Private data pointer
* @name: Name for the switch (optional)
* *
* @usb2_port and @usb3_port will point to the USB host port and @udc to the USB * @usb2_port and @usb3_port will point to the USB host port and @udc to the USB
* device controller behind the USB connector with the role switch. If * device controller behind the USB connector with the role switch. If
...@@ -43,6 +44,7 @@ struct usb_role_switch_desc { ...@@ -43,6 +44,7 @@ struct usb_role_switch_desc {
usb_role_switch_get_t get; usb_role_switch_get_t get;
bool allow_userspace_control; bool allow_userspace_control;
void *driver_data; void *driver_data;
const char *name;
}; };
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment