lkml.org 
[lkml]   [2020]   [Jun]   [13]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Subject[PATCH] leds: trigger: gpio: Avoid warning on update of inverted
Date
From: Jan Kiszka <jan.kiszka@siemens.com>

If the GPIO has not been configured yet, writing to inverted will raise
a kernel warning.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
---
drivers/leds/trigger/ledtrig-gpio.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/leds/trigger/ledtrig-gpio.c b/drivers/leds/trigger/ledtrig-gpio.c
index dc64679b1a92..0120faa3dafa 100644
--- a/drivers/leds/trigger/ledtrig-gpio.c
+++ b/drivers/leds/trigger/ledtrig-gpio.c
@@ -99,7 +99,8 @@ static ssize_t gpio_trig_inverted_store(struct device *dev,
gpio_data->inverted = inverted;

/* After inverting, we need to update the LED. */
- gpio_trig_irq(0, led);
+ if (gpio_is_valid(gpio_data->gpio))
+ gpio_trig_irq(0, led);

return n;
}
--
2.26.2
\
 
 \ /
  Last update: 2020-06-13 09:15    [W:0.232 / U:0.124 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site