leds: trigger: gpio: Avoid warning on update of inverted

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>
Signed-off-by: Pavel Machek <pavel@ucw.cz>
This commit is contained in:
Jan Kiszka 2020-06-13 09:15:06 +02:00 committed by Pavel Machek
parent 14d3e74f59
commit 5ad79c20b6
1 changed files with 2 additions and 1 deletions

View File

@ -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;
}