[PATCH 1/2] usb: typec: mux: avoid duplicated orientation switches
Sebastian Reichel
sebastian.reichel at collabora.com
Fri Feb 13 11:23:28 PST 2026
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 at collabora.com>
---
drivers/usb/typec/mux.c | 14 +++++++++++++-
1 file changed, 13 insertions(+), 1 deletion(-)
diff --git a/drivers/usb/typec/mux.c b/drivers/usb/typec/mux.c
index 182c902c42f6..db35b7398343 100644
--- a/drivers/usb/typec/mux.c
+++ b/drivers/usb/typec/mux.c
@@ -72,9 +72,9 @@ struct typec_switch *fwnode_typec_switch_get(struct fwnode_handle *fwnode)
{
struct typec_switch_dev *sw_devs[TYPEC_MUX_MAX_DEVS];
struct typec_switch *sw;
+ int i, j, k;
int count;
int err;
- int i;
sw = kzalloc(sizeof(*sw), GFP_KERNEL);
if (!sw)
@@ -96,6 +96,18 @@ struct typec_switch *fwnode_typec_switch_get(struct fwnode_handle *fwnode)
}
}
+ /* eliminate duplicates */
+ for (i = 0; i < count; i++) {
+ for (j = i + 1; j < count; j++) {
+ if (sw_devs[j] == sw_devs[i]) {
+ put_device(&sw_devs[j]->dev);
+ for (k = j; k < count; k++)
+ sw_devs[k] = sw_devs[k+1];
+ count--;
+ }
+ }
+ }
+
for (i = 0; i < count; i++) {
WARN_ON(!try_module_get(sw_devs[i]->dev.parent->driver->owner));
sw->sw_devs[i] = sw_devs[i];
--
2.51.0
More information about the Linux-rockchip
mailing list