Commit cc587ece authored by Janusz Krzysztofik's avatar Janusz Krzysztofik Committed by Linus Torvalds

drivers/leds/ledtrig-gpio.c: make output match input, tighten input checking

Replicate changes made to drivers/leds/ledtrig-backlight.c.

Cc: Paul Mundt <lethal@linux-sh.org>
Cc: Richard Purdie <richard.purdie@linuxfoundation.org>
Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
parent c1fc8675
...@@ -99,7 +99,7 @@ static ssize_t gpio_trig_inverted_show(struct device *dev, ...@@ -99,7 +99,7 @@ static ssize_t gpio_trig_inverted_show(struct device *dev,
struct led_classdev *led = dev_get_drvdata(dev); struct led_classdev *led = dev_get_drvdata(dev);
struct gpio_trig_data *gpio_data = led->trigger_data; struct gpio_trig_data *gpio_data = led->trigger_data;
return sprintf(buf, "%s\n", gpio_data->inverted ? "yes" : "no"); return sprintf(buf, "%u\n", gpio_data->inverted);
} }
static ssize_t gpio_trig_inverted_store(struct device *dev, static ssize_t gpio_trig_inverted_store(struct device *dev,
...@@ -107,16 +107,17 @@ static ssize_t gpio_trig_inverted_store(struct device *dev, ...@@ -107,16 +107,17 @@ static ssize_t gpio_trig_inverted_store(struct device *dev,
{ {
struct led_classdev *led = dev_get_drvdata(dev); struct led_classdev *led = dev_get_drvdata(dev);
struct gpio_trig_data *gpio_data = led->trigger_data; struct gpio_trig_data *gpio_data = led->trigger_data;
unsigned inverted; unsigned long inverted;
int ret; int ret;
ret = sscanf(buf, "%u", &inverted); ret = strict_strtoul(buf, 10, &inverted);
if (ret < 1) { if (ret < 0)
dev_err(dev, "invalid value\n"); return ret;
if (inverted > 1)
return -EINVAL; return -EINVAL;
}
gpio_data->inverted = !!inverted; gpio_data->inverted = inverted;
/* After inverting, we need to update the LED. */ /* After inverting, we need to update the LED. */
schedule_work(&gpio_data->work); schedule_work(&gpio_data->work);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment