aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/gpio
diff options
context:
space:
mode:
authorAlexandre Courbot <acourbot@nvidia.com>2014-07-22 03:17:42 -0400
committerLinus Walleij <linus.walleij@linaro.org>2014-07-23 11:43:24 -0400
commitd74be6dfea1b96cfb4bd79d9254fa9d21ed5f131 (patch)
tree376ed1e1d51a70262f825af17eee4eb56e363666 /drivers/gpio
parent1bd6b601fe196b6fbce2c93536ce0f3f53577cec (diff)
gpio: remove gpiod_lock/unlock_as_irq()
gpio_lock/unlock_as_irq() are working with (chip, offset) arguments and are thus not using the old integer namespace. Therefore, there is no reason to have gpiod variants of these functions working with descriptors, especially since the (chip, offset) tuple is more suitable to the users of these functions (GPIO drivers, whereas GPIO descriptors are targeted at GPIO consumers). Signed-off-by: Alexandre Courbot <acourbot@nvidia.com> Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
Diffstat (limited to 'drivers/gpio')
-rw-r--r--drivers/gpio/gpiolib-acpi.c6
-rw-r--r--drivers/gpio/gpiolib-legacy.c12
-rw-r--r--drivers/gpio/gpiolib-sysfs.c4
-rw-r--r--drivers/gpio/gpiolib.c30
4 files changed, 21 insertions, 31 deletions
diff --git a/drivers/gpio/gpiolib-acpi.c b/drivers/gpio/gpiolib-acpi.c
index 4a987917c186..d2e8600df02c 100644
--- a/drivers/gpio/gpiolib-acpi.c
+++ b/drivers/gpio/gpiolib-acpi.c
@@ -157,7 +157,7 @@ static acpi_status acpi_gpiochip_request_interrupt(struct acpi_resource *ares,
157 157
158 gpiod_direction_input(desc); 158 gpiod_direction_input(desc);
159 159
160 ret = gpiod_lock_as_irq(desc); 160 ret = gpio_lock_as_irq(chip, pin);
161 if (ret) { 161 if (ret) {
162 dev_err(chip->dev, "Failed to lock GPIO as interrupt\n"); 162 dev_err(chip->dev, "Failed to lock GPIO as interrupt\n");
163 goto fail_free_desc; 163 goto fail_free_desc;
@@ -212,7 +212,7 @@ static acpi_status acpi_gpiochip_request_interrupt(struct acpi_resource *ares,
212fail_free_event: 212fail_free_event:
213 kfree(event); 213 kfree(event);
214fail_unlock_irq: 214fail_unlock_irq:
215 gpiod_unlock_as_irq(desc); 215 gpio_unlock_as_irq(chip, pin);
216fail_free_desc: 216fail_free_desc:
217 gpiochip_free_own_desc(desc); 217 gpiochip_free_own_desc(desc);
218 218
@@ -263,7 +263,7 @@ static void acpi_gpiochip_free_interrupts(struct acpi_gpio_chip *acpi_gpio)
263 desc = gpiochip_get_desc(chip, event->pin); 263 desc = gpiochip_get_desc(chip, event->pin);
264 if (WARN_ON(IS_ERR(desc))) 264 if (WARN_ON(IS_ERR(desc)))
265 continue; 265 continue;
266 gpiod_unlock_as_irq(desc); 266 gpio_unlock_as_irq(chip, event->pin);
267 gpiochip_free_own_desc(desc); 267 gpiochip_free_own_desc(desc);
268 list_del(&event->node); 268 list_del(&event->node);
269 kfree(event); 269 kfree(event);
diff --git a/drivers/gpio/gpiolib-legacy.c b/drivers/gpio/gpiolib-legacy.c
index c684d94cdbb4..078ae6c2df79 100644
--- a/drivers/gpio/gpiolib-legacy.c
+++ b/drivers/gpio/gpiolib-legacy.c
@@ -100,15 +100,3 @@ void gpio_free_array(const struct gpio *array, size_t num)
100 gpio_free((array++)->gpio); 100 gpio_free((array++)->gpio);
101} 101}
102EXPORT_SYMBOL_GPL(gpio_free_array); 102EXPORT_SYMBOL_GPL(gpio_free_array);
103
104int gpio_lock_as_irq(struct gpio_chip *chip, unsigned int offset)
105{
106 return gpiod_lock_as_irq(gpiochip_get_desc(chip, offset));
107}
108EXPORT_SYMBOL_GPL(gpio_lock_as_irq);
109
110void gpio_unlock_as_irq(struct gpio_chip *chip, unsigned int offset)
111{
112 return gpiod_unlock_as_irq(gpiochip_get_desc(chip, offset));
113}
114EXPORT_SYMBOL_GPL(gpio_unlock_as_irq);
diff --git a/drivers/gpio/gpiolib-sysfs.c b/drivers/gpio/gpiolib-sysfs.c
index f150aa288fa1..be45a9283c28 100644
--- a/drivers/gpio/gpiolib-sysfs.c
+++ b/drivers/gpio/gpiolib-sysfs.c
@@ -161,7 +161,7 @@ static int gpio_setup_irq(struct gpio_desc *desc, struct device *dev,
161 desc->flags &= ~GPIO_TRIGGER_MASK; 161 desc->flags &= ~GPIO_TRIGGER_MASK;
162 162
163 if (!gpio_flags) { 163 if (!gpio_flags) {
164 gpiod_unlock_as_irq(desc); 164 gpio_unlock_as_irq(desc->chip, gpio_chip_hwgpio(desc));
165 ret = 0; 165 ret = 0;
166 goto free_id; 166 goto free_id;
167 } 167 }
@@ -200,7 +200,7 @@ static int gpio_setup_irq(struct gpio_desc *desc, struct device *dev,
200 if (ret < 0) 200 if (ret < 0)
201 goto free_id; 201 goto free_id;
202 202
203 ret = gpiod_lock_as_irq(desc); 203 ret = gpio_lock_as_irq(desc->chip, gpio_chip_hwgpio(desc));
204 if (ret < 0) { 204 if (ret < 0) {
205 gpiod_warn(desc, "failed to flag the GPIO for IRQ\n"); 205 gpiod_warn(desc, "failed to flag the GPIO for IRQ\n");
206 goto free_id; 206 goto free_id;
diff --git a/drivers/gpio/gpiolib.c b/drivers/gpio/gpiolib.c
index 38d176e31379..7582207c92e7 100644
--- a/drivers/gpio/gpiolib.c
+++ b/drivers/gpio/gpiolib.c
@@ -1428,44 +1428,46 @@ int gpiod_to_irq(const struct gpio_desc *desc)
1428EXPORT_SYMBOL_GPL(gpiod_to_irq); 1428EXPORT_SYMBOL_GPL(gpiod_to_irq);
1429 1429
1430/** 1430/**
1431 * gpiod_lock_as_irq() - lock a GPIO to be used as IRQ 1431 * gpio_lock_as_irq() - lock a GPIO to be used as IRQ
1432 * @gpio: the GPIO line to lock as used for IRQ 1432 * @chip: the chip the GPIO to lock belongs to
1433 * @offset: the offset of the GPIO to lock as IRQ
1433 * 1434 *
1434 * This is used directly by GPIO drivers that want to lock down 1435 * This is used directly by GPIO drivers that want to lock down
1435 * a certain GPIO line to be used for IRQs. 1436 * a certain GPIO line to be used for IRQs.
1436 */ 1437 */
1437int gpiod_lock_as_irq(struct gpio_desc *desc) 1438int gpio_lock_as_irq(struct gpio_chip *chip, unsigned int offset)
1438{ 1439{
1439 if (!desc) 1440 if (offset >= chip->ngpio)
1440 return -EINVAL; 1441 return -EINVAL;
1441 1442
1442 if (test_bit(FLAG_IS_OUT, &desc->flags)) { 1443 if (test_bit(FLAG_IS_OUT, &chip->desc[offset].flags)) {
1443 gpiod_err(desc, 1444 chip_err(chip,
1444 "%s: tried to flag a GPIO set as output for IRQ\n", 1445 "%s: tried to flag a GPIO set as output for IRQ\n",
1445 __func__); 1446 __func__);
1446 return -EIO; 1447 return -EIO;
1447 } 1448 }
1448 1449
1449 set_bit(FLAG_USED_AS_IRQ, &desc->flags); 1450 set_bit(FLAG_USED_AS_IRQ, &chip->desc[offset].flags);
1450 return 0; 1451 return 0;
1451} 1452}
1452EXPORT_SYMBOL_GPL(gpiod_lock_as_irq); 1453EXPORT_SYMBOL_GPL(gpio_lock_as_irq);
1453 1454
1454/** 1455/**
1455 * gpiod_unlock_as_irq() - unlock a GPIO used as IRQ 1456 * gpio_unlock_as_irq() - unlock a GPIO used as IRQ
1456 * @gpio: the GPIO line to unlock from IRQ usage 1457 * @chip: the chip the GPIO to lock belongs to
1458 * @offset: the offset of the GPIO to lock as IRQ
1457 * 1459 *
1458 * This is used directly by GPIO drivers that want to indicate 1460 * This is used directly by GPIO drivers that want to indicate
1459 * that a certain GPIO is no longer used exclusively for IRQ. 1461 * that a certain GPIO is no longer used exclusively for IRQ.
1460 */ 1462 */
1461void gpiod_unlock_as_irq(struct gpio_desc *desc) 1463void gpio_unlock_as_irq(struct gpio_chip *chip, unsigned int offset)
1462{ 1464{
1463 if (!desc) 1465 if (offset >= chip->ngpio)
1464 return; 1466 return;
1465 1467
1466 clear_bit(FLAG_USED_AS_IRQ, &desc->flags); 1468 clear_bit(FLAG_USED_AS_IRQ, &chip->desc[offset].flags);
1467} 1469}
1468EXPORT_SYMBOL_GPL(gpiod_unlock_as_irq); 1470EXPORT_SYMBOL_GPL(gpio_unlock_as_irq);
1469 1471
1470/** 1472/**
1471 * gpiod_get_raw_value_cansleep() - return a gpio's raw value 1473 * gpiod_get_raw_value_cansleep() - return a gpio's raw value