usb: typec: Add retimer handle to port
authorPrashant Malani <pmalani@chromium.org>
Mon, 11 Jul 2022 07:22:56 +0000 (07:22 +0000)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 14 Jul 2022 14:24:05 +0000 (16:24 +0200)
Similar to mux and orientation switch, add a handle for registered
retimer to the port, so that it has handles to the various switches
connected to it.

Signed-off-by: Prashant Malani <pmalani@chromium.org>
Acked-by: Heikki Krogerus <heikki.krogerus@linux.intel.com>
Link: https://lore.kernel.org/r/20220711072333.2064341-3-pmalani@chromium.org
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/usb/typec/class.c
drivers/usb/typec/class.h

index 9062836bb6384c8d529cf1b402e80f8b03b1d45d..f08e32d552b406fb16141113ca0c3ebf2e2baedc 100644 (file)
@@ -12,6 +12,7 @@
 #include <linux/slab.h>
 #include <linux/usb/pd_vdo.h>
 #include <linux/usb/typec_mux.h>
+#include <linux/usb/typec_retimer.h>
 
 #include "bus.h"
 #include "class.h"
@@ -1736,6 +1737,7 @@ static void typec_release(struct device *dev)
        ida_destroy(&port->mode_ids);
        typec_switch_put(port->sw);
        typec_mux_put(port->mux);
+       typec_retimer_put(port->retimer);
        kfree(port->cap);
        kfree(port);
 }
@@ -2249,6 +2251,13 @@ struct typec_port *typec_register_port(struct device *parent,
                return ERR_PTR(ret);
        }
 
+       port->retimer = typec_retimer_get(&port->dev);
+       if (IS_ERR(port->retimer)) {
+               ret = PTR_ERR(port->retimer);
+               put_device(&port->dev);
+               return ERR_PTR(ret);
+       }
+
        ret = device_add(&port->dev);
        if (ret) {
                dev_err(parent, "failed to register port (%d)\n", ret);
index 43fcf9e37a8c206adc40a776192f2f919df6fdef..673b2952b074900d479db8d83ef41e45263289e0 100644 (file)
@@ -55,6 +55,7 @@ struct typec_port {
        enum typec_orientation          orientation;
        struct typec_switch             *sw;
        struct typec_mux                *mux;
+       struct typec_retimer            *retimer;
 
        const struct typec_capability   *cap;
        const struct typec_operations   *ops;