linux-leds.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v1 1/2] leds: trigger: gpio: GPIO 0 is valid
@ 2019-08-21 17:17 Andy Shevchenko
  2019-08-21 17:17 ` [PATCH v1 2/2] leds: trigger: gpio: Convert to use kstrtox() Andy Shevchenko
  2019-08-24 16:47 ` [PATCH v1 1/2] leds: trigger: gpio: GPIO 0 is valid Jacek Anaszewski
  0 siblings, 2 replies; 7+ messages in thread
From: Andy Shevchenko @ 2019-08-21 17:17 UTC (permalink / raw)
  To: Jacek Anaszewski, Pavel Machek, Dan Murphy, linux-leds; +Cc: Andy Shevchenko

Allow all valid GPIOs to be used in the driver.

Fixes: 17354bfe8527 ("leds: Add gpio-led trigger")
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
 drivers/leds/trigger/ledtrig-gpio.c | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/drivers/leds/trigger/ledtrig-gpio.c b/drivers/leds/trigger/ledtrig-gpio.c
index 33cc99a1a16a..31f456dd4417 100644
--- a/drivers/leds/trigger/ledtrig-gpio.c
+++ b/drivers/leds/trigger/ledtrig-gpio.c
@@ -131,10 +131,10 @@ static ssize_t gpio_trig_gpio_store(struct device *dev,
 	if (gpio_data->gpio == gpio)
 		return n;
 
-	if (!gpio) {
-		if (gpio_data->gpio != 0)
+	if (!gpio_is_valid(gpio)) {
+		if (gpio_is_valid(gpio_data->gpio))
 			free_irq(gpio_to_irq(gpio_data->gpio), led);
-		gpio_data->gpio = 0;
+		gpio_data->gpio = gpio;
 		return n;
 	}
 
@@ -144,7 +144,7 @@ static ssize_t gpio_trig_gpio_store(struct device *dev,
 	if (ret) {
 		dev_err(dev, "request_irq failed with error %d\n", ret);
 	} else {
-		if (gpio_data->gpio != 0)
+		if (gpio_is_valid(gpio_data->gpio))
 			free_irq(gpio_to_irq(gpio_data->gpio), led);
 		gpio_data->gpio = gpio;
 		/* After changing the GPIO, we need to update the LED. */
@@ -181,7 +181,7 @@ static void gpio_trig_deactivate(struct led_classdev *led)
 {
 	struct gpio_trig_data *gpio_data = led_get_trigger_data(led);
 
-	if (gpio_data->gpio != 0)
+	if (gpio_is_valid(gpio_data->gpio))
 		free_irq(gpio_to_irq(gpio_data->gpio), led);
 	kfree(gpio_data);
 }
-- 
2.23.0.rc1


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

end of thread, other threads:[~2019-08-30 15:01 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-08-21 17:17 [PATCH v1 1/2] leds: trigger: gpio: GPIO 0 is valid Andy Shevchenko
2019-08-21 17:17 ` [PATCH v1 2/2] leds: trigger: gpio: Convert to use kstrtox() Andy Shevchenko
2019-08-24 16:51   ` Jacek Anaszewski
2019-08-24 16:47 ` [PATCH v1 1/2] leds: trigger: gpio: GPIO 0 is valid Jacek Anaszewski
2019-08-26  9:57   ` Andy Shevchenko
2019-08-26 18:36     ` Jacek Anaszewski
2019-08-30 15:01       ` Andy Shevchenko

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