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

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: Milo(Woogyom) Kim <milo.kim@ti.com>
Acked-by: Linus 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: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>

authored by

Kim, Milo and committed by
Linus Torvalds
5ae4e8a7 c5bd2a71

+15 -3
+6
Documentation/leds/leds-lp5521.txt
··· 43 43 example platform data: 44 44 45 45 Note: chan_nr can have values between 0 and 2. 46 + The name of each channel can be configurable. 47 + If the name field is not defined, the default name will be set to 'xxxx:channelN' 48 + (XXXX : pdata->label or i2c client name, N : channel number) 46 49 47 50 static struct lp5521_led_config lp5521_led_config[] = { 48 51 { 52 + .name = "red", 49 53 .chan_nr = 0, 50 54 .led_current = 50, 51 55 .max_current = 130, 52 56 }, { 57 + .name = "green", 53 58 .chan_nr = 1, 54 59 .led_current = 0, 55 60 .max_current = 130, 56 61 }, { 62 + .name = "blue", 57 63 .chan_nr = 2, 58 64 .led_current = 0, 59 65 .max_current = 130,
+8 -3
drivers/leds/leds-lp5521.c
··· 620 620 return -EINVAL; 621 621 } 622 622 623 - snprintf(name, sizeof(name), "%s:channel%d", 624 - pdata->label ?: client->name, chan); 625 623 led->cdev.brightness_set = lp5521_set_brightness; 626 - led->cdev.name = name; 624 + if (pdata->led_config[chan].name) { 625 + led->cdev.name = pdata->led_config[chan].name; 626 + } else { 627 + snprintf(name, sizeof(name), "%s:channel%d", 628 + pdata->label ?: client->name, chan); 629 + led->cdev.name = name; 630 + } 631 + 627 632 res = led_classdev_register(dev, &led->cdev); 628 633 if (res < 0) { 629 634 dev_err(dev, "couldn't register led on channel %d\n", chan);
+1
include/linux/leds-lp5521.h
··· 26 26 /* See Documentation/leds/leds-lp5521.txt */ 27 27 28 28 struct lp5521_led_config { 29 + char *name; 29 30 u8 chan_nr; 30 31 u8 led_current; /* mA x10, 0 if led is not connected */ 31 32 u8 max_current;