aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/gpio/gpiolib.c
diff options
context:
space:
mode:
authorAlexandre Courbot <acourbot@nvidia.com>2013-11-16 07:44:52 -0500
committerLinus Walleij <linus.walleij@linaro.org>2013-11-25 03:03:12 -0500
commit53e7cac35db5941f42221314c33693e71ffa496b (patch)
tree1df9f325363d80e37a424a3f7e37f49533b9a975 /drivers/gpio/gpiolib.c
parent79697ef94c48df8831a156bbb046e94215b7300d (diff)
gpiolib: use dedicated flags for GPIO properties
GPIO mapping properties were defined using the GPIOF_* flags, which are declared in linux/gpio.h. This file is not included when using the GPIO descriptor interface. This patch declares the flags that can be used as GPIO mappings properties in linux/gpio/driver.h, and uses them in gpiolib, so that no deprecated declarations are used by the GPIO descriptor interface. This patch also allows GPIO_OPEN_DRAIN and GPIO_OPEN_SOURCE to be specified as GPIO mapping properties. Signed-off-by: Alexandre Courbot <acourbot@nvidia.com> Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
Diffstat (limited to 'drivers/gpio/gpiolib.c')
-rw-r--r--drivers/gpio/gpiolib.c22
1 files changed, 15 insertions, 7 deletions
diff --git a/drivers/gpio/gpiolib.c b/drivers/gpio/gpiolib.c
index d8938b9b794a..490198365ce4 100644
--- a/drivers/gpio/gpiolib.c
+++ b/drivers/gpio/gpiolib.c
@@ -14,6 +14,7 @@
14#include <linux/idr.h> 14#include <linux/idr.h>
15#include <linux/slab.h> 15#include <linux/slab.h>
16#include <linux/acpi.h> 16#include <linux/acpi.h>
17#include <linux/gpio/driver.h>
17 18
18#define CREATE_TRACE_POINTS 19#define CREATE_TRACE_POINTS
19#include <trace/events/gpio.h> 20#include <trace/events/gpio.h>
@@ -2274,7 +2275,8 @@ void gpiod_add_table(struct gpiod_lookup *table, size_t size)
2274 2275
2275#ifdef CONFIG_OF 2276#ifdef CONFIG_OF
2276static struct gpio_desc *of_find_gpio(struct device *dev, const char *con_id, 2277static struct gpio_desc *of_find_gpio(struct device *dev, const char *con_id,
2277 unsigned int idx, unsigned long *flags) 2278 unsigned int idx,
2279 enum gpio_lookup_flags *flags)
2278{ 2280{
2279 char prop_name[32]; /* 32 is max size of property name */ 2281 char prop_name[32]; /* 32 is max size of property name */
2280 enum of_gpio_flags of_flags; 2282 enum of_gpio_flags of_flags;
@@ -2292,7 +2294,7 @@ static struct gpio_desc *of_find_gpio(struct device *dev, const char *con_id,
2292 return desc; 2294 return desc;
2293 2295
2294 if (of_flags & OF_GPIO_ACTIVE_LOW) 2296 if (of_flags & OF_GPIO_ACTIVE_LOW)
2295 *flags |= GPIOF_ACTIVE_LOW; 2297 *flags |= GPIO_ACTIVE_LOW;
2296 2298
2297 return desc; 2299 return desc;
2298} 2300}
@@ -2305,7 +2307,8 @@ static struct gpio_desc *of_find_gpio(struct device *dev, const char *con_id,
2305#endif 2307#endif
2306 2308
2307static struct gpio_desc *acpi_find_gpio(struct device *dev, const char *con_id, 2309static struct gpio_desc *acpi_find_gpio(struct device *dev, const char *con_id,
2308 unsigned int idx, unsigned long *flags) 2310 unsigned int idx,
2311 enum gpio_lookup_flags *flags)
2309{ 2312{
2310 struct acpi_gpio_info info; 2313 struct acpi_gpio_info info;
2311 struct gpio_desc *desc; 2314 struct gpio_desc *desc;
@@ -2315,13 +2318,14 @@ static struct gpio_desc *acpi_find_gpio(struct device *dev, const char *con_id,
2315 return desc; 2318 return desc;
2316 2319
2317 if (info.gpioint && info.active_low) 2320 if (info.gpioint && info.active_low)
2318 *flags |= GPIOF_ACTIVE_LOW; 2321 *flags |= GPIO_ACTIVE_LOW;
2319 2322
2320 return desc; 2323 return desc;
2321} 2324}
2322 2325
2323static struct gpio_desc *gpiod_find(struct device *dev, const char *con_id, 2326static struct gpio_desc *gpiod_find(struct device *dev, const char *con_id,
2324 unsigned int idx, unsigned long *flags) 2327 unsigned int idx,
2328 enum gpio_lookup_flags *flags)
2325{ 2329{
2326 const char *dev_id = dev ? dev_name(dev) : NULL; 2330 const char *dev_id = dev ? dev_name(dev) : NULL;
2327 struct gpio_desc *desc = ERR_PTR(-ENODEV); 2331 struct gpio_desc *desc = ERR_PTR(-ENODEV);
@@ -2413,7 +2417,7 @@ struct gpio_desc *__must_check gpiod_get_index(struct device *dev,
2413{ 2417{
2414 struct gpio_desc *desc; 2418 struct gpio_desc *desc;
2415 int status; 2419 int status;
2416 unsigned long flags = 0; 2420 enum gpio_lookup_flags flags = 0;
2417 2421
2418 dev_dbg(dev, "GPIO lookup for consumer %s\n", con_id); 2422 dev_dbg(dev, "GPIO lookup for consumer %s\n", con_id);
2419 2423
@@ -2439,8 +2443,12 @@ struct gpio_desc *__must_check gpiod_get_index(struct device *dev,
2439 if (status < 0) 2443 if (status < 0)
2440 return ERR_PTR(status); 2444 return ERR_PTR(status);
2441 2445
2442 if (flags & GPIOF_ACTIVE_LOW) 2446 if (flags & GPIO_ACTIVE_LOW)
2443 set_bit(FLAG_ACTIVE_LOW, &desc->flags); 2447 set_bit(FLAG_ACTIVE_LOW, &desc->flags);
2448 if (flags & GPIO_OPEN_DRAIN)
2449 set_bit(FLAG_OPEN_DRAIN, &desc->flags);
2450 if (flags & GPIO_OPEN_SOURCE)
2451 set_bit(FLAG_OPEN_SOURCE, &desc->flags);
2444 2452
2445 return desc; 2453 return desc;
2446} 2454}