Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 2f56e0a5 authored by Javier Martinez Canillas's avatar Javier Martinez Canillas Committed by Linus Walleij
Browse files

gpio/omap: use gpiolib API to mark a GPIO used as an IRQ



The OMAP GPIO driver keeps track about GPIO pins that are
used as IRQ lines for two reasons:

1) To prevent GPIO banks to be disabled while one of their
   GPIO pins are only used as an interrupt line.

2) To not allow another caller to set the GPIO pin as output.

Now gpiolib has an API to mark GPIO pins as used as IRQ lines
so the GPIO core only allows to set as output GPIO pins not
tied to an IRQ. So there is no need to have custom code for 2).

The IRQ usage still has to be maintained locally for 1) though.

Signed-off-by: default avatarJavier Martinez Canillas <javier.martinez@collabora.co.uk>
Signed-off-by: default avatarLinus Walleij <linus.walleij@linaro.org>
parent 263c43a4
Loading
Loading
Loading
Loading
+10 −10
Original line number Original line Diff line number Diff line
@@ -514,6 +514,14 @@ static int gpio_irq_type(struct irq_data *d, unsigned type)
		return -EINVAL;
		return -EINVAL;
	}
	}


	retval = gpio_lock_as_irq(&bank->chip, offset);
	if (retval) {
		dev_err(bank->dev, "unable to lock offset %d for IRQ\n",
			offset);
		spin_unlock_irqrestore(&bank->lock, flags);
		return retval;
	}

	bank->irq_usage |= 1 << GPIO_INDEX(bank, gpio);
	bank->irq_usage |= 1 << GPIO_INDEX(bank, gpio);
	spin_unlock_irqrestore(&bank->lock, flags);
	spin_unlock_irqrestore(&bank->lock, flags);


@@ -797,6 +805,7 @@ static void gpio_irq_shutdown(struct irq_data *d)
	unsigned offset = GPIO_INDEX(bank, gpio);
	unsigned offset = GPIO_INDEX(bank, gpio);


	spin_lock_irqsave(&bank->lock, flags);
	spin_lock_irqsave(&bank->lock, flags);
	gpio_unlock_as_irq(&bank->chip, offset);
	bank->irq_usage &= ~(1 << offset);
	bank->irq_usage &= ~(1 << offset);
	_disable_gpio_module(bank, offset);
	_disable_gpio_module(bank, offset);
	_reset_gpio(bank, gpio);
	_reset_gpio(bank, gpio);
@@ -957,22 +966,13 @@ static int gpio_output(struct gpio_chip *chip, unsigned offset, int value)
{
{
	struct gpio_bank *bank;
	struct gpio_bank *bank;
	unsigned long flags;
	unsigned long flags;
	int retval = 0;


	bank = container_of(chip, struct gpio_bank, chip);
	bank = container_of(chip, struct gpio_bank, chip);
	spin_lock_irqsave(&bank->lock, flags);
	spin_lock_irqsave(&bank->lock, flags);

	if (LINE_USED(bank->irq_usage, offset)) {
			retval = -EINVAL;
			goto exit;
	}

	bank->set_dataout(bank, offset, value);
	bank->set_dataout(bank, offset, value);
	_set_gpio_direction(bank, offset, 0);
	_set_gpio_direction(bank, offset, 0);

exit:
	spin_unlock_irqrestore(&bank->lock, flags);
	spin_unlock_irqrestore(&bank->lock, flags);
	return retval;
	return 0;
}
}


static int gpio_debounce(struct gpio_chip *chip, unsigned offset,
static int gpio_debounce(struct gpio_chip *chip, unsigned offset,