diff options
author | Linus Torvalds <torvalds@linux-foundation.org> | 2014-10-21 11:18:38 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2014-10-21 11:18:38 -0400 |
commit | 045aaedab67bc3f2f01fe46917e0e17a6b5a7d5d (patch) | |
tree | 48c18f788c81d84c895318c82cb35e8d19d23efa /drivers | |
parent | 5b9c8972527fdb52d5cd7dadc9853c57430e0ff5 (diff) | |
parent | a4c84e6aafda0ddd8cb004c464cd11e47e211049 (diff) |
Merge branch 'for-next' of git://git.kernel.org/pub/scm/linux/kernel/git/cooloney/linux-leds
Pull LED update from Bryan Wu:
"Basically we have some bug fixing and clean up and one big thing is we
start to merge patch to add support LED Flash class"
* 'for-next' of git://git.kernel.org/pub/scm/linux/kernel/git/cooloney/linux-leds:
leds: gpio: cleanup the leds-gpio driver
led: gpio: Fix possible ZERO_SIZE_PTR pointer dereferencing error.
led: gpio: Sort include headers alphabetically
leds: Improve and export led_update_brightness
leds: trigger: gpio: fix warning in gpio trigger for gpios whose accessor function may sleep
leds: lp3944: fix sparse warning
leds: avoid using DEVICE_ATTR macro for max_brightness attribute
leds: make brightness type consistent across whole subsystem
leds: Reorder include directives
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/leds/led-class.c | 23 | ||||
-rw-r--r-- | drivers/leds/led-core.c | 19 | ||||
-rw-r--r-- | drivers/leds/leds-gpio-register.c | 5 | ||||
-rw-r--r-- | drivers/leds/leds-gpio.c | 14 | ||||
-rw-r--r-- | drivers/leds/leds-lp3944.c | 3 | ||||
-rw-r--r-- | drivers/leds/trigger/ledtrig-gpio.c | 2 |
6 files changed, 40 insertions, 26 deletions
diff --git a/drivers/leds/led-class.c b/drivers/leds/led-class.c index aa29198fca3e..7440c58b8e6f 100644 --- a/drivers/leds/led-class.c +++ b/drivers/leds/led-class.c | |||
@@ -9,26 +9,21 @@ | |||
9 | * published by the Free Software Foundation. | 9 | * published by the Free Software Foundation. |
10 | */ | 10 | */ |
11 | 11 | ||
12 | #include <linux/module.h> | 12 | #include <linux/ctype.h> |
13 | #include <linux/kernel.h> | 13 | #include <linux/device.h> |
14 | #include <linux/err.h> | ||
14 | #include <linux/init.h> | 15 | #include <linux/init.h> |
16 | #include <linux/kernel.h> | ||
17 | #include <linux/leds.h> | ||
15 | #include <linux/list.h> | 18 | #include <linux/list.h> |
19 | #include <linux/module.h> | ||
20 | #include <linux/slab.h> | ||
16 | #include <linux/spinlock.h> | 21 | #include <linux/spinlock.h> |
17 | #include <linux/device.h> | ||
18 | #include <linux/timer.h> | 22 | #include <linux/timer.h> |
19 | #include <linux/err.h> | ||
20 | #include <linux/ctype.h> | ||
21 | #include <linux/leds.h> | ||
22 | #include "leds.h" | 23 | #include "leds.h" |
23 | 24 | ||
24 | static struct class *leds_class; | 25 | static struct class *leds_class; |
25 | 26 | ||
26 | static void led_update_brightness(struct led_classdev *led_cdev) | ||
27 | { | ||
28 | if (led_cdev->brightness_get) | ||
29 | led_cdev->brightness = led_cdev->brightness_get(led_cdev); | ||
30 | } | ||
31 | |||
32 | static ssize_t brightness_show(struct device *dev, | 27 | static ssize_t brightness_show(struct device *dev, |
33 | struct device_attribute *attr, char *buf) | 28 | struct device_attribute *attr, char *buf) |
34 | { | 29 | { |
@@ -59,14 +54,14 @@ static ssize_t brightness_store(struct device *dev, | |||
59 | } | 54 | } |
60 | static DEVICE_ATTR_RW(brightness); | 55 | static DEVICE_ATTR_RW(brightness); |
61 | 56 | ||
62 | static ssize_t led_max_brightness_show(struct device *dev, | 57 | static ssize_t max_brightness_show(struct device *dev, |
63 | struct device_attribute *attr, char *buf) | 58 | struct device_attribute *attr, char *buf) |
64 | { | 59 | { |
65 | struct led_classdev *led_cdev = dev_get_drvdata(dev); | 60 | struct led_classdev *led_cdev = dev_get_drvdata(dev); |
66 | 61 | ||
67 | return sprintf(buf, "%u\n", led_cdev->max_brightness); | 62 | return sprintf(buf, "%u\n", led_cdev->max_brightness); |
68 | } | 63 | } |
69 | static DEVICE_ATTR(max_brightness, 0444, led_max_brightness_show, NULL); | 64 | static DEVICE_ATTR_RO(max_brightness); |
70 | 65 | ||
71 | #ifdef CONFIG_LEDS_TRIGGERS | 66 | #ifdef CONFIG_LEDS_TRIGGERS |
72 | static DEVICE_ATTR(trigger, 0644, led_trigger_show, led_trigger_store); | 67 | static DEVICE_ATTR(trigger, 0644, led_trigger_show, led_trigger_store); |
diff --git a/drivers/leds/led-core.c b/drivers/leds/led-core.c index 71b40d3bf776..aaa8eba9099f 100644 --- a/drivers/leds/led-core.c +++ b/drivers/leds/led-core.c | |||
@@ -12,10 +12,11 @@ | |||
12 | */ | 12 | */ |
13 | 13 | ||
14 | #include <linux/kernel.h> | 14 | #include <linux/kernel.h> |
15 | #include <linux/leds.h> | ||
15 | #include <linux/list.h> | 16 | #include <linux/list.h> |
16 | #include <linux/module.h> | 17 | #include <linux/module.h> |
18 | #include <linux/mutex.h> | ||
17 | #include <linux/rwsem.h> | 19 | #include <linux/rwsem.h> |
18 | #include <linux/leds.h> | ||
19 | #include "leds.h" | 20 | #include "leds.h" |
20 | 21 | ||
21 | DECLARE_RWSEM(leds_list_lock); | 22 | DECLARE_RWSEM(leds_list_lock); |
@@ -126,3 +127,19 @@ void led_set_brightness(struct led_classdev *led_cdev, | |||
126 | __led_set_brightness(led_cdev, brightness); | 127 | __led_set_brightness(led_cdev, brightness); |
127 | } | 128 | } |
128 | EXPORT_SYMBOL(led_set_brightness); | 129 | EXPORT_SYMBOL(led_set_brightness); |
130 | |||
131 | int led_update_brightness(struct led_classdev *led_cdev) | ||
132 | { | ||
133 | int ret = 0; | ||
134 | |||
135 | if (led_cdev->brightness_get) { | ||
136 | ret = led_cdev->brightness_get(led_cdev); | ||
137 | if (ret >= 0) { | ||
138 | led_cdev->brightness = ret; | ||
139 | return 0; | ||
140 | } | ||
141 | } | ||
142 | |||
143 | return ret; | ||
144 | } | ||
145 | EXPORT_SYMBOL(led_update_brightness); | ||
diff --git a/drivers/leds/leds-gpio-register.c b/drivers/leds/leds-gpio-register.c index 1c4ed5510f35..75717ba68ae0 100644 --- a/drivers/leds/leds-gpio-register.c +++ b/drivers/leds/leds-gpio-register.c | |||
@@ -7,9 +7,9 @@ | |||
7 | * Free Software Foundation. | 7 | * Free Software Foundation. |
8 | */ | 8 | */ |
9 | #include <linux/err.h> | 9 | #include <linux/err.h> |
10 | #include <linux/leds.h> | ||
10 | #include <linux/platform_device.h> | 11 | #include <linux/platform_device.h> |
11 | #include <linux/slab.h> | 12 | #include <linux/slab.h> |
12 | #include <linux/leds.h> | ||
13 | 13 | ||
14 | /** | 14 | /** |
15 | * gpio_led_register_device - register a gpio-led device | 15 | * gpio_led_register_device - register a gpio-led device |
@@ -28,6 +28,9 @@ struct platform_device *__init gpio_led_register_device( | |||
28 | struct platform_device *ret; | 28 | struct platform_device *ret; |
29 | struct gpio_led_platform_data _pdata = *pdata; | 29 | struct gpio_led_platform_data _pdata = *pdata; |
30 | 30 | ||
31 | if (!pdata->num_leds) | ||
32 | return ERR_PTR(-EINVAL); | ||
33 | |||
31 | _pdata.leds = kmemdup(pdata->leds, | 34 | _pdata.leds = kmemdup(pdata->leds, |
32 | pdata->num_leds * sizeof(*pdata->leds), GFP_KERNEL); | 35 | pdata->num_leds * sizeof(*pdata->leds), GFP_KERNEL); |
33 | if (!_pdata.leds) | 36 | if (!_pdata.leds) |
diff --git a/drivers/leds/leds-gpio.c b/drivers/leds/leds-gpio.c index 57ff20fecf57..b4518c8751c8 100644 --- a/drivers/leds/leds-gpio.c +++ b/drivers/leds/leds-gpio.c | |||
@@ -10,17 +10,17 @@ | |||
10 | * published by the Free Software Foundation. | 10 | * published by the Free Software Foundation. |
11 | * | 11 | * |
12 | */ | 12 | */ |
13 | #include <linux/kernel.h> | 13 | #include <linux/err.h> |
14 | #include <linux/platform_device.h> | ||
15 | #include <linux/gpio.h> | 14 | #include <linux/gpio.h> |
15 | #include <linux/kernel.h> | ||
16 | #include <linux/leds.h> | 16 | #include <linux/leds.h> |
17 | #include <linux/module.h> | ||
17 | #include <linux/of.h> | 18 | #include <linux/of.h> |
18 | #include <linux/of_platform.h> | ||
19 | #include <linux/of_gpio.h> | 19 | #include <linux/of_gpio.h> |
20 | #include <linux/of_platform.h> | ||
21 | #include <linux/platform_device.h> | ||
20 | #include <linux/slab.h> | 22 | #include <linux/slab.h> |
21 | #include <linux/workqueue.h> | 23 | #include <linux/workqueue.h> |
22 | #include <linux/module.h> | ||
23 | #include <linux/err.h> | ||
24 | 24 | ||
25 | struct gpio_led_data { | 25 | struct gpio_led_data { |
26 | struct led_classdev cdev; | 26 | struct led_classdev cdev; |
@@ -36,7 +36,7 @@ struct gpio_led_data { | |||
36 | 36 | ||
37 | static void gpio_led_work(struct work_struct *work) | 37 | static void gpio_led_work(struct work_struct *work) |
38 | { | 38 | { |
39 | struct gpio_led_data *led_dat = | 39 | struct gpio_led_data *led_dat = |
40 | container_of(work, struct gpio_led_data, work); | 40 | container_of(work, struct gpio_led_data, work); |
41 | 41 | ||
42 | if (led_dat->blinking) { | 42 | if (led_dat->blinking) { |
@@ -235,14 +235,12 @@ static struct gpio_leds_priv *gpio_leds_create_of(struct platform_device *pdev) | |||
235 | } | 235 | } |
236 | #endif /* CONFIG_OF_GPIO */ | 236 | #endif /* CONFIG_OF_GPIO */ |
237 | 237 | ||
238 | |||
239 | static int gpio_led_probe(struct platform_device *pdev) | 238 | static int gpio_led_probe(struct platform_device *pdev) |
240 | { | 239 | { |
241 | struct gpio_led_platform_data *pdata = dev_get_platdata(&pdev->dev); | 240 | struct gpio_led_platform_data *pdata = dev_get_platdata(&pdev->dev); |
242 | struct gpio_leds_priv *priv; | 241 | struct gpio_leds_priv *priv; |
243 | int i, ret = 0; | 242 | int i, ret = 0; |
244 | 243 | ||
245 | |||
246 | if (pdata && pdata->num_leds) { | 244 | if (pdata && pdata->num_leds) { |
247 | priv = devm_kzalloc(&pdev->dev, | 245 | priv = devm_kzalloc(&pdev->dev, |
248 | sizeof_gpio_leds_priv(pdata->num_leds), | 246 | sizeof_gpio_leds_priv(pdata->num_leds), |
diff --git a/drivers/leds/leds-lp3944.c b/drivers/leds/leds-lp3944.c index 8e1abdcd4c9d..53144fb96167 100644 --- a/drivers/leds/leds-lp3944.c +++ b/drivers/leds/leds-lp3944.c | |||
@@ -335,7 +335,8 @@ static int lp3944_configure(struct i2c_client *client, | |||
335 | } | 335 | } |
336 | 336 | ||
337 | /* to expose the default value to userspace */ | 337 | /* to expose the default value to userspace */ |
338 | led->ldev.brightness = led->status; | 338 | led->ldev.brightness = |
339 | (enum led_brightness) led->status; | ||
339 | 340 | ||
340 | /* Set the default led status */ | 341 | /* Set the default led status */ |
341 | err = lp3944_led_set(led, led->status); | 342 | err = lp3944_led_set(led, led->status); |
diff --git a/drivers/leds/trigger/ledtrig-gpio.c b/drivers/leds/trigger/ledtrig-gpio.c index 35812e3a37f2..c86c41826476 100644 --- a/drivers/leds/trigger/ledtrig-gpio.c +++ b/drivers/leds/trigger/ledtrig-gpio.c | |||
@@ -48,7 +48,7 @@ static void gpio_trig_work(struct work_struct *work) | |||
48 | if (!gpio_data->gpio) | 48 | if (!gpio_data->gpio) |
49 | return; | 49 | return; |
50 | 50 | ||
51 | tmp = gpio_get_value(gpio_data->gpio); | 51 | tmp = gpio_get_value_cansleep(gpio_data->gpio); |
52 | if (gpio_data->inverted) | 52 | if (gpio_data->inverted) |
53 | tmp = !tmp; | 53 | tmp = !tmp; |
54 | 54 | ||