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

Configure Feed

Select the types of activity you want to include in your feed.

usb: typec: mux: avoid duplicated orientation switches

Some devices use combo PHYs (i.e. USB3 + DisplayPort), which also
handle the orientation mux. These PHYs are referenced twice from
the USB-C connector (USB super-speed lines and SBU/AUX lines)
resulting in the switch being configured twice. Avoid this by
dropping duplicates.

Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
Reviewed-by: Heikki Krogerus <heikki.krogerus@linux.intel.com>
Link: https://patch.msgid.link/20260223-typec-mux-duplication-fix-v2-1-0402fefc222e@collabora.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

authored by

Sebastian Reichel and committed by
Greg Kroah-Hartman
a53b4f9c f2529d08

+11 -1
+11 -1
drivers/usb/typec/mux.c
··· 35 35 static void *typec_switch_match(const struct fwnode_handle *fwnode, 36 36 const char *id, void *data) 37 37 { 38 + struct typec_switch_dev **sw_devs = data; 38 39 struct device *dev; 40 + int i; 39 41 40 42 /* 41 43 * Device graph (OF graph) does not give any means to identify the ··· 57 55 */ 58 56 dev = class_find_device(&typec_mux_class, NULL, fwnode, 59 57 switch_fwnode_match); 58 + 59 + /* Skip duplicates */ 60 + for (i = 0; i < TYPEC_MUX_MAX_DEVS; i++) 61 + if (to_typec_switch_dev(dev) == sw_devs[i]) { 62 + put_device(dev); 63 + return NULL; 64 + } 60 65 61 66 return dev ? to_typec_switch_dev(dev) : ERR_PTR(-EPROBE_DEFER); 62 67 } ··· 89 80 if (!sw) 90 81 return ERR_PTR(-ENOMEM); 91 82 92 - count = fwnode_connection_find_matches(fwnode, "orientation-switch", NULL, 83 + count = fwnode_connection_find_matches(fwnode, "orientation-switch", 84 + (void **)sw_devs, 93 85 typec_switch_match, 94 86 (void **)sw_devs, 95 87 ARRAY_SIZE(sw_devs));