Commit 5ae4e8a7 authored by Kim, Milo's avatar Kim, Milo Committed by Linus Torvalds

drivers/leds/leds-lp5521.c: add 'name' in the lp5521_led_config

The name of each led channel can be configurable.  For the compatibility,
the name is set to default value(xx:channelN) when 'name' is not defined.
Signed-off-by: default avatarMilo(Woogyom) Kim <milo.kim@ti.com>
Acked-by: default avatarLinus Walleij <linus.walleij@linaro.org>
Cc: Arun MURTHY <arun.murthy@stericsson.com>
Cc: Srinidhi Kasagar <srinidhi.kasagar@stericsson.com>
Cc: Richard Purdie <rpurdie@rpsys.net>
Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
parent c5bd2a71
...@@ -43,17 +43,23 @@ Format: 10x mA i.e 10 means 1.0 mA ...@@ -43,17 +43,23 @@ Format: 10x mA i.e 10 means 1.0 mA
example platform data: example platform data:
Note: chan_nr can have values between 0 and 2. Note: chan_nr can have values between 0 and 2.
The name of each channel can be configurable.
If the name field is not defined, the default name will be set to 'xxxx:channelN'
(XXXX : pdata->label or i2c client name, N : channel number)
static struct lp5521_led_config lp5521_led_config[] = { static struct lp5521_led_config lp5521_led_config[] = {
{ {
.name = "red",
.chan_nr = 0, .chan_nr = 0,
.led_current = 50, .led_current = 50,
.max_current = 130, .max_current = 130,
}, { }, {
.name = "green",
.chan_nr = 1, .chan_nr = 1,
.led_current = 0, .led_current = 0,
.max_current = 130, .max_current = 130,
}, { }, {
.name = "blue",
.chan_nr = 2, .chan_nr = 2,
.led_current = 0, .led_current = 0,
.max_current = 130, .max_current = 130,
......
...@@ -620,10 +620,15 @@ static int __devinit lp5521_init_led(struct lp5521_led *led, ...@@ -620,10 +620,15 @@ static int __devinit lp5521_init_led(struct lp5521_led *led,
return -EINVAL; return -EINVAL;
} }
led->cdev.brightness_set = lp5521_set_brightness;
if (pdata->led_config[chan].name) {
led->cdev.name = pdata->led_config[chan].name;
} else {
snprintf(name, sizeof(name), "%s:channel%d", snprintf(name, sizeof(name), "%s:channel%d",
pdata->label ?: client->name, chan); pdata->label ?: client->name, chan);
led->cdev.brightness_set = lp5521_set_brightness;
led->cdev.name = name; led->cdev.name = name;
}
res = led_classdev_register(dev, &led->cdev); res = led_classdev_register(dev, &led->cdev);
if (res < 0) { if (res < 0) {
dev_err(dev, "couldn't register led on channel %d\n", chan); dev_err(dev, "couldn't register led on channel %d\n", chan);
......
...@@ -26,6 +26,7 @@ ...@@ -26,6 +26,7 @@
/* See Documentation/leds/leds-lp5521.txt */ /* See Documentation/leds/leds-lp5521.txt */
struct lp5521_led_config { struct lp5521_led_config {
char *name;
u8 chan_nr; u8 chan_nr;
u8 led_current; /* mA x10, 0 if led is not connected */ u8 led_current; /* mA x10, 0 if led is not connected */
u8 max_current; u8 max_current;
......
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