diff options
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/leds/ledtrig-gpio.c | 15 |
1 files changed, 8 insertions, 7 deletions
diff --git a/drivers/leds/ledtrig-gpio.c b/drivers/leds/ledtrig-gpio.c index 991d93be0f44..ecc4bf3f37a9 100644 --- a/drivers/leds/ledtrig-gpio.c +++ b/drivers/leds/ledtrig-gpio.c | |||
@@ -99,7 +99,7 @@ static ssize_t gpio_trig_inverted_show(struct device *dev, | |||
99 | struct led_classdev *led = dev_get_drvdata(dev); | 99 | struct led_classdev *led = dev_get_drvdata(dev); |
100 | struct gpio_trig_data *gpio_data = led->trigger_data; | 100 | struct gpio_trig_data *gpio_data = led->trigger_data; |
101 | 101 | ||
102 | return sprintf(buf, "%s\n", gpio_data->inverted ? "yes" : "no"); | 102 | return sprintf(buf, "%u\n", gpio_data->inverted); |
103 | } | 103 | } |
104 | 104 | ||
105 | static ssize_t gpio_trig_inverted_store(struct device *dev, | 105 | 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 | { | 107 | { |
108 | struct led_classdev *led = dev_get_drvdata(dev); | 108 | struct led_classdev *led = dev_get_drvdata(dev); |
109 | struct gpio_trig_data *gpio_data = led->trigger_data; | 109 | struct gpio_trig_data *gpio_data = led->trigger_data; |
110 | unsigned inverted; | 110 | unsigned long inverted; |
111 | int ret; | 111 | int ret; |
112 | 112 | ||
113 | ret = sscanf(buf, "%u", &inverted); | 113 | ret = strict_strtoul(buf, 10, &inverted); |
114 | if (ret < 1) { | 114 | if (ret < 0) |
115 | dev_err(dev, "invalid value\n"); | 115 | return ret; |
116 | |||
117 | if (inverted > 1) | ||
116 | return -EINVAL; | 118 | return -EINVAL; |
117 | } | ||
118 | 119 | ||
119 | gpio_data->inverted = !!inverted; | 120 | gpio_data->inverted = inverted; |
120 | 121 | ||
121 | /* After inverting, we need to update the LED. */ | 122 | /* After inverting, we need to update the LED. */ |
122 | schedule_work(&gpio_data->work); | 123 | schedule_work(&gpio_data->work); |