Skip to content

Commit a37599e

Browse files
Prashant Malanigregkh
authored andcommitted
usb: typec: mux: Add CONFIG guards for functions
There are some drivers that can use the Type C mux API, but don't have to. Introduce CONFIG guards for the mux functions so that drivers can include the header file and not run into compilation errors on systems which don't have CONFIG_TYPEC enabled. When CONFIG_TYPEC is not enabled, the Type C mux functions will be stub versions of the original calls. Reported-by: kernel test robot <[email protected]> Reviewed-by: Nícolas F. R. A. Prado <[email protected]> Reviewed-by: Heikki Krogerus <[email protected]> Reviewed-by: AngeloGioacchino Del Regno <[email protected]> Tested-by: Nícolas F. R. A. Prado <[email protected]> Signed-off-by: Prashant Malani <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent 144a96f commit a37599e

File tree

1 file changed

+38
-6
lines changed

1 file changed

+38
-6
lines changed

include/linux/usb/typec_mux.h

Lines changed: 38 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -58,22 +58,54 @@ struct typec_mux_desc {
5858
void *drvdata;
5959
};
6060

61+
#if IS_ENABLED(CONFIG_TYPEC)
62+
6163
struct typec_mux *fwnode_typec_mux_get(struct fwnode_handle *fwnode,
6264
const struct typec_altmode_desc *desc);
6365
void typec_mux_put(struct typec_mux *mux);
6466
int typec_mux_set(struct typec_mux *mux, struct typec_mux_state *state);
6567

66-
static inline struct typec_mux *
67-
typec_mux_get(struct device *dev, const struct typec_altmode_desc *desc)
68-
{
69-
return fwnode_typec_mux_get(dev_fwnode(dev), desc);
70-
}
71-
7268
struct typec_mux_dev *
7369
typec_mux_register(struct device *parent, const struct typec_mux_desc *desc);
7470
void typec_mux_unregister(struct typec_mux_dev *mux);
7571

7672
void typec_mux_set_drvdata(struct typec_mux_dev *mux, void *data);
7773
void *typec_mux_get_drvdata(struct typec_mux_dev *mux);
7874

75+
#else
76+
77+
static inline struct typec_mux *fwnode_typec_mux_get(struct fwnode_handle *fwnode,
78+
const struct typec_altmode_desc *desc)
79+
{
80+
return NULL;
81+
}
82+
83+
static inline void typec_mux_put(struct typec_mux *mux) {}
84+
85+
static inline int typec_mux_set(struct typec_mux *mux, struct typec_mux_state *state)
86+
{
87+
return 0;
88+
}
89+
90+
static inline struct typec_mux_dev *
91+
typec_mux_register(struct device *parent, const struct typec_mux_desc *desc)
92+
{
93+
return ERR_PTR(-EOPNOTSUPP);
94+
}
95+
static inline void typec_mux_unregister(struct typec_mux_dev *mux) {}
96+
97+
static inline void typec_mux_set_drvdata(struct typec_mux_dev *mux, void *data) {}
98+
static inline void *typec_mux_get_drvdata(struct typec_mux_dev *mux)
99+
{
100+
return ERR_PTR(-EOPNOTSUPP);
101+
}
102+
103+
#endif /* CONFIG_TYPEC */
104+
105+
static inline struct typec_mux *
106+
typec_mux_get(struct device *dev, const struct typec_altmode_desc *desc)
107+
{
108+
return fwnode_typec_mux_get(dev_fwnode(dev), desc);
109+
}
110+
79111
#endif /* __USB_TYPEC_MUX */

0 commit comments

Comments
 (0)