Skip to content

Commit d74be6d

Browse files
GnurouLinus Walleij
authored andcommitted
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>
1 parent 1bd6b60 commit d74be6d

7 files changed

Lines changed: 25 additions & 38 deletions

File tree

‎Documentation/gpio/driver.txt‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -157,12 +157,12 @@ Locking IRQ usage
157157
Input GPIOs can be used as IRQ signals. When this happens, a driver is requested
158158
to mark the GPIO as being used as an IRQ:
159159

160-
int gpiod_lock_as_irq(struct gpio_desc *desc)
160+
int gpio_lock_as_irq(struct gpio_chip *chip, unsigned int offset)
161161

162162
This will prevent the use of non-irq related GPIO APIs until the GPIO IRQ lock
163163
is released:
164164

165-
void gpiod_unlock_as_irq(struct gpio_desc *desc)
165+
void gpio_unlock_as_irq(struct gpio_chip *chip, unsigned int offset)
166166

167167
When implementing an irqchip inside a GPIO driver, these two functions should
168168
typically be called in the .startup() and .shutdown() callbacks from the

‎drivers/gpio/gpiolib-acpi.c‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,7 @@ static acpi_status acpi_gpiochip_request_interrupt(struct acpi_resource *ares,
157157

158158
gpiod_direction_input(desc);
159159

160-
ret = gpiod_lock_as_irq(desc);
160+
ret = gpio_lock_as_irq(chip, pin);
161161
if (ret) {
162162
dev_err(chip->dev, "Failed to lock GPIO as interrupt\n");
163163
goto fail_free_desc;
@@ -212,7 +212,7 @@ static acpi_status acpi_gpiochip_request_interrupt(struct acpi_resource *ares,
212212
fail_free_event:
213213
kfree(event);
214214
fail_unlock_irq:
215-
gpiod_unlock_as_irq(desc);
215+
gpio_unlock_as_irq(chip, pin);
216216
fail_free_desc:
217217
gpiochip_free_own_desc(desc);
218218

@@ -263,7 +263,7 @@ static void acpi_gpiochip_free_interrupts(struct acpi_gpio_chip *acpi_gpio)
263263
desc = gpiochip_get_desc(chip, event->pin);
264264
if (WARN_ON(IS_ERR(desc)))
265265
continue;
266-
gpiod_unlock_as_irq(desc);
266+
gpio_unlock_as_irq(chip, event->pin);
267267
gpiochip_free_own_desc(desc);
268268
list_del(&event->node);
269269
kfree(event);

‎drivers/gpio/gpiolib-legacy.c‎

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -100,15 +100,3 @@ void gpio_free_array(const struct gpio *array, size_t num)
100100
gpio_free((array++)->gpio);
101101
}
102102
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);

‎drivers/gpio/gpiolib-sysfs.c‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,7 @@ static int gpio_setup_irq(struct gpio_desc *desc, struct device *dev,
161161
desc->flags &= ~GPIO_TRIGGER_MASK;
162162

163163
if (!gpio_flags) {
164-
gpiod_unlock_as_irq(desc);
164+
gpio_unlock_as_irq(desc->chip, gpio_chip_hwgpio(desc));
165165
ret = 0;
166166
goto free_id;
167167
}
@@ -200,7 +200,7 @@ static int gpio_setup_irq(struct gpio_desc *desc, struct device *dev,
200200
if (ret < 0)
201201
goto free_id;
202202

203-
ret = gpiod_lock_as_irq(desc);
203+
ret = gpio_lock_as_irq(desc->chip, gpio_chip_hwgpio(desc));
204204
if (ret < 0) {
205205
gpiod_warn(desc, "failed to flag the GPIO for IRQ\n");
206206
goto free_id;

‎drivers/gpio/gpiolib.c‎

Lines changed: 16 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1428,44 +1428,46 @@ int gpiod_to_irq(const struct gpio_desc *desc)
14281428
EXPORT_SYMBOL_GPL(gpiod_to_irq);
14291429

14301430
/**
1431-
* gpiod_lock_as_irq() - lock a GPIO to be used as IRQ
1432-
* @gpio: the GPIO line to lock as used for IRQ
1431+
* gpio_lock_as_irq() - lock a GPIO to be used as IRQ
1432+
* @chip: the chip the GPIO to lock belongs to
1433+
* @offset: the offset of the GPIO to lock as IRQ
14331434
*
14341435
* This is used directly by GPIO drivers that want to lock down
14351436
* a certain GPIO line to be used for IRQs.
14361437
*/
1437-
int gpiod_lock_as_irq(struct gpio_desc *desc)
1438+
int gpio_lock_as_irq(struct gpio_chip *chip, unsigned int offset)
14381439
{
1439-
if (!desc)
1440+
if (offset >= chip->ngpio)
14401441
return -EINVAL;
14411442

1442-
if (test_bit(FLAG_IS_OUT, &desc->flags)) {
1443-
gpiod_err(desc,
1443+
if (test_bit(FLAG_IS_OUT, &chip->desc[offset].flags)) {
1444+
chip_err(chip,
14441445
"%s: tried to flag a GPIO set as output for IRQ\n",
14451446
__func__);
14461447
return -EIO;
14471448
}
14481449

1449-
set_bit(FLAG_USED_AS_IRQ, &desc->flags);
1450+
set_bit(FLAG_USED_AS_IRQ, &chip->desc[offset].flags);
14501451
return 0;
14511452
}
1452-
EXPORT_SYMBOL_GPL(gpiod_lock_as_irq);
1453+
EXPORT_SYMBOL_GPL(gpio_lock_as_irq);
14531454

14541455
/**
1455-
* gpiod_unlock_as_irq() - unlock a GPIO used as IRQ
1456-
* @gpio: the GPIO line to unlock from IRQ usage
1456+
* gpio_unlock_as_irq() - unlock a GPIO used as IRQ
1457+
* @chip: the chip the GPIO to lock belongs to
1458+
* @offset: the offset of the GPIO to lock as IRQ
14571459
*
14581460
* This is used directly by GPIO drivers that want to indicate
14591461
* that a certain GPIO is no longer used exclusively for IRQ.
14601462
*/
1461-
void gpiod_unlock_as_irq(struct gpio_desc *desc)
1463+
void gpio_unlock_as_irq(struct gpio_chip *chip, unsigned int offset)
14621464
{
1463-
if (!desc)
1465+
if (offset >= chip->ngpio)
14641466
return;
14651467

1466-
clear_bit(FLAG_USED_AS_IRQ, &desc->flags);
1468+
clear_bit(FLAG_USED_AS_IRQ, &chip->desc[offset].flags);
14671469
}
1468-
EXPORT_SYMBOL_GPL(gpiod_unlock_as_irq);
1470+
EXPORT_SYMBOL_GPL(gpio_unlock_as_irq);
14691471

14701472
/**
14711473
* gpiod_get_raw_value_cansleep() - return a gpio's raw value

‎include/asm-generic/gpio.h‎

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -110,9 +110,6 @@ static inline int __gpio_to_irq(unsigned gpio)
110110
return gpiod_to_irq(gpio_to_desc(gpio));
111111
}
112112

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-
116113
extern int gpio_request_one(unsigned gpio, unsigned long flags, const char *label);
117114
extern int gpio_request_array(const struct gpio *array, size_t num);
118115
extern void gpio_free_array(const struct gpio *array, size_t num);

‎include/linux/gpio/driver.h‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -146,8 +146,8 @@ extern struct gpio_chip *gpiochip_find(void *data,
146146
int (*match)(struct gpio_chip *chip, void *data));
147147

148148
/* lock/unlock as IRQ */
149-
int gpiod_lock_as_irq(struct gpio_desc *desc);
150-
void gpiod_unlock_as_irq(struct gpio_desc *desc);
149+
int gpio_lock_as_irq(struct gpio_chip *chip, unsigned int offset);
150+
void gpio_unlock_as_irq(struct gpio_chip *chip, unsigned int offset);
151151

152152
struct gpio_chip *gpiod_to_chip(const struct gpio_desc *desc);
153153

0 commit comments

Comments
 (0)