From mboxrd@z Thu Jan 1 00:00:00 1970 From: Nicolas Ferre Subject: Re: [PATCH] pinctrl: at91: move lock/unlock_as_irq calls into request/release resources methods Date: Thu, 26 Feb 2015 14:32:02 +0100 Message-ID: <54EF2052.6030909@atmel.com> References: <1423419822-6258-1-git-send-email-boris.brezillon@free-electrons.com> Mime-Version: 1.0 Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: QUOTED-PRINTABLE Return-path: In-Reply-To: <1423419822-6258-1-git-send-email-boris.brezillon@free-electrons.com> Sender: linux-kernel-owner@vger.kernel.org To: Boris Brezillon , Linus Walleij Cc: Jean-Christophe Plagniol-Villard , Alexandre Belloni , linux-gpio@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, Jean-Jacques Hiblot List-Id: linux-gpio@vger.kernel.org Le 08/02/2015 19:23, Boris Brezillon a =E9crit : > 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). >=20 > irq_request/release_resources functions have been created to address = this > problem. >=20 > 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. >=20 > Signed-off-by: Boris Brezillon If it can speed up things: Acked-by: Nicolas Ferre Linus, can we schedule this fix during the 4.0-rc phase? Bye, > --- > drivers/pinctrl/pinctrl-at91.c | 17 +++++++---------- > 1 file changed, 7 insertions(+), 10 deletions(-) >=20 > diff --git a/drivers/pinctrl/pinctrl-at91.c b/drivers/pinctrl/pinctrl= -at91.c > index f4cd0b9..a481406 100644 > --- a/drivers/pinctrl/pinctrl-at91.c > +++ b/drivers/pinctrl/pinctrl-at91.c > @@ -1477,28 +1477,25 @@ static void gpio_irq_ack(struct irq_data *d) > /* the interrupt is already cleared before by reading ISR */ > } > =20 > -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 =3D irq_data_get_irq_chip_data(d); > unsigned pin =3D d->hwirq; > int ret; > =20 > ret =3D 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", > d->hwirq); > - return ret; > - } > - gpio_irq_unmask(d); > - return 0; > + > + return ret; > } > =20 > -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 =3D irq_data_get_irq_chip_data(d); > unsigned pin =3D d->hwirq; > =20 > - gpio_irq_mask(d); > gpiochip_unlock_as_irq(&at91_gpio->chip, pin); > } > =20 > @@ -1577,8 +1574,8 @@ void at91_pinctrl_gpio_resume(void) > static struct irq_chip gpio_irqchip =3D { > .name =3D "GPIO", > .irq_ack =3D gpio_irq_ack, > - .irq_startup =3D gpio_irq_startup, > - .irq_shutdown =3D gpio_irq_shutdown, > + .irq_request_resources =3D gpio_irq_request_res, > + .irq_release_resources =3D gpio_irq_release_res, > .irq_disable =3D gpio_irq_mask, > .irq_mask =3D gpio_irq_mask, > .irq_unmask =3D gpio_irq_unmask, >=20 --=20 Nicolas Ferre From mboxrd@z Thu Jan 1 00:00:00 1970 From: nicolas.ferre@atmel.com (Nicolas Ferre) Date: Thu, 26 Feb 2015 14:32:02 +0100 Subject: [PATCH] pinctrl: at91: move lock/unlock_as_irq calls into request/release resources methods In-Reply-To: <1423419822-6258-1-git-send-email-boris.brezillon@free-electrons.com> References: <1423419822-6258-1-git-send-email-boris.brezillon@free-electrons.com> Message-ID: <54EF2052.6030909@atmel.com> To: linux-arm-kernel@lists.infradead.org List-Id: linux-arm-kernel.lists.infradead.org Le 08/02/2015 19:23, Boris Brezillon a ?crit : > 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 If it can speed up things: Acked-by: Nicolas Ferre Linus, can we schedule this fix during the 4.0-rc phase? Bye, > --- > drivers/pinctrl/pinctrl-at91.c | 17 +++++++---------- > 1 file changed, 7 insertions(+), 10 deletions(-) > > diff --git a/drivers/pinctrl/pinctrl-at91.c b/drivers/pinctrl/pinctrl-at91.c > index f4cd0b9..a481406 100644 > --- a/drivers/pinctrl/pinctrl-at91.c > +++ b/drivers/pinctrl/pinctrl-at91.c > @@ -1477,28 +1477,25 @@ static void gpio_irq_ack(struct irq_data *d) > /* 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); > unsigned pin = d->hwirq; > int ret; > > 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", > d->hwirq); > - return ret; > - } > - gpio_irq_unmask(d); > - return 0; > + > + return ret; > } > > -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); > unsigned pin = d->hwirq; > > - gpio_irq_mask(d); > gpiochip_unlock_as_irq(&at91_gpio->chip, pin); > } > > @@ -1577,8 +1574,8 @@ void at91_pinctrl_gpio_resume(void) > static struct irq_chip gpio_irqchip = { > .name = "GPIO", > .irq_ack = gpio_irq_ack, > - .irq_startup = gpio_irq_startup, > - .irq_shutdown = gpio_irq_shutdown, > + .irq_request_resources = gpio_irq_request_res, > + .irq_release_resources = gpio_irq_release_res, > .irq_disable = gpio_irq_mask, > .irq_mask = gpio_irq_mask, > .irq_unmask = gpio_irq_unmask, > -- Nicolas Ferre From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932260AbbBZNcH (ORCPT ); Thu, 26 Feb 2015 08:32:07 -0500 Received: from eusmtp01.atmel.com ([212.144.249.242]:16886 "EHLO eusmtp01.atmel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753190AbbBZNcF (ORCPT ); Thu, 26 Feb 2015 08:32:05 -0500 Message-ID: <54EF2052.6030909@atmel.com> Date: Thu, 26 Feb 2015 14:32:02 +0100 From: Nicolas Ferre Organization: atmel User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.4.0 MIME-Version: 1.0 To: Boris Brezillon , Linus Walleij CC: Jean-Christophe Plagniol-Villard , "Alexandre Belloni" , , , , Jean-Jacques Hiblot Subject: Re: [PATCH] pinctrl: at91: move lock/unlock_as_irq calls into request/release resources methods References: <1423419822-6258-1-git-send-email-boris.brezillon@free-electrons.com> In-Reply-To: <1423419822-6258-1-git-send-email-boris.brezillon@free-electrons.com> Content-Type: text/plain; charset="windows-1252" Content-Transfer-Encoding: 8bit X-Originating-IP: [10.161.30.18] Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Le 08/02/2015 19:23, Boris Brezillon a écrit : > 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 If it can speed up things: Acked-by: Nicolas Ferre Linus, can we schedule this fix during the 4.0-rc phase? Bye, > --- > drivers/pinctrl/pinctrl-at91.c | 17 +++++++---------- > 1 file changed, 7 insertions(+), 10 deletions(-) > > diff --git a/drivers/pinctrl/pinctrl-at91.c b/drivers/pinctrl/pinctrl-at91.c > index f4cd0b9..a481406 100644 > --- a/drivers/pinctrl/pinctrl-at91.c > +++ b/drivers/pinctrl/pinctrl-at91.c > @@ -1477,28 +1477,25 @@ static void gpio_irq_ack(struct irq_data *d) > /* 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); > unsigned pin = d->hwirq; > int ret; > > 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", > d->hwirq); > - return ret; > - } > - gpio_irq_unmask(d); > - return 0; > + > + return ret; > } > > -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); > unsigned pin = d->hwirq; > > - gpio_irq_mask(d); > gpiochip_unlock_as_irq(&at91_gpio->chip, pin); > } > > @@ -1577,8 +1574,8 @@ void at91_pinctrl_gpio_resume(void) > static struct irq_chip gpio_irqchip = { > .name = "GPIO", > .irq_ack = gpio_irq_ack, > - .irq_startup = gpio_irq_startup, > - .irq_shutdown = gpio_irq_shutdown, > + .irq_request_resources = gpio_irq_request_res, > + .irq_release_resources = gpio_irq_release_res, > .irq_disable = gpio_irq_mask, > .irq_mask = gpio_irq_mask, > .irq_unmask = gpio_irq_unmask, > -- Nicolas Ferre