aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
Diffstat (limited to 'drivers')
-rw-r--r--drivers/leds/leds-lp5521.c19
-rw-r--r--drivers/leds/leds-lp5523.c23
-rw-r--r--drivers/leds/leds-lp55xx-common.c9
3 files changed, 17 insertions, 34 deletions
diff --git a/drivers/leds/leds-lp5521.c b/drivers/leds/leds-lp5521.c
index bda03049fb3c..6efbb7ec0e2d 100644
--- a/drivers/leds/leds-lp5521.c
+++ b/drivers/leds/leds-lp5521.c
@@ -151,8 +151,6 @@ static inline struct lp5521_chip *led_to_lp5521(struct lp5521_led *led)
151 leds[led->id]); 151 leds[led->id]);
152} 152}
153 153
154static void lp5521_led_brightness_work(struct work_struct *work);
155
156static inline int lp5521_write(struct i2c_client *client, u8 reg, u8 value) 154static inline int lp5521_write(struct i2c_client *client, u8 reg, u8 value)
157{ 155{
158 return i2c_smbus_write_byte_data(client, reg, value); 156 return i2c_smbus_write_byte_data(client, reg, value);
@@ -303,24 +301,14 @@ static int lp5521_run_selftest(struct lp5521_chip *chip, char *buf)
303 return 0; 301 return 0;
304} 302}
305 303
306static void lp5521_set_brightness(struct led_classdev *cdev,
307 enum led_brightness brightness)
308{
309 struct lp5521_led *led = cdev_to_led(cdev);
310 led->brightness = (u8)brightness;
311 schedule_work(&led->brightness_work);
312}
313
314static void lp5521_led_brightness_work(struct work_struct *work) 304static void lp5521_led_brightness_work(struct work_struct *work)
315{ 305{
316 struct lp5521_led *led = container_of(work, 306 struct lp55xx_led *led = container_of(work, struct lp55xx_led,
317 struct lp5521_led,
318 brightness_work); 307 brightness_work);
319 struct lp5521_chip *chip = led_to_lp5521(led); 308 struct lp55xx_chip *chip = led->chip;
320 struct i2c_client *client = chip->client;
321 309
322 mutex_lock(&chip->lock); 310 mutex_lock(&chip->lock);
323 lp5521_write(client, LP5521_REG_LED_PWM_BASE + led->chan_nr, 311 lp55xx_write(chip, LP5521_REG_LED_PWM_BASE + led->chan_nr,
324 led->brightness); 312 led->brightness);
325 mutex_unlock(&chip->lock); 313 mutex_unlock(&chip->lock);
326} 314}
@@ -711,6 +699,7 @@ static struct lp55xx_device_config lp5521_cfg = {
711 }, 699 },
712 .max_channel = LP5521_MAX_LEDS, 700 .max_channel = LP5521_MAX_LEDS,
713 .post_init_device = lp5521_post_init_device, 701 .post_init_device = lp5521_post_init_device,
702 .brightness_work_fn = lp5521_led_brightness_work,
714}; 703};
715 704
716static int lp5521_probe(struct i2c_client *client, 705static int lp5521_probe(struct i2c_client *client,
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,
diff --git a/drivers/leds/leds-lp55xx-common.c b/drivers/leds/leds-lp55xx-common.c
index 75ab1c3c03ed..8244d78447f4 100644
--- a/drivers/leds/leds-lp55xx-common.c
+++ b/drivers/leds/leds-lp55xx-common.c
@@ -20,6 +20,11 @@
20 20
21#include "leds-lp55xx-common.h" 21#include "leds-lp55xx-common.h"
22 22
23static struct lp55xx_led *cdev_to_lp55xx_led(struct led_classdev *cdev)
24{
25 return container_of(cdev, struct lp55xx_led, cdev);
26}
27
23static void lp55xx_reset_device(struct lp55xx_chip *chip) 28static void lp55xx_reset_device(struct lp55xx_chip *chip)
24{ 29{
25 struct lp55xx_device_config *cfg = chip->cfg; 30 struct lp55xx_device_config *cfg = chip->cfg;
@@ -74,6 +79,10 @@ static struct attribute_group lp55xx_led_attr_group = {
74static void lp55xx_set_brightness(struct led_classdev *cdev, 79static void lp55xx_set_brightness(struct led_classdev *cdev,
75 enum led_brightness brightness) 80 enum led_brightness brightness)
76{ 81{
82 struct lp55xx_led *led = cdev_to_lp55xx_led(cdev);
83
84 led->brightness = (u8)brightness;
85 schedule_work(&led->brightness_work);
77} 86}
78 87
79static int lp55xx_init_led(struct lp55xx_led *led, 88static int lp55xx_init_led(struct lp55xx_led *led,