linux-leds.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Lothar Waßmann" <LW@KARO-electronics.de>
To: linux-leds@vger.kernel.org
Cc: linux-kernel@vger.kernel.org,
	"Richard Purdie" <rpurdie@rpsys.net>,
	"Bryan Wu" <cooloney@gmail.com>,
	"Lothar Waßmann" <LW@KARO-electronics.de>
Subject: [PATCH 2/2] leds: trigger: gpio: make ledtrig-gpio useable with GPIO drivers requiring threaded irqs
Date: Tue,  9 Sep 2014 09:40:33 +0200	[thread overview]
Message-ID: <1410248433-24005-3-git-send-email-LW@KARO-electronics.de> (raw)
In-Reply-To: <1410248433-24005-1-git-send-email-LW@KARO-electronics.de>

When trying to use the LED GPIO trigger with e.g. the PCA953x GPIO
driver, request_irq() fails with -EINVAL, because the GPIO driver
requires a nested interrupt handler.

Use request_any_context_irq() to be able to use any GPIO driver as LED
trigger.

Signed-off-by: Lothar Waßmann <LW@KARO-electronics.de>
---
 drivers/leds/trigger/ledtrig-gpio.c |    6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/leds/trigger/ledtrig-gpio.c b/drivers/leds/trigger/ledtrig-gpio.c
index c86c418..b4168a7 100644
--- a/drivers/leds/trigger/ledtrig-gpio.c
+++ b/drivers/leds/trigger/ledtrig-gpio.c
@@ -161,10 +161,10 @@ static ssize_t gpio_trig_gpio_store(struct device *dev,
 		return n;
 	}
 
-	ret = request_irq(gpio_to_irq(gpio), gpio_trig_irq,
+	ret = request_any_context_irq(gpio_to_irq(gpio), gpio_trig_irq,
 			IRQF_SHARED | IRQF_TRIGGER_RISING
 			| IRQF_TRIGGER_FALLING, "ledtrig-gpio", led);
-	if (ret) {
+	if (ret < 0) {
 		dev_err(dev, "request_irq failed with error %d\n", ret);
 	} else {
 		if (gpio_data->gpio != 0)
@@ -172,7 +172,7 @@ static ssize_t gpio_trig_gpio_store(struct device *dev,
 		gpio_data->gpio = gpio;
 	}
 
-	return ret ? ret : n;
+	return ret < 0 ? ret : n;
 }
 static DEVICE_ATTR(gpio, 0644, gpio_trig_gpio_show, gpio_trig_gpio_store);
 
-- 
1.7.10.4

  parent reply	other threads:[~2014-09-09  7:40 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-09-09  7:40 make ledtrig-gpio useable with GPIO drivers requiring threaded irqs Lothar Waßmann
2014-09-09  7:40 ` [PATCH 1/2] leds: trigger: gpio: fix warning in gpio trigger for gpios whose accessor function may sleep Lothar Waßmann
2014-09-12  0:13   ` Bryan Wu
2014-09-09  7:40 ` Lothar Waßmann [this message]
2014-09-12  0:32   ` [PATCH 2/2] leds: trigger: gpio: make ledtrig-gpio useable with GPIO drivers requiring threaded irqs Bryan Wu
2014-09-12  7:09     ` Lothar Waßmann
2014-09-12 18:57       ` Bryan Wu

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1410248433-24005-3-git-send-email-LW@KARO-electronics.de \
    --to=lw@karo-electronics.de \
    --cc=cooloney@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-leds@vger.kernel.org \
    --cc=rpurdie@rpsys.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).