diff options
Diffstat (limited to 'drivers/gpio/gpiolib.c')
-rw-r--r-- | drivers/gpio/gpiolib.c | 30 |
1 files changed, 16 insertions, 14 deletions
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 |