Skip to content

Commit 45fe729

Browse files
bebarinogregkh
authored andcommitted
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>
1 parent 368ed48 commit 45fe729

1 file changed

Lines changed: 41 additions & 5 deletions

File tree

include/linux/usb/typec_mux.h

Lines changed: 41 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
#ifndef __USB_TYPEC_MUX
44
#define __USB_TYPEC_MUX
55

6+
#include <linux/err.h>
67
#include <linux/property.h>
78
#include <linux/usb/typec.h>
89

@@ -24,16 +25,13 @@ struct typec_switch_desc {
2425
void *drvdata;
2526
};
2627

28+
#if IS_ENABLED(CONFIG_TYPEC)
29+
2730
struct typec_switch *fwnode_typec_switch_get(struct fwnode_handle *fwnode);
2831
void typec_switch_put(struct typec_switch *sw);
2932
int typec_switch_set(struct typec_switch *sw,
3033
enum typec_orientation orientation);
3134

32-
static inline struct typec_switch *typec_switch_get(struct device *dev)
33-
{
34-
return fwnode_typec_switch_get(dev_fwnode(dev));
35-
}
36-
3735
struct typec_switch_dev *
3836
typec_switch_register(struct device *parent,
3937
const struct typec_switch_desc *desc);
@@ -42,6 +40,44 @@ void typec_switch_unregister(struct typec_switch_dev *sw);
4240
void typec_switch_set_drvdata(struct typec_switch_dev *sw, void *data);
4341
void *typec_switch_get_drvdata(struct typec_switch_dev *sw);
4442

43+
#else
44+
45+
static inline struct typec_switch *
46+
fwnode_typec_switch_get(struct fwnode_handle *fwnode)
47+
{
48+
return NULL;
49+
}
50+
51+
static inline void typec_switch_put(struct typec_switch *sw) {}
52+
53+
static inline int typec_switch_set(struct typec_switch *sw,
54+
enum typec_orientation orientation)
55+
{
56+
return 0;
57+
}
58+
59+
static inline struct typec_switch_dev *
60+
typec_switch_register(struct device *parent,
61+
const struct typec_switch_desc *desc)
62+
{
63+
return ERR_PTR(-EOPNOTSUPP);
64+
}
65+
66+
static inline void typec_switch_unregister(struct typec_switch_dev *sw) {}
67+
68+
static inline void typec_switch_set_drvdata(struct typec_switch_dev *sw, void *data) {}
69+
static inline void *typec_switch_get_drvdata(struct typec_switch_dev *sw)
70+
{
71+
return ERR_PTR(-EOPNOTSUPP);
72+
}
73+
74+
#endif /* CONFIG_TYPEC */
75+
76+
static inline struct typec_switch *typec_switch_get(struct device *dev)
77+
{
78+
return fwnode_typec_switch_get(dev_fwnode(dev));
79+
}
80+
4581
struct typec_mux_state {
4682
struct typec_altmode *alt;
4783
unsigned long mode;

0 commit comments

Comments
 (0)