Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932979AbbBIP2U (ORCPT ); Mon, 9 Feb 2015 10:28:20 -0500 Received: from 5.mo69.mail-out.ovh.net ([46.105.43.105]:34949 "EHLO 5.mo69.mail-out.ovh.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932490AbbBIP2T convert rfc822-to-8bit (ORCPT ); Mon, 9 Feb 2015 10:28:19 -0500 X-Greylist: delayed 2230 seconds by postgrey-1.27 at vger.kernel.org; Mon, 09 Feb 2015 10:28:18 EST Content-Type: text/plain; charset=utf-8 Mime-Version: 1.0 (Mac OS X Mail 8.2 \(2070.6\)) Subject: Re: [PATCH] pinctrl: at91: move lock/unlock_as_irq calls into request/release resources methods From: Jean-Christophe PLAGNIOL-VILLARD In-Reply-To: <1423419822-6258-1-git-send-email-boris.brezillon@free-electrons.com> Date: Mon, 9 Feb 2015 22:50:56 +0800 Cc: Jean-Christophe PLAGNIOL-VILLARD , Nicolas FERRE , Alexandre Belloni , Linus Walleij , linux-gpio@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, Jean-Jacques Hiblot Content-Transfer-Encoding: 8BIT Message-Id: References: <1423419822-6258-1-git-send-email-boris.brezillon@free-electrons.com> To: Boris Brezillon X-Mailer: Apple Mail (2.2070.6) X-Ovh-Tracer-Id: 14507220300873706442 X-Ovh-Remote: 210.13.96.76 () X-Ovh-Local: 213.186.33.20 (ns0.ovh.net) X-OVH-SPAMSTATE: OK X-OVH-SPAMSCORE: -100 X-OVH-SPAMCAUSE: gggruggvucftvghtrhhoucdtuddrfeejkedrjedtucetufdoteggodetrfcurfhrohhfihhlvgemucfqggfjnecuuegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmd X-VR-SPAMSTATE: OK X-VR-SPAMSCORE: -100 X-VR-SPAMCAUSE: gggruggvucftvghtrhhoucdtuddrfeejkedrjedtucetufdoteggodetrfcurfhrohhfihhlvgemucfqggfjnecuuegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmd Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2581 Lines: 82 > On Feb 9, 2015, at 2:23 AM, Boris Brezillon wrote: > > 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 > — I’m travelling will take a look end of the week Best Regards, J. > 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, > -- > 1.9.1 > -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/