diff options
| author | Dmitry Torokhov <dmitry.torokhov@gmail.com> | 2017-02-12 20:13:55 -0500 |
|---|---|---|
| committer | Linus Walleij <linus.walleij@linaro.org> | 2017-03-15 06:16:30 -0400 |
| commit | 22c403676dbbb7c6f186099527af7f065498ef45 (patch) | |
| tree | b4c165eee3ec51b83a17bd1d62f5e0851d28287c /include/linux/gpio | |
| parent | 85c73d50e57eb8ad43955fe38714bc5fba1acd92 (diff) | |
gpio: return NULL from gpiod_get_optional when GPIOLIB is disabled
Given the intent behind gpiod_get_optional() and friends it does not make
sense to return -ENOSYS when GPIOLIB is disabled: the driver is expected to
work just fine without gpio so let's behave as if gpio was not found.
Otherwise we have to special-case -ENOSYS in drivers.
Note that there was objection that someone might forget to enable GPIOLIB
when dealing with a platform that has device that actually specifies
optional gpio and we'll break it. I find this unconvincing as that would
have to be the *only GPIO* in the system, which is extremely unlikely.
Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
Diffstat (limited to 'include/linux/gpio')
| -rw-r--r-- | include/linux/gpio/consumer.h | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/include/linux/gpio/consumer.h b/include/linux/gpio/consumer.h index 2484b2fcc6eb..13daf08e25bb 100644 --- a/include/linux/gpio/consumer.h +++ b/include/linux/gpio/consumer.h | |||
| @@ -179,14 +179,14 @@ static inline struct gpio_desc *__must_check | |||
| 179 | gpiod_get_optional(struct device *dev, const char *con_id, | 179 | gpiod_get_optional(struct device *dev, const char *con_id, |
| 180 | enum gpiod_flags flags) | 180 | enum gpiod_flags flags) |
| 181 | { | 181 | { |
| 182 | return ERR_PTR(-ENOSYS); | 182 | return NULL; |
| 183 | } | 183 | } |
| 184 | 184 | ||
| 185 | static inline struct gpio_desc *__must_check | 185 | static inline struct gpio_desc *__must_check |
| 186 | gpiod_get_index_optional(struct device *dev, const char *con_id, | 186 | gpiod_get_index_optional(struct device *dev, const char *con_id, |
| 187 | unsigned int index, enum gpiod_flags flags) | 187 | unsigned int index, enum gpiod_flags flags) |
| 188 | { | 188 | { |
| 189 | return ERR_PTR(-ENOSYS); | 189 | return NULL; |
| 190 | } | 190 | } |
| 191 | 191 | ||
| 192 | static inline struct gpio_descs *__must_check | 192 | static inline struct gpio_descs *__must_check |
| @@ -200,7 +200,7 @@ static inline struct gpio_descs *__must_check | |||
| 200 | gpiod_get_array_optional(struct device *dev, const char *con_id, | 200 | gpiod_get_array_optional(struct device *dev, const char *con_id, |
| 201 | enum gpiod_flags flags) | 201 | enum gpiod_flags flags) |
| 202 | { | 202 | { |
| 203 | return ERR_PTR(-ENOSYS); | 203 | return NULL; |
| 204 | } | 204 | } |
| 205 | 205 | ||
| 206 | static inline void gpiod_put(struct gpio_desc *desc) | 206 | static inline void gpiod_put(struct gpio_desc *desc) |
| @@ -240,14 +240,14 @@ static inline struct gpio_desc *__must_check | |||
| 240 | devm_gpiod_get_optional(struct device *dev, const char *con_id, | 240 | devm_gpiod_get_optional(struct device *dev, const char *con_id, |
| 241 | enum gpiod_flags flags) | 241 | enum gpiod_flags flags) |
| 242 | { | 242 | { |
| 243 | return ERR_PTR(-ENOSYS); | 243 | return NULL; |
| 244 | } | 244 | } |
| 245 | 245 | ||
| 246 | static inline struct gpio_desc *__must_check | 246 | static inline struct gpio_desc *__must_check |
| 247 | devm_gpiod_get_index_optional(struct device *dev, const char *con_id, | 247 | devm_gpiod_get_index_optional(struct device *dev, const char *con_id, |
| 248 | unsigned int index, enum gpiod_flags flags) | 248 | unsigned int index, enum gpiod_flags flags) |
| 249 | { | 249 | { |
| 250 | return ERR_PTR(-ENOSYS); | 250 | return NULL; |
| 251 | } | 251 | } |
| 252 | 252 | ||
| 253 | static inline struct gpio_descs *__must_check | 253 | static inline struct gpio_descs *__must_check |
| @@ -261,7 +261,7 @@ static inline struct gpio_descs *__must_check | |||
| 261 | devm_gpiod_get_array_optional(struct device *dev, const char *con_id, | 261 | devm_gpiod_get_array_optional(struct device *dev, const char *con_id, |
| 262 | enum gpiod_flags flags) | 262 | enum gpiod_flags flags) |
| 263 | { | 263 | { |
| 264 | return ERR_PTR(-ENOSYS); | 264 | return NULL; |
| 265 | } | 265 | } |
| 266 | 266 | ||
| 267 | static inline void devm_gpiod_put(struct device *dev, struct gpio_desc *desc) | 267 | static inline void devm_gpiod_put(struct device *dev, struct gpio_desc *desc) |
