aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/leds/leds-lp5523.c
diff options
context:
space:
mode:
authorMilo(Woogyom) Kim <milo.kim@ti.com>2013-02-05 05:08:40 -0500
committerBryan Wu <cooloney@gmail.com>2013-02-06 18:59:28 -0500
commita6e4679a09a0a2bcfa63074272fc9fb2a40f11ad (patch)
tree53405497f05e27c0c69e008f9dfcce05b9e48b25 /drivers/leds/leds-lp5523.c
parent0e2023463a3c9412728cb2c36c79aca0bb731cc8 (diff)
leds-lp55xx: use lp55xx_set_brightness()
lp5521_set_brightness() and lp5523_set_brightness() are replaced with common function, lp55xx_set_brightness(). This function is invoked when the brightness of each LED channel is updated. LP5521 and LP5523 have different register address for the brightness control, so this work is done by chip specific brightness_work_fn(). lp5521/5523_led_brightness_work(): use lp55xx_led and lp55xx_chip data structure. use lp55xx write function. Signed-off-by: Milo(Woogyom) Kim <milo.kim@ti.com> Signed-off-by: Bryan Wu <cooloney@gmail.com>
Diffstat (limited to 'drivers/leds/leds-lp5523.c')
-rw-r--r--drivers/leds/leds-lp5523.c23
1 files changed, 4 insertions, 19 deletions
diff --git a/drivers/leds/leds-lp5523.c b/drivers/leds/leds-lp5523.c
index ca2f8134909f..43db2429616b 100644
--- a/drivers/leds/leds-lp5523.c
+++ b/drivers/leds/leds-lp5523.c
@@ -163,8 +163,6 @@ static void lp5523_set_mode(struct lp5523_engine *engine, u8 mode);
163static int lp5523_set_engine_mode(struct lp5523_engine *engine, u8 mode); 163static int lp5523_set_engine_mode(struct lp5523_engine *engine, u8 mode);
164static int lp5523_load_program(struct lp5523_engine *engine, const u8 *pattern); 164static int lp5523_load_program(struct lp5523_engine *engine, const u8 *pattern);
165 165
166static void lp5523_led_brightness_work(struct work_struct *work);
167
168static int lp5523_write(struct i2c_client *client, u8 reg, u8 value) 166static int lp5523_write(struct i2c_client *client, u8 reg, u8 value)
169{ 167{
170 return i2c_smbus_write_byte_data(client, reg, value); 168 return i2c_smbus_write_byte_data(client, reg, value);
@@ -468,29 +466,15 @@ release_lock:
468 return pos; 466 return pos;
469} 467}
470 468
471static void lp5523_set_brightness(struct led_classdev *cdev,
472 enum led_brightness brightness)
473{
474 struct lp5523_led *led = cdev_to_led(cdev);
475
476 led->brightness = (u8)brightness;
477
478 schedule_work(&led->brightness_work);
479}
480
481static void lp5523_led_brightness_work(struct work_struct *work) 469static void lp5523_led_brightness_work(struct work_struct *work)
482{ 470{
483 struct lp5523_led *led = container_of(work, 471 struct lp55xx_led *led = container_of(work, struct lp55xx_led,
484 struct lp5523_led,
485 brightness_work); 472 brightness_work);
486 struct lp5523_chip *chip = led_to_lp5523(led); 473 struct lp55xx_chip *chip = led->chip;
487 struct i2c_client *client = chip->client;
488 474
489 mutex_lock(&chip->lock); 475 mutex_lock(&chip->lock);
490 476 lp55xx_write(chip, LP5523_REG_LED_PWM_BASE + led->chan_nr,
491 lp5523_write(client, LP5523_REG_LED_PWM_BASE + led->chan_nr,
492 led->brightness); 477 led->brightness);
493
494 mutex_unlock(&chip->lock); 478 mutex_unlock(&chip->lock);
495} 479}
496 480
@@ -795,6 +779,7 @@ static struct lp55xx_device_config lp5523_cfg = {
795 }, 779 },
796 .max_channel = LP5523_MAX_LEDS, 780 .max_channel = LP5523_MAX_LEDS,
797 .post_init_device = lp5523_post_init_device, 781 .post_init_device = lp5523_post_init_device,
782 .brightness_work_fn = lp5523_led_brightness_work,
798}; 783};
799 784
800static int lp5523_probe(struct i2c_client *client, 785static int lp5523_probe(struct i2c_client *client,