linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2] gpio/stmpe: support no-irq mode
@ 2012-01-25  9:53 Linus Walleij
  2012-01-25 10:35 ` Viresh Kumar
  0 siblings, 1 reply; 3+ messages in thread
From: Linus Walleij @ 2012-01-25  9:53 UTC (permalink / raw)
  To: Samuel Ortiz, linux-kernel; +Cc: Viresh Kumar, Chris Blair, Grant Likely

From: Chris Blair <chris.blair@stericsson.com>

Adds support for boards which have an STMPE GPIO device without the
interrupt pin connected. This means that no interrupt can be received
but the GPIO pins can still be driven and read.

Cc: Grant Likely <grant.likely@secretlab.ca>
Acked-by: Viresh Kumar <viresh.kumar@st.com>
Tested-by: Michel Jaouen <michel.jaouen@stericsson.com>
Signed-off-by: Chris Blair <chris.blair@stericsson.com>
---
This depends on the previous patch to the MFD code so should
better be merged into the MFD tree with the previous patch.
---
 drivers/gpio/gpio-stmpe.c |   40 ++++++++++++++++++++++++----------------
 1 files changed, 24 insertions(+), 16 deletions(-)

diff --git a/drivers/gpio/gpio-stmpe.c b/drivers/gpio/gpio-stmpe.c
index 87a68a8..c747929 100644
--- a/drivers/gpio/gpio-stmpe.c
+++ b/drivers/gpio/gpio-stmpe.c
@@ -307,13 +307,15 @@ static int __devinit stmpe_gpio_probe(struct platform_device *pdev)
 	struct stmpe_gpio_platform_data *pdata;
 	struct stmpe_gpio *stmpe_gpio;
 	int ret;
-	int irq;
+	int irq = 0;
 
 	pdata = stmpe->pdata->gpio;
 
-	irq = platform_get_irq(pdev, 0);
-	if (irq < 0)
-		return irq;
+	if (!stmpe->pdata->no_irq) {
+		irq = platform_get_irq(pdev, 0);
+		if (irq < 0)
+			return irq;
+	}
 
 	stmpe_gpio = kzalloc(sizeof(struct stmpe_gpio), GFP_KERNEL);
 	if (!stmpe_gpio)
@@ -336,15 +338,17 @@ static int __devinit stmpe_gpio_probe(struct platform_device *pdev)
 	if (ret)
 		goto out_free;
 
-	ret = stmpe_gpio_irq_init(stmpe_gpio);
-	if (ret)
-		goto out_disable;
+	if (!stmpe->pdata->no_irq) {
+		ret = stmpe_gpio_irq_init(stmpe_gpio);
+		if (ret)
+			goto out_disable;
 
-	ret = request_threaded_irq(irq, NULL, stmpe_gpio_irq, IRQF_ONESHOT,
-				   "stmpe-gpio", stmpe_gpio);
-	if (ret) {
-		dev_err(&pdev->dev, "unable to get irq: %d\n", ret);
-		goto out_removeirq;
+		ret = request_threaded_irq(irq, NULL, stmpe_gpio_irq,
+				IRQF_ONESHOT, "stmpe-gpio", stmpe_gpio);
+		if (ret) {
+			dev_err(&pdev->dev, "unable to get irq: %d\n", ret);
+			goto out_removeirq;
+		}
 	}
 
 	ret = gpiochip_add(&stmpe_gpio->chip);
@@ -361,9 +365,11 @@ static int __devinit stmpe_gpio_probe(struct platform_device *pdev)
 	return 0;
 
 out_freeirq:
-	free_irq(irq, stmpe_gpio);
+	if (!stmpe->pdata->no_irq)
+		free_irq(irq, stmpe_gpio);
 out_removeirq:
-	stmpe_gpio_irq_remove(stmpe_gpio);
+	if (!stmpe->pdata->no_irq)
+		stmpe_gpio_irq_remove(stmpe_gpio);
 out_disable:
 	stmpe_disable(stmpe, STMPE_BLOCK_GPIO);
 out_free:
@@ -391,8 +397,10 @@ static int __devexit stmpe_gpio_remove(struct platform_device *pdev)
 
 	stmpe_disable(stmpe, STMPE_BLOCK_GPIO);
 
-	free_irq(irq, stmpe_gpio);
-	stmpe_gpio_irq_remove(stmpe_gpio);
+	if (!stmpe->pdata->no_irq) {
+		free_irq(irq, stmpe_gpio);
+		stmpe_gpio_irq_remove(stmpe_gpio);
+	}
 	platform_set_drvdata(pdev, NULL);
 	kfree(stmpe_gpio);
 
-- 
1.7.8


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

* Re: [PATCH v2] gpio/stmpe: support no-irq mode
  2012-01-25  9:53 [PATCH v2] gpio/stmpe: support no-irq mode Linus Walleij
@ 2012-01-25 10:35 ` Viresh Kumar
  2012-01-26  6:34   ` Linus Walleij
  0 siblings, 1 reply; 3+ messages in thread
From: Viresh Kumar @ 2012-01-25 10:35 UTC (permalink / raw)
  To: Linus WALLEIJ; +Cc: Samuel Ortiz, linux-kernel, Christopher BLAIR, Grant Likely

On 1/25/2012 3:23 PM, Linus WALLEIJ wrote:
> +	if (!stmpe->pdata->no_irq) {
> +		irq = platform_get_irq(pdev, 0);
> +		if (irq < 0)
> +			return irq;
> +	}

I already acked it once, but there is another idea that i have :)
Why not allow passing no irqs in resource fields directly.

i.e. platform_get_irq() < 0 will automatically mean irqs are not supported
on platform and then we can do what we are doing in your patch. This will
remove need of another pdata field. :)

-- 
viresh

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

* Re: [PATCH v2] gpio/stmpe: support no-irq mode
  2012-01-25 10:35 ` Viresh Kumar
@ 2012-01-26  6:34   ` Linus Walleij
  0 siblings, 0 replies; 3+ messages in thread
From: Linus Walleij @ 2012-01-26  6:34 UTC (permalink / raw)
  To: Viresh Kumar, Christopher BLAIR
  Cc: Linus WALLEIJ, Samuel Ortiz, linux-kernel, Grant Likely

On Wed, Jan 25, 2012 at 11:35 AM, Viresh Kumar <viresh.kumar@st.com> wrote:
> On 1/25/2012 3:23 PM, Linus WALLEIJ wrote:
>> +     if (!stmpe->pdata->no_irq) {
>> +             irq = platform_get_irq(pdev, 0);
>> +             if (irq < 0)
>> +                     return irq;
>> +     }
>
> I already acked it once, but there is another idea that i have :)
> Why not allow passing no irqs in resource fields directly.
>
> i.e. platform_get_irq() < 0 will automatically mean irqs are not supported
> on platform and then we can do what we are doing in your patch. This will
> remove need of another pdata field. :)

Hm sounds intuitively elegant! Chris, do you want to have a go
at it?

Yours,
Linus Walleij

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

end of thread, other threads:[~2012-01-26  6:35 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-01-25  9:53 [PATCH v2] gpio/stmpe: support no-irq mode Linus Walleij
2012-01-25 10:35 ` Viresh Kumar
2012-01-26  6:34   ` 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).