All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] gpio: stmpe: forbid unused lines to be mapped as IRQs
@ 2016-09-27 23:07 Linus Walleij
  2016-09-28  7:22 ` Patrice Chotard
  2016-09-29  6:40 ` Mika Westerberg
  0 siblings, 2 replies; 3+ messages in thread
From: Linus Walleij @ 2016-09-27 23:07 UTC (permalink / raw)
  To: linux-gpio, Alexandre Courbot
  Cc: Linus Walleij, Patrice Chotard, Mika Westerberg

Exploit the new mechanism for masking off disallowed IRQs
added by Mika Westerberg to properly manage the STMPE
"norequest mask" to disallow also mapping said lines as
IRQs.

Cc: Patrice Chotard <patrice.chotard@st.com>
Cc: Mika Westerberg <mika.westerberg@linux.intel.com>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
---
 drivers/gpio/gpio-stmpe.c | 11 +++++++++++
 1 file changed, 11 insertions(+)

diff --git a/drivers/gpio/gpio-stmpe.c b/drivers/gpio/gpio-stmpe.c
index b51c5be55c3a..432b2ee173c7 100644
--- a/drivers/gpio/gpio-stmpe.c
+++ b/drivers/gpio/gpio-stmpe.c
@@ -13,6 +13,7 @@
 #include <linux/of.h>
 #include <linux/mfd/stmpe.h>
 #include <linux/seq_file.h>
+#include <linux/bitops.h>
 
 /*
  * These registers are modified under the irq bus lock and cached to avoid
@@ -449,6 +450,8 @@ static int stmpe_gpio_probe(struct platform_device *pdev)
 
 	of_property_read_u32(np, "st,norequest-mask",
 			&stmpe_gpio->norequest_mask);
+	if (stmpe_gpio->norequest_mask)
+		stmpe_gpio->chip.irq_need_valid_mask = true;
 
 	if (irq < 0)
 		dev_info(&pdev->dev,
@@ -473,6 +476,14 @@ static int stmpe_gpio_probe(struct platform_device *pdev)
 			dev_err(&pdev->dev, "unable to get irq: %d\n", ret);
 			goto out_disable;
 		}
+		if (stmpe_gpio->norequest_mask) {
+			int i;
+
+			/* Forbid unused lines to be mapped as IRQs */
+			for (i = 0; i < sizeof(u32); i++)
+				if (stmpe_gpio->norequest_mask & BIT(i))
+					clear_bit(i, stmpe_gpio->chip.irq_valid_mask);
+		}
 		ret =  gpiochip_irqchip_add(&stmpe_gpio->chip,
 					    &stmpe_gpio_irq_chip,
 					    0,
-- 
2.7.4


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

* Re: [PATCH] gpio: stmpe: forbid unused lines to be mapped as IRQs
  2016-09-27 23:07 [PATCH] gpio: stmpe: forbid unused lines to be mapped as IRQs Linus Walleij
@ 2016-09-28  7:22 ` Patrice Chotard
  2016-09-29  6:40 ` Mika Westerberg
  1 sibling, 0 replies; 3+ messages in thread
From: Patrice Chotard @ 2016-09-28  7:22 UTC (permalink / raw)
  To: Linus Walleij, linux-gpio, Alexandre Courbot; +Cc: Mika Westerberg

Hi Linus

On 09/28/2016 01:07 AM, Linus Walleij wrote:
> Exploit the new mechanism for masking off disallowed IRQs
> added by Mika Westerberg to properly manage the STMPE
> "norequest mask" to disallow also mapping said lines as
> IRQs.
> 
> Cc: Patrice Chotard <patrice.chotard@st.com>
> Cc: Mika Westerberg <mika.westerberg@linux.intel.com>
> Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
> ---
>  drivers/gpio/gpio-stmpe.c | 11 +++++++++++
>  1 file changed, 11 insertions(+)
> 
> diff --git a/drivers/gpio/gpio-stmpe.c b/drivers/gpio/gpio-stmpe.c
> index b51c5be55c3a..432b2ee173c7 100644
> --- a/drivers/gpio/gpio-stmpe.c
> +++ b/drivers/gpio/gpio-stmpe.c
> @@ -13,6 +13,7 @@
>  #include <linux/of.h>
>  #include <linux/mfd/stmpe.h>
>  #include <linux/seq_file.h>
> +#include <linux/bitops.h>
>  
>  /*
>   * These registers are modified under the irq bus lock and cached to avoid
> @@ -449,6 +450,8 @@ static int stmpe_gpio_probe(struct platform_device *pdev)
>  
>  	of_property_read_u32(np, "st,norequest-mask",
>  			&stmpe_gpio->norequest_mask);
> +	if (stmpe_gpio->norequest_mask)
> +		stmpe_gpio->chip.irq_need_valid_mask = true;
>  
>  	if (irq < 0)
>  		dev_info(&pdev->dev,
> @@ -473,6 +476,14 @@ static int stmpe_gpio_probe(struct platform_device *pdev)
>  			dev_err(&pdev->dev, "unable to get irq: %d\n", ret);
>  			goto out_disable;
>  		}
> +		if (stmpe_gpio->norequest_mask) {
> +			int i;
> +
> +			/* Forbid unused lines to be mapped as IRQs */
> +			for (i = 0; i < sizeof(u32); i++)
> +				if (stmpe_gpio->norequest_mask & BIT(i))
> +					clear_bit(i, stmpe_gpio->chip.irq_valid_mask);
> +		}
>  		ret =  gpiochip_irqchip_add(&stmpe_gpio->chip,
>  					    &stmpe_gpio_irq_chip,
>  					    0,
> 

Reviewed-by: Patrice Chotard <patrice.chotard@st.com>

Thanks

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

* Re: [PATCH] gpio: stmpe: forbid unused lines to be mapped as IRQs
  2016-09-27 23:07 [PATCH] gpio: stmpe: forbid unused lines to be mapped as IRQs Linus Walleij
  2016-09-28  7:22 ` Patrice Chotard
@ 2016-09-29  6:40 ` Mika Westerberg
  1 sibling, 0 replies; 3+ messages in thread
From: Mika Westerberg @ 2016-09-29  6:40 UTC (permalink / raw)
  To: Linus Walleij; +Cc: linux-gpio, Alexandre Courbot, Patrice Chotard

On Tue, Sep 27, 2016 at 04:07:04PM -0700, Linus Walleij wrote:
> Exploit the new mechanism for masking off disallowed IRQs
> added by Mika Westerberg to properly manage the STMPE
> "norequest mask" to disallow also mapping said lines as
> IRQs.
> 
> Cc: Patrice Chotard <patrice.chotard@st.com>
> Cc: Mika Westerberg <mika.westerberg@linux.intel.com>

Good to see it being useful outside of pinctrl-cherryview.c :-)

Reviewed-by: Mika Westerberg <mika.westerberg@linux.intel.com>

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

end of thread, other threads:[~2016-09-29  6:41 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-09-27 23:07 [PATCH] gpio: stmpe: forbid unused lines to be mapped as IRQs Linus Walleij
2016-09-28  7:22 ` Patrice Chotard
2016-09-29  6:40 ` Mika Westerberg

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.