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

usb: typec: Stub out typec_switch APIs when CONFIG_TYPEC=n

Ease driver development by adding stubs for the typec_switch APIs when
CONFIG_TYPEC=n. Copy the same method used for the typec_mux APIs to be
consistent.

Acked-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Reviewed-by: Heikki Krogerus <heikki.krogerus@linux.intel.com>
Signed-off-by: Stephen Boyd <swboyd@chromium.org>
Signed-off-by: Xu Yang <xu.yang_2@nxp.com>
Link: https://lore.kernel.org/r/20250916021620.1303995-1-xu.yang_2@nxp.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

authored by

Stephen Boyd and committed by
Greg Kroah-Hartman
45fe729b 368ed48a

+41 -5
+41 -5
include/linux/usb/typec_mux.h
··· 3 3 #ifndef __USB_TYPEC_MUX 4 4 #define __USB_TYPEC_MUX 5 5 6 + #include <linux/err.h> 6 7 #include <linux/property.h> 7 8 #include <linux/usb/typec.h> 8 9 ··· 25 24 void *drvdata; 26 25 }; 27 26 27 + #if IS_ENABLED(CONFIG_TYPEC) 28 + 28 29 struct typec_switch *fwnode_typec_switch_get(struct fwnode_handle *fwnode); 29 30 void typec_switch_put(struct typec_switch *sw); 30 31 int typec_switch_set(struct typec_switch *sw, 31 32 enum typec_orientation orientation); 32 - 33 - static inline struct typec_switch *typec_switch_get(struct device *dev) 34 - { 35 - return fwnode_typec_switch_get(dev_fwnode(dev)); 36 - } 37 33 38 34 struct typec_switch_dev * 39 35 typec_switch_register(struct device *parent, ··· 39 41 40 42 void typec_switch_set_drvdata(struct typec_switch_dev *sw, void *data); 41 43 void *typec_switch_get_drvdata(struct typec_switch_dev *sw); 44 + 45 + #else 46 + 47 + static inline struct typec_switch * 48 + fwnode_typec_switch_get(struct fwnode_handle *fwnode) 49 + { 50 + return NULL; 51 + } 52 + 53 + static inline void typec_switch_put(struct typec_switch *sw) {} 54 + 55 + static inline int typec_switch_set(struct typec_switch *sw, 56 + enum typec_orientation orientation) 57 + { 58 + return 0; 59 + } 60 + 61 + static inline struct typec_switch_dev * 62 + typec_switch_register(struct device *parent, 63 + const struct typec_switch_desc *desc) 64 + { 65 + return ERR_PTR(-EOPNOTSUPP); 66 + } 67 + 68 + static inline void typec_switch_unregister(struct typec_switch_dev *sw) {} 69 + 70 + static inline void typec_switch_set_drvdata(struct typec_switch_dev *sw, void *data) {} 71 + static inline void *typec_switch_get_drvdata(struct typec_switch_dev *sw) 72 + { 73 + return ERR_PTR(-EOPNOTSUPP); 74 + } 75 + 76 + #endif /* CONFIG_TYPEC */ 77 + 78 + static inline struct typec_switch *typec_switch_get(struct device *dev) 79 + { 80 + return fwnode_typec_switch_get(dev_fwnode(dev)); 81 + } 42 82 43 83 struct typec_mux_state { 44 84 struct typec_altmode *alt;