diff options
Diffstat (limited to 'drivers/leds/leds-lp55xx-common.c')
-rw-r--r-- | drivers/leds/leds-lp55xx-common.c | 55 |
1 files changed, 55 insertions, 0 deletions
diff --git a/drivers/leds/leds-lp55xx-common.c b/drivers/leds/leds-lp55xx-common.c index bcabf2cb949a..1fab1d1c4502 100644 --- a/drivers/leds/leds-lp55xx-common.c +++ b/drivers/leds/leds-lp55xx-common.c | |||
@@ -63,6 +63,12 @@ static int lp55xx_post_init_device(struct lp55xx_chip *chip) | |||
63 | return cfg->post_init_device(chip); | 63 | return cfg->post_init_device(chip); |
64 | } | 64 | } |
65 | 65 | ||
66 | static int lp55xx_init_led(struct lp55xx_led *led, | ||
67 | struct lp55xx_chip *chip, int chan) | ||
68 | { | ||
69 | return 0; | ||
70 | } | ||
71 | |||
66 | int lp55xx_write(struct lp55xx_chip *chip, u8 reg, u8 val) | 72 | int lp55xx_write(struct lp55xx_chip *chip, u8 reg, u8 val) |
67 | { | 73 | { |
68 | return i2c_smbus_write_byte_data(chip->cl, reg, val); | 74 | return i2c_smbus_write_byte_data(chip->cl, reg, val); |
@@ -170,6 +176,55 @@ void lp55xx_deinit_device(struct lp55xx_chip *chip) | |||
170 | } | 176 | } |
171 | EXPORT_SYMBOL_GPL(lp55xx_deinit_device); | 177 | EXPORT_SYMBOL_GPL(lp55xx_deinit_device); |
172 | 178 | ||
179 | int lp55xx_register_leds(struct lp55xx_led *led, struct lp55xx_chip *chip) | ||
180 | { | ||
181 | struct lp55xx_platform_data *pdata = chip->pdata; | ||
182 | struct lp55xx_device_config *cfg = chip->cfg; | ||
183 | int num_channels = pdata->num_channels; | ||
184 | struct lp55xx_led *each; | ||
185 | u8 led_current; | ||
186 | int ret; | ||
187 | int i; | ||
188 | |||
189 | if (!cfg->brightness_work_fn) { | ||
190 | dev_err(&chip->cl->dev, "empty brightness configuration\n"); | ||
191 | return -EINVAL; | ||
192 | } | ||
193 | |||
194 | for (i = 0; i < num_channels; i++) { | ||
195 | |||
196 | /* do not initialize channels that are not connected */ | ||
197 | if (pdata->led_config[i].led_current == 0) | ||
198 | continue; | ||
199 | |||
200 | led_current = pdata->led_config[i].led_current; | ||
201 | each = led + i; | ||
202 | ret = lp55xx_init_led(each, chip, i); | ||
203 | if (ret) | ||
204 | goto err_init_led; | ||
205 | |||
206 | INIT_WORK(&each->brightness_work, cfg->brightness_work_fn); | ||
207 | |||
208 | chip->num_leds++; | ||
209 | each->chip = chip; | ||
210 | |||
211 | /* setting led current at each channel */ | ||
212 | if (cfg->set_led_current) | ||
213 | cfg->set_led_current(each, led_current); | ||
214 | } | ||
215 | |||
216 | return 0; | ||
217 | |||
218 | err_init_led: | ||
219 | for (i = 0; i < chip->num_leds; i++) { | ||
220 | each = led + i; | ||
221 | led_classdev_unregister(&each->cdev); | ||
222 | flush_work(&each->brightness_work); | ||
223 | } | ||
224 | return ret; | ||
225 | } | ||
226 | EXPORT_SYMBOL_GPL(lp55xx_register_leds); | ||
227 | |||
173 | MODULE_AUTHOR("Milo Kim <milo.kim@ti.com>"); | 228 | MODULE_AUTHOR("Milo Kim <milo.kim@ti.com>"); |
174 | MODULE_DESCRIPTION("LP55xx Common Driver"); | 229 | MODULE_DESCRIPTION("LP55xx Common Driver"); |
175 | MODULE_LICENSE("GPL"); | 230 | MODULE_LICENSE("GPL"); |