Skip to content

Commit fe6c473

Browse files
Linus Walleijbroonie
authored andcommitted
gpio: Export gpiod_get_from_of_node()
This function already exist inside gpiolib, we were just reluctant to make it available to the kernel at large as the devm_* seemed to be enough for anyone. However we found out that regulators need to do their own lifecycle/refcounting on GPIO descriptors and explicitly call gpiod_put() when done with a descriptor, so export this function so we can hand the refcounting over to the regulator core for these descriptors after retrieveal. Signed-off-by: Linus Walleij <linus.walleij@linaro.org> Reviewed-by: Marek Szyprowski <m.szyprowski@samsung.com> Tested-by: Marek Szyprowski <m.szyprowski@samsung.com> Reviewed-by: Charles Keepax <ckeepax@opensource.cirrus.com> Signed-off-by: Mark Brown <broonie@kernel.org>
1 parent 894077d commit fe6c473

2 files changed

Lines changed: 13 additions & 6 deletions

File tree

‎drivers/gpio/gpiolib.h‎

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -201,12 +201,6 @@ int gpiod_set_array_value_complex(bool raw, bool can_sleep,
201201
struct gpio_array *array_info,
202202
unsigned long *value_bitmap);
203203

204-
/* This is just passed between gpiolib and devres */
205-
struct gpio_desc *gpiod_get_from_of_node(struct device_node *node,
206-
const char *propname, int index,
207-
enum gpiod_flags dflags,
208-
const char *label);
209-
210204
extern struct spinlock gpio_lock;
211205
extern struct list_head gpio_devices;
212206

‎include/linux/gpio/consumer.h‎

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -172,6 +172,10 @@ int desc_to_gpio(const struct gpio_desc *desc);
172172
struct device_node;
173173
struct fwnode_handle;
174174

175+
struct gpio_desc *gpiod_get_from_of_node(struct device_node *node,
176+
const char *propname, int index,
177+
enum gpiod_flags dflags,
178+
const char *label);
175179
struct gpio_desc *devm_gpiod_get_from_of_node(struct device *dev,
176180
struct device_node *node,
177181
const char *propname, int index,
@@ -517,6 +521,15 @@ static inline int desc_to_gpio(const struct gpio_desc *desc)
517521
struct device_node;
518522
struct fwnode_handle;
519523

524+
static inline
525+
struct gpio_desc *gpiod_get_from_of_node(struct device_node *node,
526+
const char *propname, int index,
527+
enum gpiod_flags dflags,
528+
const char *label)
529+
{
530+
return ERR_PTR(-ENOSYS);
531+
}
532+
520533
static inline
521534
struct gpio_desc *devm_gpiod_get_from_of_node(struct device *dev,
522535
struct device_node *node,

0 commit comments

Comments
 (0)