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

usb: typec: Make bus switch code retimer-aware

Since ports can have retimers associated with them, update the Type-C
alternate mode bus code to also set retimer state when the switch state
is updated.

While we are here, make the typec_retimer_dev_type declaration in the
retimer.h file as extern, so that the header file can be successfully
included in the bus code without redeclaration compilation errors.

Signed-off-by: Prashant Malani <pmalani@chromium.org>
Reviewed-by: Heikki Krogerus <heikki.krogerus@linux.intel.com>
Link: https://lore.kernel.org/r/20230112221609.540754-4-pmalani@chromium.org
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

authored by

Prashant Malani and committed by
Greg Kroah-Hartman
6681e43f 2c8cb236

+23 -1
+22
drivers/usb/typec/bus.c
··· 11 11 #include "bus.h" 12 12 #include "class.h" 13 13 #include "mux.h" 14 + #include "retimer.h" 15 + 16 + static inline int 17 + typec_altmode_set_retimer(struct altmode *alt, unsigned long conf, void *data) 18 + { 19 + struct typec_retimer_state state; 20 + 21 + if (!alt->retimer) 22 + return 0; 23 + 24 + state.alt = &alt->adev; 25 + state.mode = conf; 26 + state.data = data; 27 + 28 + return typec_retimer_set(alt->retimer, &state); 29 + } 14 30 15 31 static inline int 16 32 typec_altmode_set_mux(struct altmode *alt, unsigned long conf, void *data) ··· 47 31 static inline int 48 32 typec_altmode_set_switches(struct altmode *alt, unsigned long conf, void *data) 49 33 { 34 + int ret; 35 + 36 + ret = typec_altmode_set_retimer(alt, conf, data); 37 + if (ret) 38 + return ret; 39 + 50 40 return typec_altmode_set_mux(alt, conf, data); 51 41 } 52 42
+1 -1
drivers/usb/typec/retimer.h
··· 12 12 13 13 #define to_typec_retimer(_dev_) container_of(_dev_, struct typec_retimer, dev) 14 14 15 - const struct device_type typec_retimer_dev_type; 15 + extern const struct device_type typec_retimer_dev_type; 16 16 17 17 #define is_typec_retimer(dev) ((dev)->type == &typec_retimer_dev_type) 18 18