Skip to content

Commit

Permalink
usb: typec: mux: Allow the muxes to be named
Browse files Browse the repository at this point in the history
The mux devices have been named by using the name of the
parent device as base until now, but if for example the
parent device has multiple muxes that will not work. This
makes it possible to supply the name for a mux during
registration.

Signed-off-by: Heikki Krogerus <heikki.krogerus@linux.intel.com>
Link: https://lore.kernel.org/r/20200302135353.56659-2-heikki.krogerus@linux.intel.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
  • Loading branch information
Heikki Krogerus authored and Greg Kroah-Hartman committed Mar 4, 2020
1 parent 6754046 commit ef441dd
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
6 changes: 4 additions & 2 deletions drivers/usb/typec/mux.c
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,8 @@ typec_switch_register(struct device *parent,
sw->dev.class = &typec_mux_class;
sw->dev.type = &typec_switch_dev_type;
sw->dev.driver_data = desc->drvdata;
dev_set_name(&sw->dev, "%s-switch", dev_name(parent));
dev_set_name(&sw->dev, "%s-switch",
desc->name ? desc->name : dev_name(parent));

ret = device_add(&sw->dev);
if (ret) {
Expand Down Expand Up @@ -309,7 +310,8 @@ typec_mux_register(struct device *parent, const struct typec_mux_desc *desc)
mux->dev.class = &typec_mux_class;
mux->dev.type = &typec_mux_dev_type;
mux->dev.driver_data = desc->drvdata;
dev_set_name(&mux->dev, "%s-mux", dev_name(parent));
dev_set_name(&mux->dev, "%s-mux",
desc->name ? desc->name : dev_name(parent));

ret = device_add(&mux->dev);
if (ret) {
Expand Down
2 changes: 2 additions & 0 deletions include/linux/usb/typec_mux.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ typedef int (*typec_switch_set_fn_t)(struct typec_switch *sw,
struct typec_switch_desc {
struct fwnode_handle *fwnode;
typec_switch_set_fn_t set;
const char *name;
void *drvdata;
};

Expand All @@ -42,6 +43,7 @@ typedef int (*typec_mux_set_fn_t)(struct typec_mux *mux,
struct typec_mux_desc {
struct fwnode_handle *fwnode;
typec_mux_set_fn_t set;
const char *name;
void *drvdata;
};

Expand Down

0 comments on commit ef441dd

Please sign in to comment.