Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

leds: trigger: gpio: GPIO 0 is valid

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>
Signed-off-by: Jacek Anaszewski <jacek.anaszewski@gmail.com>

authored by

Andy Shevchenko and committed by
Jacek Anaszewski
4e421040 d4b02200

+7 -5
+7 -5
drivers/leds/trigger/ledtrig-gpio.c
··· 131 131 if (gpio_data->gpio == gpio) 132 132 return n; 133 133 134 - if (!gpio) { 135 - if (gpio_data->gpio != 0) 134 + if (!gpio_is_valid(gpio)) { 135 + if (gpio_is_valid(gpio_data->gpio)) 136 136 free_irq(gpio_to_irq(gpio_data->gpio), led); 137 - gpio_data->gpio = 0; 137 + gpio_data->gpio = gpio; 138 138 return n; 139 139 } 140 140 ··· 144 144 if (ret) { 145 145 dev_err(dev, "request_irq failed with error %d\n", ret); 146 146 } else { 147 - if (gpio_data->gpio != 0) 147 + if (gpio_is_valid(gpio_data->gpio)) 148 148 free_irq(gpio_to_irq(gpio_data->gpio), led); 149 149 gpio_data->gpio = gpio; 150 150 /* After changing the GPIO, we need to update the LED. */ ··· 172 172 return -ENOMEM; 173 173 174 174 gpio_data->led = led; 175 + gpio_data->gpio = -ENOENT; 176 + 175 177 led_set_trigger_data(led, gpio_data); 176 178 177 179 return 0; ··· 183 181 { 184 182 struct gpio_trig_data *gpio_data = led_get_trigger_data(led); 185 183 186 - if (gpio_data->gpio != 0) 184 + if (gpio_is_valid(gpio_data->gpio)) 187 185 free_irq(gpio_to_irq(gpio_data->gpio), led); 188 186 kfree(gpio_data); 189 187 }