From d4a7942e29b905064dd46a3c4b05e84e60d9ca57 Mon Sep 17 00:00:00 2001 From: Mark Brown Date: Wed, 2 May 2012 12:46:46 +0100 Subject: [PATCH] --- yaml --- r: 307685 b: refs/heads/master c: 09d71ff19404b3957fab6de942fb8026ccfd8524 h: refs/heads/master i: 307683: b5c9b62a04ffa006fb34e15dce9767d667390764 v: v3 --- [refs] | 2 +- trunk/drivers/gpio/devres.c | 29 +++++++++++++++++++++++++++++ trunk/include/asm-generic/gpio.h | 2 ++ trunk/include/linux/gpio.h | 6 ++++++ 4 files changed, 38 insertions(+), 1 deletion(-) diff --git a/[refs] b/[refs] index b90fca171a31..605989938af9 100644 --- a/[refs] +++ b/[refs] @@ -1,2 +1,2 @@ --- -refs/heads/master: eb1567f7ad0032ba7b02b878e352f191d53dc228 +refs/heads/master: 09d71ff19404b3957fab6de942fb8026ccfd8524 diff --git a/trunk/drivers/gpio/devres.c b/trunk/drivers/gpio/devres.c index 3dd29399cef5..d21a9ff38551 100644 --- a/trunk/drivers/gpio/devres.c +++ b/trunk/drivers/gpio/devres.c @@ -70,6 +70,35 @@ int devm_gpio_request(struct device *dev, unsigned gpio, const char *label) } EXPORT_SYMBOL(devm_gpio_request); +/** + * devm_gpio_request_one - request a single GPIO with initial setup + * @dev: device to request for + * @gpio: the GPIO number + * @flags: GPIO configuration as specified by GPIOF_* + * @label: a literal description string of this GPIO + */ +int devm_gpio_request_one(struct device *dev, unsigned gpio, + unsigned long flags, const char *label) +{ + unsigned *dr; + int rc; + + dr = devres_alloc(devm_gpio_release, sizeof(unsigned), GFP_KERNEL); + if (!dr) + return -ENOMEM; + + rc = gpio_request_one(gpio, flags, label); + if (rc) { + devres_free(dr); + return rc; + } + + *dr = gpio; + devres_add(dev, dr); + + return 0; +} + /** * devm_gpio_free - free an interrupt * @dev: device to free gpio for diff --git a/trunk/include/asm-generic/gpio.h b/trunk/include/asm-generic/gpio.h index 5f52690c3c8f..4ead12332c66 100644 --- a/trunk/include/asm-generic/gpio.h +++ b/trunk/include/asm-generic/gpio.h @@ -179,6 +179,8 @@ extern void gpio_free_array(const struct gpio *array, size_t num); /* bindings for managed devices that want to request gpios */ int devm_gpio_request(struct device *dev, unsigned gpio, const char *label); +int devm_gpio_request_one(struct device *dev, unsigned gpio, + unsigned long flags, const char *label); void devm_gpio_free(struct device *dev, unsigned int gpio); #ifdef CONFIG_GPIO_SYSFS diff --git a/trunk/include/linux/gpio.h b/trunk/include/linux/gpio.h index 7a8816a1a0d8..f07fc2d08159 100644 --- a/trunk/include/linux/gpio.h +++ b/trunk/include/linux/gpio.h @@ -106,6 +106,12 @@ static inline int gpio_request_one(unsigned gpio, return -ENOSYS; } +static inline int devm_gpio_request_one(struct device *dev, unsigned gpio, + unsigned long flags, const char *label) +{ + return -ENOSYS; +} + static inline int gpio_request_array(const struct gpio *array, size_t num) { return -ENOSYS;