aboutsummaryrefslogtreecommitdiffstats
path: root/include/linux/pinctrl/consumer.h
diff options
context:
space:
mode:
Diffstat (limited to 'include/linux/pinctrl/consumer.h')
-rw-r--r--include/linux/pinctrl/consumer.h44
1 files changed, 44 insertions, 0 deletions
diff --git a/include/linux/pinctrl/consumer.h b/include/linux/pinctrl/consumer.h
index 191e72688481..6dd96fb45482 100644
--- a/include/linux/pinctrl/consumer.h
+++ b/include/linux/pinctrl/consumer.h
@@ -36,6 +36,9 @@ extern struct pinctrl_state * __must_check pinctrl_lookup_state(
36 const char *name); 36 const char *name);
37extern int pinctrl_select_state(struct pinctrl *p, struct pinctrl_state *s); 37extern int pinctrl_select_state(struct pinctrl *p, struct pinctrl_state *s);
38 38
39extern struct pinctrl * __must_check devm_pinctrl_get(struct device *dev);
40extern void devm_pinctrl_put(struct pinctrl *p);
41
39#else /* !CONFIG_PINCTRL */ 42#else /* !CONFIG_PINCTRL */
40 43
41static inline int pinctrl_request_gpio(unsigned gpio) 44static inline int pinctrl_request_gpio(unsigned gpio)
@@ -79,6 +82,15 @@ static inline int pinctrl_select_state(struct pinctrl *p,
79 return 0; 82 return 0;
80} 83}
81 84
85static inline struct pinctrl * __must_check devm_pinctrl_get(struct device *dev)
86{
87 return NULL;
88}
89
90static inline void devm_pinctrl_put(struct pinctrl *p)
91{
92}
93
82#endif /* CONFIG_PINCTRL */ 94#endif /* CONFIG_PINCTRL */
83 95
84static inline struct pinctrl * __must_check pinctrl_get_select( 96static inline struct pinctrl * __must_check pinctrl_get_select(
@@ -113,6 +125,38 @@ static inline struct pinctrl * __must_check pinctrl_get_select_default(
113 return pinctrl_get_select(dev, PINCTRL_STATE_DEFAULT); 125 return pinctrl_get_select(dev, PINCTRL_STATE_DEFAULT);
114} 126}
115 127
128static inline struct pinctrl * __must_check devm_pinctrl_get_select(
129 struct device *dev, const char *name)
130{
131 struct pinctrl *p;
132 struct pinctrl_state *s;
133 int ret;
134
135 p = devm_pinctrl_get(dev);
136 if (IS_ERR(p))
137 return p;
138
139 s = pinctrl_lookup_state(p, name);
140 if (IS_ERR(s)) {
141 devm_pinctrl_put(p);
142 return ERR_PTR(PTR_ERR(s));
143 }
144
145 ret = pinctrl_select_state(p, s);
146 if (ret < 0) {
147 devm_pinctrl_put(p);
148 return ERR_PTR(ret);
149 }
150
151 return p;
152}
153
154static inline struct pinctrl * __must_check devm_pinctrl_get_select_default(
155 struct device *dev)
156{
157 return devm_pinctrl_get_select(dev, PINCTRL_STATE_DEFAULT);
158}
159
116#ifdef CONFIG_PINCONF 160#ifdef CONFIG_PINCONF
117 161
118extern int pin_config_get(const char *dev_name, const char *name, 162extern int pin_config_get(const char *dev_name, const char *name,