OSDN Git Service

usb: typec: mux: Get the mux identifier from function parameter
authorHeikki Krogerus <heikki.krogerus@linux.intel.com>
Wed, 27 Jun 2018 15:19:48 +0000 (18:19 +0300)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Mon, 2 Jul 2018 15:42:36 +0000 (17:42 +0200)
In order for the muxes to be usable with alternate modes,
the alternate mode devices will need also to be able to get
a handle to the muxes on top of the port devices. To make
that possible, the muxes need to be possible to request with
an identifier.

This will change the API so that the mux identifier is given
as a function parameter to typec_mux_get(), and the hard-coded
"typec-mux" is replaced with that value.

Signed-off-by: Heikki Krogerus <heikki.krogerus@linux.intel.com>
Tested-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/usb/typec/class.c
drivers/usb/typec/mux.c
include/linux/usb/typec_mux.h

index 3ef7b99..784e928 100644 (file)
@@ -1407,7 +1407,7 @@ struct typec_port *typec_register_port(struct device *parent,
                goto err_switch;
        }
 
-       port->mux = typec_mux_get(cap->fwnode ? &port->dev : parent);
+       port->mux = typec_mux_get(parent, "typec-mux");
        if (IS_ERR(port->mux)) {
                ret = PTR_ERR(port->mux);
                goto err_mux;
index 9d8330e..ddaac63 100644 (file)
@@ -123,19 +123,19 @@ static void *typec_mux_match(struct device_connection *con, int ep, void *data)
 /**
  * typec_mux_get - Find USB Type-C Multiplexer
  * @dev: The caller device
+ * @name: Mux identifier
  *
  * Finds a mux linked to the caller. This function is primarily meant for the
  * Type-C drivers. Returns a reference to the mux on success, NULL if no
  * matching connection was found, or ERR_PTR(-EPROBE_DEFER) when a connection
  * was found but the mux has not been enumerated yet.
  */
-struct typec_mux *typec_mux_get(struct device *dev)
+struct typec_mux *typec_mux_get(struct device *dev, const char *name)
 {
        struct typec_mux *mux;
 
        mutex_lock(&mux_lock);
-       mux = device_connection_find_match(dev, "typec-mux", NULL,
-                                          typec_mux_match);
+       mux = device_connection_find_match(dev, name, NULL, typec_mux_match);
        if (!IS_ERR_OR_NULL(mux))
                get_device(mux->dev);
        mutex_unlock(&mux_lock);
index 12c1b05..79293f6 100644 (file)
@@ -47,7 +47,7 @@ void typec_switch_put(struct typec_switch *sw);
 int typec_switch_register(struct typec_switch *sw);
 void typec_switch_unregister(struct typec_switch *sw);
 
-struct typec_mux *typec_mux_get(struct device *dev);
+struct typec_mux *typec_mux_get(struct device *dev, const char *name);
 void typec_mux_put(struct typec_mux *mux);
 int typec_mux_register(struct typec_mux *mux);
 void typec_mux_unregister(struct typec_mux *mux);