diff options
author | Alexandre Courbot <acourbot@nvidia.com> | 2013-11-16 07:44:52 -0500 |
---|---|---|
committer | Linus Walleij <linus.walleij@linaro.org> | 2013-11-25 03:03:12 -0500 |
commit | 53e7cac35db5941f42221314c33693e71ffa496b (patch) | |
tree | 1df9f325363d80e37a424a3f7e37f49533b9a975 | |
parent | 79697ef94c48df8831a156bbb046e94215b7300d (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>
-rw-r--r-- | drivers/gpio/gpiolib.c | 22 | ||||
-rw-r--r-- | include/linux/gpio/driver.h | 11 |
2 files changed, 24 insertions, 9 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 |
2276 | static struct gpio_desc *of_find_gpio(struct device *dev, const char *con_id, | 2277 | static 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 | ||
2307 | static struct gpio_desc *acpi_find_gpio(struct device *dev, const char *con_id, | 2309 | static 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 | ||
2323 | static struct gpio_desc *gpiod_find(struct device *dev, const char *con_id, | 2326 | static 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 | } |
diff --git a/include/linux/gpio/driver.h b/include/linux/gpio/driver.h index 656a27efb2c8..82eac610ce1a 100644 --- a/include/linux/gpio/driver.h +++ b/include/linux/gpio/driver.h | |||
@@ -125,6 +125,13 @@ extern struct gpio_chip *gpiochip_find(void *data, | |||
125 | int gpiod_lock_as_irq(struct gpio_desc *desc); | 125 | int gpiod_lock_as_irq(struct gpio_desc *desc); |
126 | void gpiod_unlock_as_irq(struct gpio_desc *desc); | 126 | void gpiod_unlock_as_irq(struct gpio_desc *desc); |
127 | 127 | ||
128 | enum gpio_lookup_flags { | ||
129 | GPIO_ACTIVE_HIGH = (0 << 0), | ||
130 | GPIO_ACTIVE_LOW = (1 << 0), | ||
131 | GPIO_OPEN_DRAIN = (1 << 1), | ||
132 | GPIO_OPEN_SOURCE = (1 << 2), | ||
133 | }; | ||
134 | |||
128 | /** | 135 | /** |
129 | * Lookup table for associating GPIOs to specific devices and functions using | 136 | * Lookup table for associating GPIOs to specific devices and functions using |
130 | * platform data. | 137 | * platform data. |
@@ -152,9 +159,9 @@ struct gpiod_lookup { | |||
152 | */ | 159 | */ |
153 | unsigned int idx; | 160 | unsigned int idx; |
154 | /* | 161 | /* |
155 | * mask of GPIOF_* values | 162 | * mask of GPIO_* values |
156 | */ | 163 | */ |
157 | unsigned long flags; | 164 | enum gpio_lookup_flags flags; |
158 | }; | 165 | }; |
159 | 166 | ||
160 | /* | 167 | /* |