mirror of
https://github.com/torvalds/linux.git
synced 2024-11-27 22:51:35 +00:00
pinctrl: at91: move lock/unlock_as_irq calls into request/release
The gpiochip_lock_as_irq call can fail and return an error, while the irq_startup is not expected to fail (returns an unsigned int which is not checked by irq core code). irq_request/release_resources functions have been created to address this problem. Move gpiochip_lock/unlock_as_irq calls into irq_request/release_resources functions to prevent using a gpio as an irq if the gpiochip_lock_as_irq call failed. Signed-off-by: Boris Brezillon <boris.brezillon@free-electrons.com> Acked-by: Ludovic Desroches <ludovic.desroches@atmel.com> Acked-by: Nicolas Ferre <nicolas.ferre@atmel.com> Acked-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com> Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
This commit is contained in:
parent
549e783f6a
commit
bd8733738c
@ -1477,28 +1477,25 @@ static void gpio_irq_ack(struct irq_data *d)
|
|||||||
/* the interrupt is already cleared before by reading ISR */
|
/* the interrupt is already cleared before by reading ISR */
|
||||||
}
|
}
|
||||||
|
|
||||||
static unsigned int gpio_irq_startup(struct irq_data *d)
|
static int gpio_irq_request_res(struct irq_data *d)
|
||||||
{
|
{
|
||||||
struct at91_gpio_chip *at91_gpio = irq_data_get_irq_chip_data(d);
|
struct at91_gpio_chip *at91_gpio = irq_data_get_irq_chip_data(d);
|
||||||
unsigned pin = d->hwirq;
|
unsigned pin = d->hwirq;
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
ret = gpiochip_lock_as_irq(&at91_gpio->chip, pin);
|
ret = gpiochip_lock_as_irq(&at91_gpio->chip, pin);
|
||||||
if (ret) {
|
if (ret)
|
||||||
dev_err(at91_gpio->chip.dev, "unable to lock pind %lu IRQ\n",
|
dev_err(at91_gpio->chip.dev, "unable to lock pind %lu IRQ\n",
|
||||||
d->hwirq);
|
d->hwirq);
|
||||||
return ret;
|
|
||||||
}
|
return ret;
|
||||||
gpio_irq_unmask(d);
|
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void gpio_irq_shutdown(struct irq_data *d)
|
static void gpio_irq_release_res(struct irq_data *d)
|
||||||
{
|
{
|
||||||
struct at91_gpio_chip *at91_gpio = irq_data_get_irq_chip_data(d);
|
struct at91_gpio_chip *at91_gpio = irq_data_get_irq_chip_data(d);
|
||||||
unsigned pin = d->hwirq;
|
unsigned pin = d->hwirq;
|
||||||
|
|
||||||
gpio_irq_mask(d);
|
|
||||||
gpiochip_unlock_as_irq(&at91_gpio->chip, pin);
|
gpiochip_unlock_as_irq(&at91_gpio->chip, pin);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1577,8 +1574,8 @@ void at91_pinctrl_gpio_resume(void)
|
|||||||
static struct irq_chip gpio_irqchip = {
|
static struct irq_chip gpio_irqchip = {
|
||||||
.name = "GPIO",
|
.name = "GPIO",
|
||||||
.irq_ack = gpio_irq_ack,
|
.irq_ack = gpio_irq_ack,
|
||||||
.irq_startup = gpio_irq_startup,
|
.irq_request_resources = gpio_irq_request_res,
|
||||||
.irq_shutdown = gpio_irq_shutdown,
|
.irq_release_resources = gpio_irq_release_res,
|
||||||
.irq_disable = gpio_irq_mask,
|
.irq_disable = gpio_irq_mask,
|
||||||
.irq_mask = gpio_irq_mask,
|
.irq_mask = gpio_irq_mask,
|
||||||
.irq_unmask = gpio_irq_unmask,
|
.irq_unmask = gpio_irq_unmask,
|
||||||
|
Loading…
Reference in New Issue
Block a user