diff options
-rw-r--r-- | Documentation/gpio/driver.txt | 4 | ||||
-rw-r--r-- | drivers/gpio/gpiolib-acpi.c | 6 | ||||
-rw-r--r-- | drivers/gpio/gpiolib-legacy.c | 12 | ||||
-rw-r--r-- | drivers/gpio/gpiolib-sysfs.c | 4 | ||||
-rw-r--r-- | drivers/gpio/gpiolib.c | 30 | ||||
-rw-r--r-- | include/asm-generic/gpio.h | 3 | ||||
-rw-r--r-- | include/linux/gpio/driver.h | 4 |
7 files changed, 25 insertions, 38 deletions
diff --git a/Documentation/gpio/driver.txt b/Documentation/gpio/driver.txt index fa9a0a8b3734..224dbbcd1804 100644 --- a/Documentation/gpio/driver.txt +++ b/Documentation/gpio/driver.txt | |||
@@ -157,12 +157,12 @@ Locking IRQ usage | |||
157 | Input GPIOs can be used as IRQ signals. When this happens, a driver is requested | 157 | Input GPIOs can be used as IRQ signals. When this happens, a driver is requested |
158 | to mark the GPIO as being used as an IRQ: | 158 | to mark the GPIO as being used as an IRQ: |
159 | 159 | ||
160 | int gpiod_lock_as_irq(struct gpio_desc *desc) | 160 | int gpio_lock_as_irq(struct gpio_chip *chip, unsigned int offset) |
161 | 161 | ||
162 | This will prevent the use of non-irq related GPIO APIs until the GPIO IRQ lock | 162 | This will prevent the use of non-irq related GPIO APIs until the GPIO IRQ lock |
163 | is released: | 163 | is released: |
164 | 164 | ||
165 | void gpiod_unlock_as_irq(struct gpio_desc *desc) | 165 | void gpio_unlock_as_irq(struct gpio_chip *chip, unsigned int offset) |
166 | 166 | ||
167 | When implementing an irqchip inside a GPIO driver, these two functions should | 167 | When implementing an irqchip inside a GPIO driver, these two functions should |
168 | typically be called in the .startup() and .shutdown() callbacks from the | 168 | typically be called in the .startup() and .shutdown() callbacks from the |
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, | |||
212 | fail_free_event: | 212 | fail_free_event: |
213 | kfree(event); | 213 | kfree(event); |
214 | fail_unlock_irq: | 214 | fail_unlock_irq: |
215 | gpiod_unlock_as_irq(desc); | 215 | gpio_unlock_as_irq(chip, pin); |
216 | fail_free_desc: | 216 | fail_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 | } |
102 | EXPORT_SYMBOL_GPL(gpio_free_array); | 102 | EXPORT_SYMBOL_GPL(gpio_free_array); |
103 | |||
104 | int gpio_lock_as_irq(struct gpio_chip *chip, unsigned int offset) | ||
105 | { | ||
106 | return gpiod_lock_as_irq(gpiochip_get_desc(chip, offset)); | ||
107 | } | ||
108 | EXPORT_SYMBOL_GPL(gpio_lock_as_irq); | ||
109 | |||
110 | void gpio_unlock_as_irq(struct gpio_chip *chip, unsigned int offset) | ||
111 | { | ||
112 | return gpiod_unlock_as_irq(gpiochip_get_desc(chip, offset)); | ||
113 | } | ||
114 | EXPORT_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) | |||
1428 | EXPORT_SYMBOL_GPL(gpiod_to_irq); | 1428 | EXPORT_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 | */ |
1437 | int gpiod_lock_as_irq(struct gpio_desc *desc) | 1438 | int 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 | } |
1452 | EXPORT_SYMBOL_GPL(gpiod_lock_as_irq); | 1453 | EXPORT_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 | */ |
1461 | void gpiod_unlock_as_irq(struct gpio_desc *desc) | 1463 | void 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 | } |
1468 | EXPORT_SYMBOL_GPL(gpiod_unlock_as_irq); | 1470 | EXPORT_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 |
diff --git a/include/asm-generic/gpio.h b/include/asm-generic/gpio.h index 23e364538ab5..c1d4105e1c1d 100644 --- a/include/asm-generic/gpio.h +++ b/include/asm-generic/gpio.h | |||
@@ -110,9 +110,6 @@ static inline int __gpio_to_irq(unsigned gpio) | |||
110 | return gpiod_to_irq(gpio_to_desc(gpio)); | 110 | return gpiod_to_irq(gpio_to_desc(gpio)); |
111 | } | 111 | } |
112 | 112 | ||
113 | extern int gpio_lock_as_irq(struct gpio_chip *chip, unsigned int offset); | ||
114 | extern void gpio_unlock_as_irq(struct gpio_chip *chip, unsigned int offset); | ||
115 | |||
116 | extern int gpio_request_one(unsigned gpio, unsigned long flags, const char *label); | 113 | extern int gpio_request_one(unsigned gpio, unsigned long flags, const char *label); |
117 | extern int gpio_request_array(const struct gpio *array, size_t num); | 114 | extern int gpio_request_array(const struct gpio *array, size_t num); |
118 | extern void gpio_free_array(const struct gpio *array, size_t num); | 115 | extern void gpio_free_array(const struct gpio *array, size_t num); |
diff --git a/include/linux/gpio/driver.h b/include/linux/gpio/driver.h index 88f92dfae545..c66c91682d9e 100644 --- a/include/linux/gpio/driver.h +++ b/include/linux/gpio/driver.h | |||
@@ -146,8 +146,8 @@ extern struct gpio_chip *gpiochip_find(void *data, | |||
146 | int (*match)(struct gpio_chip *chip, void *data)); | 146 | int (*match)(struct gpio_chip *chip, void *data)); |
147 | 147 | ||
148 | /* lock/unlock as IRQ */ | 148 | /* lock/unlock as IRQ */ |
149 | int gpiod_lock_as_irq(struct gpio_desc *desc); | 149 | int gpio_lock_as_irq(struct gpio_chip *chip, unsigned int offset); |
150 | void gpiod_unlock_as_irq(struct gpio_desc *desc); | 150 | void gpio_unlock_as_irq(struct gpio_chip *chip, unsigned int offset); |
151 | 151 | ||
152 | struct gpio_chip *gpiod_to_chip(const struct gpio_desc *desc); | 152 | struct gpio_chip *gpiod_to_chip(const struct gpio_desc *desc); |
153 | 153 | ||