Skip to content

Commit e525619

Browse files
Heikki Krogerusgregkh
authored andcommitted
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: Heikki Krogerus <heikki.krogerus@linux.intel.com> Link: https://lore.kernel.org/r/20200302135353.56659-7-heikki.krogerus@linux.intel.com Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent bce3052 commit e525619

2 files changed

Lines changed: 4 additions & 1 deletion

File tree

‎drivers/usb/roles/class.c‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -330,7 +330,8 @@ usb_role_switch_register(struct device *parent,
330330
sw->dev.class = role_class;
331331
sw->dev.type = &usb_role_dev_type;
332332
dev_set_drvdata(&sw->dev, desc->driver_data);
333-
dev_set_name(&sw->dev, "%s-role-switch", dev_name(parent));
333+
dev_set_name(&sw->dev, "%s-role-switch",
334+
desc->name ? desc->name : dev_name(parent));
334335

335336
ret = device_register(&sw->dev);
336337
if (ret) {

‎include/linux/usb/role.h‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ typedef enum usb_role (*usb_role_switch_get_t)(struct usb_role_switch *sw);
2727
* @get: Callback for getting the role (optional)
2828
* @allow_userspace_control: If true userspace may change the role through sysfs
2929
* @driver_data: Private data pointer
30+
* @name: Name for the switch (optional)
3031
*
3132
* @usb2_port and @usb3_port will point to the USB host port and @udc to the USB
3233
* device controller behind the USB connector with the role switch. If
@@ -43,6 +44,7 @@ struct usb_role_switch_desc {
4344
usb_role_switch_get_t get;
4445
bool allow_userspace_control;
4546
void *driver_data;
47+
const char *name;
4648
};
4749

4850

0 commit comments

Comments
 (0)