[PATCH 2/2] usb: typec: mux: avoid duplicated mux switches
Heikki Krogerus
heikki.krogerus at linux.intel.com
Mon Feb 23 07:02:12 PST 2026
Fri, Feb 13, 2026 at 08:23:29PM +0100, Sebastian Reichel wrote:
> Some devices use combo PHYs (i.e. USB3 + DisplayPort), which also
> handle the lane muxing. These PHYs are referenced twice from
> the USB-C connector (USB super-speed lines and SBU/AUX lines)
> resulting in the mux 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 db35b7398343..6a394326f236 100644
> --- a/drivers/usb/typec/mux.c
> +++ b/drivers/usb/typec/mux.c
> @@ -309,9 +309,9 @@ struct typec_mux *fwnode_typec_mux_get(struct fwnode_handle *fwnode)
> {
> struct typec_mux_dev *mux_devs[TYPEC_MUX_MAX_DEVS];
> struct typec_mux *mux;
> + int i, j, k;
> int count;
> int err;
> - int i;
>
> mux = kzalloc(sizeof(*mux), GFP_KERNEL);
> if (!mux)
> @@ -333,6 +333,18 @@ struct typec_mux *fwnode_typec_mux_get(struct fwnode_handle *fwnode)
> }
> }
>
> + /* eliminate duplicates */
> + for (i = 0; i < count; i++) {
> + for (j = i + 1; j < count; j++) {
> + if (mux_devs[j] == mux_devs[i]) {
> + put_device(&mux_devs[j]->dev);
> + for (k = j; k < count; k++)
> + mux_devs[k] = mux_devs[k+1];
> + count--;
> + }
> + }
> + }
The same should work here. My code snippets probable has to be
modified, but the idea should work. The check should be more simple to
do in typec_switch_match().
Br,
--
heikki
More information about the Linux-rockchip
mailing list