diff options
author | Milo(Woogyom) Kim <milo.kim@ti.com> | 2013-02-05 05:07:34 -0500 |
---|---|---|
committer | Bryan Wu <cooloney@gmail.com> | 2013-02-06 18:59:28 -0500 |
commit | 0e2023463a3c9412728cb2c36c79aca0bb731cc8 (patch) | |
tree | d88e84842ab9b3fcca01e56da349f7c94e61ae0a /drivers/leds/leds-lp5521.c | |
parent | 9e9b3db1b2f725bacaf1b7e8708a0c78265bde97 (diff) |
leds-lp55xx: use lp55xx_init_led() common function
lp5521_init_led() and lp5523_init_led() are replaced with one common function,
lp55xx_init_led().
Max channels is configurable, so it's used in lp55xx_init_led().
'LP5523_LEDS' are changed to 'LP5523_MAX_LEDS'.
lp55xx_set_brightness, lp55xx_led_attributes: skeleton
Will be filled in next patches.
Signed-off-by: Milo(Woogyom) Kim <milo.kim@ti.com>
Signed-off-by: Bryan Wu <cooloney@gmail.com>
Diffstat (limited to 'drivers/leds/leds-lp5521.c')
-rw-r--r-- | drivers/leds/leds-lp5521.c | 50 |
1 files changed, 1 insertions, 49 deletions
diff --git a/drivers/leds/leds-lp5521.c b/drivers/leds/leds-lp5521.c index dc58f4106d09..bda03049fb3c 100644 --- a/drivers/leds/leds-lp5521.c +++ b/drivers/leds/leds-lp5521.c | |||
@@ -689,55 +689,6 @@ static void lp5521_unregister_sysfs(struct i2c_client *client) | |||
689 | &lp5521_led_attribute_group); | 689 | &lp5521_led_attribute_group); |
690 | } | 690 | } |
691 | 691 | ||
692 | static int lp5521_init_led(struct lp5521_led *led, | ||
693 | struct i2c_client *client, | ||
694 | int chan, struct lp5521_platform_data *pdata) | ||
695 | { | ||
696 | struct device *dev = &client->dev; | ||
697 | char name[32]; | ||
698 | int res; | ||
699 | |||
700 | if (chan >= LP5521_MAX_LEDS) | ||
701 | return -EINVAL; | ||
702 | |||
703 | if (pdata->led_config[chan].led_current == 0) | ||
704 | return 0; | ||
705 | |||
706 | led->led_current = pdata->led_config[chan].led_current; | ||
707 | led->max_current = pdata->led_config[chan].max_current; | ||
708 | led->chan_nr = pdata->led_config[chan].chan_nr; | ||
709 | |||
710 | if (led->chan_nr >= LP5521_MAX_LEDS) { | ||
711 | dev_err(dev, "Use channel numbers between 0 and %d\n", | ||
712 | LP5521_MAX_LEDS - 1); | ||
713 | return -EINVAL; | ||
714 | } | ||
715 | |||
716 | led->cdev.brightness_set = lp5521_set_brightness; | ||
717 | if (pdata->led_config[chan].name) { | ||
718 | led->cdev.name = pdata->led_config[chan].name; | ||
719 | } else { | ||
720 | snprintf(name, sizeof(name), "%s:channel%d", | ||
721 | pdata->label ?: client->name, chan); | ||
722 | led->cdev.name = name; | ||
723 | } | ||
724 | |||
725 | res = led_classdev_register(dev, &led->cdev); | ||
726 | if (res < 0) { | ||
727 | dev_err(dev, "couldn't register led on channel %d\n", chan); | ||
728 | return res; | ||
729 | } | ||
730 | |||
731 | res = sysfs_create_group(&led->cdev.dev->kobj, | ||
732 | &lp5521_led_attribute_group); | ||
733 | if (res < 0) { | ||
734 | dev_err(dev, "couldn't register current attribute\n"); | ||
735 | led_classdev_unregister(&led->cdev); | ||
736 | return res; | ||
737 | } | ||
738 | return 0; | ||
739 | } | ||
740 | |||
741 | static void lp5521_unregister_leds(struct lp5521_chip *chip) | 692 | static void lp5521_unregister_leds(struct lp5521_chip *chip) |
742 | { | 693 | { |
743 | int i; | 694 | int i; |
@@ -758,6 +709,7 @@ static struct lp55xx_device_config lp5521_cfg = { | |||
758 | .addr = LP5521_REG_ENABLE, | 709 | .addr = LP5521_REG_ENABLE, |
759 | .val = LP5521_ENABLE_DEFAULT, | 710 | .val = LP5521_ENABLE_DEFAULT, |
760 | }, | 711 | }, |
712 | .max_channel = LP5521_MAX_LEDS, | ||
761 | .post_init_device = lp5521_post_init_device, | 713 | .post_init_device = lp5521_post_init_device, |
762 | }; | 714 | }; |
763 | 715 | ||