aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/gpio/gpiolib.c
diff options
context:
space:
mode:
authorLinus Walleij <linus.walleij@linaro.org>2017-01-26 04:00:31 -0500
committerLinus Walleij <linus.walleij@linaro.org>2017-01-26 04:00:31 -0500
commit8c541b11483b099b8ce49211e766c6df77dce11b (patch)
tree3b784d41e19dbfe9429e430c94508caafb032590 /drivers/gpio/gpiolib.c
parent49cec4d8326b27e64779f888c680466d7863558f (diff)
parentb2987d7438e0ca949d81774ca8b43d370a1f9947 (diff)
Merge branch 'ib-gpiod-flags' into devel
Diffstat (limited to 'drivers/gpio/gpiolib.c')
-rw-r--r--drivers/gpio/gpiolib.c23
1 files changed, 18 insertions, 5 deletions
diff --git a/drivers/gpio/gpiolib.c b/drivers/gpio/gpiolib.c
index c76fa4ffb59c..14ee088c80dd 100644
--- a/drivers/gpio/gpiolib.c
+++ b/drivers/gpio/gpiolib.c
@@ -3301,6 +3301,7 @@ EXPORT_SYMBOL_GPL(gpiod_get_index);
3301 * fwnode_get_named_gpiod - obtain a GPIO from firmware node 3301 * fwnode_get_named_gpiod - obtain a GPIO from firmware node
3302 * @fwnode: handle of the firmware node 3302 * @fwnode: handle of the firmware node
3303 * @propname: name of the firmware property representing the GPIO 3303 * @propname: name of the firmware property representing the GPIO
3304 * @dflags: GPIO initialization flags
3304 * 3305 *
3305 * This function can be used for drivers that get their configuration 3306 * This function can be used for drivers that get their configuration
3306 * from firmware. 3307 * from firmware.
@@ -3309,12 +3310,18 @@ EXPORT_SYMBOL_GPL(gpiod_get_index);
3309 * underlying firmware interface and then makes sure that the GPIO 3310 * underlying firmware interface and then makes sure that the GPIO
3310 * descriptor is requested before it is returned to the caller. 3311 * descriptor is requested before it is returned to the caller.
3311 * 3312 *
3313 * On successfull request the GPIO pin is configured in accordance with
3314 * provided @dflags.
3315 *
3312 * In case of error an ERR_PTR() is returned. 3316 * In case of error an ERR_PTR() is returned.
3313 */ 3317 */
3314struct gpio_desc *fwnode_get_named_gpiod(struct fwnode_handle *fwnode, 3318struct gpio_desc *fwnode_get_named_gpiod(struct fwnode_handle *fwnode,
3315 const char *propname) 3319 const char *propname,
3320 enum gpiod_flags dflags,
3321 const char *label)
3316{ 3322{
3317 struct gpio_desc *desc = ERR_PTR(-ENODEV); 3323 struct gpio_desc *desc = ERR_PTR(-ENODEV);
3324 unsigned long lflags = 0;
3318 bool active_low = false; 3325 bool active_low = false;
3319 bool single_ended = false; 3326 bool single_ended = false;
3320 int ret; 3327 int ret;
@@ -3342,18 +3349,24 @@ struct gpio_desc *fwnode_get_named_gpiod(struct fwnode_handle *fwnode,
3342 if (IS_ERR(desc)) 3349 if (IS_ERR(desc))
3343 return desc; 3350 return desc;
3344 3351
3345 ret = gpiod_request(desc, NULL); 3352 ret = gpiod_request(desc, label);
3346 if (ret) 3353 if (ret)
3347 return ERR_PTR(ret); 3354 return ERR_PTR(ret);
3348 3355
3349 if (active_low) 3356 if (active_low)
3350 set_bit(FLAG_ACTIVE_LOW, &desc->flags); 3357 lflags |= GPIO_ACTIVE_LOW;
3351 3358
3352 if (single_ended) { 3359 if (single_ended) {
3353 if (active_low) 3360 if (active_low)
3354 set_bit(FLAG_OPEN_DRAIN, &desc->flags); 3361 lflags |= GPIO_OPEN_DRAIN;
3355 else 3362 else
3356 set_bit(FLAG_OPEN_SOURCE, &desc->flags); 3363 lflags |= GPIO_OPEN_SOURCE;
3364 }
3365
3366 ret = gpiod_configure_flags(desc, propname, lflags, dflags);
3367 if (ret < 0) {
3368 gpiod_put(desc);
3369 return ERR_PTR(ret);
3357 } 3370 }
3358 3371
3359 return desc; 3372 return desc;