Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

usb: typec: mux: Get the mux identifier from function parameter

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>

authored by

Heikki Krogerus and committed by
Greg Kroah-Hartman
93dd2112 0bc26314

+5 -5
+1 -1
drivers/usb/typec/class.c
··· 1407 1407 goto err_switch; 1408 1408 } 1409 1409 1410 - port->mux = typec_mux_get(cap->fwnode ? &port->dev : parent); 1410 + port->mux = typec_mux_get(parent, "typec-mux"); 1411 1411 if (IS_ERR(port->mux)) { 1412 1412 ret = PTR_ERR(port->mux); 1413 1413 goto err_mux;
+3 -3
drivers/usb/typec/mux.c
··· 123 123 /** 124 124 * typec_mux_get - Find USB Type-C Multiplexer 125 125 * @dev: The caller device 126 + * @name: Mux identifier 126 127 * 127 128 * Finds a mux linked to the caller. This function is primarily meant for the 128 129 * Type-C drivers. Returns a reference to the mux on success, NULL if no 129 130 * matching connection was found, or ERR_PTR(-EPROBE_DEFER) when a connection 130 131 * was found but the mux has not been enumerated yet. 131 132 */ 132 - struct typec_mux *typec_mux_get(struct device *dev) 133 + struct typec_mux *typec_mux_get(struct device *dev, const char *name) 133 134 { 134 135 struct typec_mux *mux; 135 136 136 137 mutex_lock(&mux_lock); 137 - mux = device_connection_find_match(dev, "typec-mux", NULL, 138 - typec_mux_match); 138 + mux = device_connection_find_match(dev, name, NULL, typec_mux_match); 139 139 if (!IS_ERR_OR_NULL(mux)) 140 140 get_device(mux->dev); 141 141 mutex_unlock(&mux_lock);
+1 -1
include/linux/usb/typec_mux.h
··· 47 47 int typec_switch_register(struct typec_switch *sw); 48 48 void typec_switch_unregister(struct typec_switch *sw); 49 49 50 - struct typec_mux *typec_mux_get(struct device *dev); 50 + struct typec_mux *typec_mux_get(struct device *dev, const char *name); 51 51 void typec_mux_put(struct typec_mux *mux); 52 52 int typec_mux_register(struct typec_mux *mux); 53 53 void typec_mux_unregister(struct typec_mux *mux);