LKML Archive on lore.kernel.org
help / color / mirror / Atom feed
* [PATCH] pinctrl: at91: move lock/unlock_as_irq calls into request/release resources methods
@ 2015-02-08 18:23 Boris Brezillon
  2015-02-09 14:50 ` Jean-Christophe PLAGNIOL-VILLARD
                   ` (4 more replies)
  0 siblings, 5 replies; 11+ messages in thread
From: Boris Brezillon @ 2015-02-08 18:23 UTC (permalink / raw)
  To: Nicolas Ferre, Jean-Christophe Plagniol-Villard,
	Alexandre Belloni, Linus Walleij, linux-gpio
  Cc: linux-arm-kernel, linux-kernel, Jean-Jacques Hiblot, Boris Brezillon

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>
---
 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


^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH] pinctrl: at91: move lock/unlock_as_irq calls into request/release resources methods
  2015-02-08 18:23 [PATCH] pinctrl: at91: move lock/unlock_as_irq calls into request/release resources methods Boris Brezillon
@ 2015-02-09 14:50 ` Jean-Christophe PLAGNIOL-VILLARD
  2015-02-20  7:50   ` Jean-Christophe PLAGNIOL-VILLARD
  2015-02-18 10:41 ` Ludovic Desroches
                   ` (3 subsequent siblings)
  4 siblings, 1 reply; 11+ messages in thread
From: Jean-Christophe PLAGNIOL-VILLARD @ 2015-02-09 14:50 UTC (permalink / raw)
  To: Boris Brezillon
  Cc: Jean-Christophe PLAGNIOL-VILLARD, Nicolas FERRE,
	Alexandre Belloni, Linus Walleij, linux-gpio, linux-arm-kernel,
	linux-kernel, Jean-Jacques Hiblot


> On Feb 9, 2015, at 2:23 AM, Boris Brezillon <boris.brezillon@free-electrons.com> 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 <boris.brezillon@free-electrons.com>
> —

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
> 


^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH] pinctrl: at91: move lock/unlock_as_irq calls into request/release resources methods
  2015-02-08 18:23 [PATCH] pinctrl: at91: move lock/unlock_as_irq calls into request/release resources methods Boris Brezillon
  2015-02-09 14:50 ` Jean-Christophe PLAGNIOL-VILLARD
@ 2015-02-18 10:41 ` Ludovic Desroches
  2015-02-26 13:32 ` Nicolas Ferre
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 11+ messages in thread
From: Ludovic Desroches @ 2015-02-18 10:41 UTC (permalink / raw)
  To: Boris Brezillon
  Cc: Nicolas Ferre, Jean-Christophe Plagniol-Villard,
	Alexandre Belloni, Linus Walleij, linux-gpio,
	Jean-Jacques Hiblot, linux-kernel, linux-arm-kernel

On Sun, Feb 08, 2015 at 07:23:42PM +0100, 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 <boris.brezillon@free-electrons.com>

It sounds good for me, you can add my

Acked-by: Ludovic Desroches <ludovic.desroches@atmel.com>

> ---
>  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
> 
> 
> _______________________________________________
> linux-arm-kernel mailing list
> linux-arm-kernel@lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH] pinctrl: at91: move lock/unlock_as_irq calls into request/release resources methods
  2015-02-09 14:50 ` Jean-Christophe PLAGNIOL-VILLARD
@ 2015-02-20  7:50   ` Jean-Christophe PLAGNIOL-VILLARD
  2015-02-26 13:12     ` Boris Brezillon
  0 siblings, 1 reply; 11+ messages in thread
From: Jean-Christophe PLAGNIOL-VILLARD @ 2015-02-20  7:50 UTC (permalink / raw)
  To: Jean-Christophe PLAGNIOL-VILLARD
  Cc: Boris Brezillon, Nicolas FERRE, Alexandre Belloni, Linus Walleij,
	linux-gpio, linux-arm-kernel, linux-kernel, Jean-Jacques Hiblot


> On Feb 9, 2015, at 10:50 PM, Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com> wrote:
> 
> 
>> On Feb 9, 2015, at 2:23 AM, Boris Brezillon <boris.brezillon@free-electrons.com> 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 <boris.brezillon@free-electrons.com>
>> —
> 
> I’m travelling will take a look end of the week

just get back from travelling will take a look after Chinese new year
as all my hw are at the office

Best Regards,
J.
> 
> 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
>> 
> 


^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH] pinctrl: at91: move lock/unlock_as_irq calls into request/release resources methods
  2015-02-20  7:50   ` Jean-Christophe PLAGNIOL-VILLARD
@ 2015-02-26 13:12     ` Boris Brezillon
  0 siblings, 0 replies; 11+ messages in thread
From: Boris Brezillon @ 2015-02-26 13:12 UTC (permalink / raw)
  To: Jean-Christophe PLAGNIOL-VILLARD
  Cc: Nicolas FERRE, Alexandre Belloni, Linus Walleij, linux-gpio,
	linux-arm-kernel, linux-kernel, Jean-Jacques Hiblot

On Fri, 20 Feb 2015 15:50:36 +0800
Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com> wrote:

> 
> > On Feb 9, 2015, at 10:50 PM, Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com> wrote:
> > 
> > 
> >> On Feb 9, 2015, at 2:23 AM, Boris Brezillon <boris.brezillon@free-electrons.com> 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 <boris.brezillon@free-electrons.com>
> >> —
> > 
> > I’m travelling will take a look end of the week
> 
> just get back from travelling will take a look after Chinese new year
> as all my hw are at the office

Ping



-- 
Boris Brezillon, Free Electrons
Embedded Linux and Kernel engineering
http://free-electrons.com

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH] pinctrl: at91: move lock/unlock_as_irq calls into request/release resources methods
  2015-02-08 18:23 [PATCH] pinctrl: at91: move lock/unlock_as_irq calls into request/release resources methods Boris Brezillon
  2015-02-09 14:50 ` Jean-Christophe PLAGNIOL-VILLARD
  2015-02-18 10:41 ` Ludovic Desroches
@ 2015-02-26 13:32 ` Nicolas Ferre
  2015-02-26 13:59   ` Jean-Christophe PLAGNIOL-VILLARD
  2015-03-04 21:30 ` Jean-Christophe PLAGNIOL-VILLARD
  2015-03-09 16:14 ` Linus Walleij
  4 siblings, 1 reply; 11+ messages in thread
From: Nicolas Ferre @ 2015-02-26 13:32 UTC (permalink / raw)
  To: Boris Brezillon, Linus Walleij
  Cc: Jean-Christophe Plagniol-Villard, Alexandre Belloni, linux-gpio,
	linux-arm-kernel, linux-kernel, Jean-Jacques Hiblot

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 <boris.brezillon@free-electrons.com>

If it can speed up things:
Acked-by: Nicolas Ferre <nicolas.ferre@atmel.com>

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

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH] pinctrl: at91: move lock/unlock_as_irq calls into request/release resources methods
  2015-02-26 13:32 ` Nicolas Ferre
@ 2015-02-26 13:59   ` Jean-Christophe PLAGNIOL-VILLARD
  0 siblings, 0 replies; 11+ messages in thread
From: Jean-Christophe PLAGNIOL-VILLARD @ 2015-02-26 13:59 UTC (permalink / raw)
  To: Nicolas FERRE
  Cc: Jean-Christophe PLAGNIOL-VILLARD, Boris Brezillon, Linus Walleij,
	Alexandre Belloni, linux-gpio, linux-arm-kernel, linux-kernel,
	Jean-Jacques Hiblot


> On Feb 26, 2015, at 9:32 PM, Nicolas Ferre <nicolas.ferre@atmel.com> wrote:
> 
> 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 <boris.brezillon@free-electrons.com>
> 
> If it can speed up things:
> Acked-by: Nicolas Ferre <nicolas.ferre@atmel.com>
> 
> Linus,
> can we schedule this fix during the 4.0-rc phase?

As I said I’ll test after CNY which finish this week for us

as we only re-open the office Monday

Best Regards,
J.
> 
> 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


^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH] pinctrl: at91: move lock/unlock_as_irq calls into request/release resources methods
  2015-02-08 18:23 [PATCH] pinctrl: at91: move lock/unlock_as_irq calls into request/release resources methods Boris Brezillon
                   ` (2 preceding siblings ...)
  2015-02-26 13:32 ` Nicolas Ferre
@ 2015-03-04 21:30 ` Jean-Christophe PLAGNIOL-VILLARD
  2015-03-09 16:14 ` Linus Walleij
  4 siblings, 0 replies; 11+ messages in thread
From: Jean-Christophe PLAGNIOL-VILLARD @ 2015-03-04 21:30 UTC (permalink / raw)
  To: Boris Brezillon
  Cc: Nicolas Ferre, Alexandre Belloni, Linus Walleij, linux-gpio,
	linux-arm-kernel, linux-kernel, Jean-Jacques Hiblot

On 19:23 Sun 08 Feb     , 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 <boris.brezillon@free-electrons.com>
Linus

Acked-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>

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
> 

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH] pinctrl: at91: move lock/unlock_as_irq calls into request/release resources methods
  2015-02-08 18:23 [PATCH] pinctrl: at91: move lock/unlock_as_irq calls into request/release resources methods Boris Brezillon
                   ` (3 preceding siblings ...)
  2015-03-04 21:30 ` Jean-Christophe PLAGNIOL-VILLARD
@ 2015-03-09 16:14 ` Linus Walleij
  2015-03-10  8:34   ` Nicolas Ferre
  4 siblings, 1 reply; 11+ messages in thread
From: Linus Walleij @ 2015-03-09 16:14 UTC (permalink / raw)
  To: Boris Brezillon
  Cc: Nicolas Ferre, Jean-Christophe Plagniol-Villard,
	Alexandre Belloni, linux-gpio, linux-arm-kernel, linux-kernel,
	Jean-Jacques Hiblot

On Sun, Feb 8, 2015 at 7:23 PM, Boris Brezillon
<boris.brezillon@free-electrons.com> 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 <boris.brezillon@free-electrons.com>

Patch applied with all the ACKs.

Happy new year J-C!

Yours,
Linus Walleij

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH] pinctrl: at91: move lock/unlock_as_irq calls into request/release resources methods
  2015-03-09 16:14 ` Linus Walleij
@ 2015-03-10  8:34   ` Nicolas Ferre
  2015-03-18  1:06     ` Linus Walleij
  0 siblings, 1 reply; 11+ messages in thread
From: Nicolas Ferre @ 2015-03-10  8:34 UTC (permalink / raw)
  To: Linus Walleij, Jean-Christophe Plagniol-Villard
  Cc: Boris Brezillon, Alexandre Belloni, linux-gpio, linux-arm-kernel,
	linux-kernel, Jean-Jacques Hiblot

Le 09/03/2015 17:14, Linus Walleij a écrit :
> On Sun, Feb 8, 2015 at 7:23 PM, Boris Brezillon
> <boris.brezillon@free-electrons.com> 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 <boris.brezillon@free-electrons.com>
> 
> Patch applied with all the ACKs.

Hi Linus,

As suggested earlier, do you think it can be scheduled for the 4.0-rc
phase as a "fix"?

Bye,



> Happy new year J-C!
> 
> Yours,
> Linus Walleij
> 
> 


-- 
Nicolas Ferre

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH] pinctrl: at91: move lock/unlock_as_irq calls into request/release resources methods
  2015-03-10  8:34   ` Nicolas Ferre
@ 2015-03-18  1:06     ` Linus Walleij
  0 siblings, 0 replies; 11+ messages in thread
From: Linus Walleij @ 2015-03-18  1:06 UTC (permalink / raw)
  To: Nicolas Ferre
  Cc: Jean-Christophe Plagniol-Villard, Boris Brezillon,
	Alexandre Belloni, linux-gpio, linux-arm-kernel, linux-kernel,
	Jean-Jacques Hiblot

On Tue, Mar 10, 2015 at 9:34 AM, Nicolas Ferre <nicolas.ferre@atmel.com> wrote:
> Le 09/03/2015 17:14, Linus Walleij a écrit :
>> On Sun, Feb 8, 2015 at 7:23 PM, Boris Brezillon
>> <boris.brezillon@free-electrons.com> 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 <boris.brezillon@free-electrons.com>
>>
>> Patch applied with all the ACKs.
>
> Hi Linus,
>
> As suggested earlier, do you think it can be scheduled for the 4.0-rc
> phase as a "fix"?

OK argh had to rebase my tree to get the patch out of the devel
branch but what can I do.

Yours,
Linus Walleij

^ permalink raw reply	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2015-03-18  1:06 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-02-08 18:23 [PATCH] pinctrl: at91: move lock/unlock_as_irq calls into request/release resources methods Boris Brezillon
2015-02-09 14:50 ` Jean-Christophe PLAGNIOL-VILLARD
2015-02-20  7:50   ` Jean-Christophe PLAGNIOL-VILLARD
2015-02-26 13:12     ` Boris Brezillon
2015-02-18 10:41 ` Ludovic Desroches
2015-02-26 13:32 ` Nicolas Ferre
2015-02-26 13:59   ` Jean-Christophe PLAGNIOL-VILLARD
2015-03-04 21:30 ` Jean-Christophe PLAGNIOL-VILLARD
2015-03-09 16:14 ` Linus Walleij
2015-03-10  8:34   ` Nicolas Ferre
2015-03-18  1:06     ` Linus Walleij

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).