diff options
author | Andrew Lunn <andrew@lunn.ch> | 2015-08-20 06:22:57 -0400 |
---|---|---|
committer | Jacek Anaszewski <j.anaszewski@samsung.com> | 2016-01-04 03:57:33 -0500 |
commit | 95b2af637e283e3d549c8a6af9f182b0bd972a2e (patch) | |
tree | ab1d6e73c0a060faa36dda71b66ab0b9cd829e8e /drivers/leds | |
parent | 525d6a65a2abe279889b019e2663b8a11bc4f90b (diff) |
leds: lp55xx: Remove work queue
Now the core implements the work queue, remove it from the drivers,
and switch to using brightness_set_blocking op.
Signed-off-by: Andrew Lunn <andrew@lunn.ch>
Signed-off-by: Jacek Anaszewski <j.anaszewski@samsung.com>
Cc: Milo Kim <milo.kim@ti.com>
Diffstat (limited to 'drivers/leds')
-rw-r--r-- | drivers/leds/leds-lp5521.c | 11 | ||||
-rw-r--r-- | drivers/leds/leds-lp5523.c | 10 | ||||
-rw-r--r-- | drivers/leds/leds-lp5562.c | 11 | ||||
-rw-r--r-- | drivers/leds/leds-lp55xx-common.c | 12 | ||||
-rw-r--r-- | drivers/leds/leds-lp55xx-common.h | 6 | ||||
-rw-r--r-- | drivers/leds/leds-lp8501.c | 11 |
6 files changed, 30 insertions, 31 deletions
diff --git a/drivers/leds/leds-lp5521.c b/drivers/leds/leds-lp5521.c index 63a92542c8cb..549b315ca8fe 100644 --- a/drivers/leds/leds-lp5521.c +++ b/drivers/leds/leds-lp5521.c | |||
@@ -362,16 +362,17 @@ static int lp5521_run_selftest(struct lp55xx_chip *chip, char *buf) | |||
362 | return 0; | 362 | return 0; |
363 | } | 363 | } |
364 | 364 | ||
365 | static void lp5521_led_brightness_work(struct work_struct *work) | 365 | static int lp5521_led_brightness(struct lp55xx_led *led) |
366 | { | 366 | { |
367 | struct lp55xx_led *led = container_of(work, struct lp55xx_led, | ||
368 | brightness_work); | ||
369 | struct lp55xx_chip *chip = led->chip; | 367 | struct lp55xx_chip *chip = led->chip; |
368 | int ret; | ||
370 | 369 | ||
371 | mutex_lock(&chip->lock); | 370 | mutex_lock(&chip->lock); |
372 | lp55xx_write(chip, LP5521_REG_LED_PWM_BASE + led->chan_nr, | 371 | ret = lp55xx_write(chip, LP5521_REG_LED_PWM_BASE + led->chan_nr, |
373 | led->brightness); | 372 | led->brightness); |
374 | mutex_unlock(&chip->lock); | 373 | mutex_unlock(&chip->lock); |
374 | |||
375 | return ret; | ||
375 | } | 376 | } |
376 | 377 | ||
377 | static ssize_t show_engine_mode(struct device *dev, | 378 | static ssize_t show_engine_mode(struct device *dev, |
@@ -501,7 +502,7 @@ static struct lp55xx_device_config lp5521_cfg = { | |||
501 | }, | 502 | }, |
502 | .max_channel = LP5521_MAX_LEDS, | 503 | .max_channel = LP5521_MAX_LEDS, |
503 | .post_init_device = lp5521_post_init_device, | 504 | .post_init_device = lp5521_post_init_device, |
504 | .brightness_work_fn = lp5521_led_brightness_work, | 505 | .brightness_fn = lp5521_led_brightness, |
505 | .set_led_current = lp5521_set_led_current, | 506 | .set_led_current = lp5521_set_led_current, |
506 | .firmware_cb = lp5521_firmware_loaded, | 507 | .firmware_cb = lp5521_firmware_loaded, |
507 | .run_engine = lp5521_run_engine, | 508 | .run_engine = lp5521_run_engine, |
diff --git a/drivers/leds/leds-lp5523.c b/drivers/leds/leds-lp5523.c index 1d0187f42941..c5b30f06218a 100644 --- a/drivers/leds/leds-lp5523.c +++ b/drivers/leds/leds-lp5523.c | |||
@@ -802,16 +802,16 @@ leave: | |||
802 | return ret; | 802 | return ret; |
803 | } | 803 | } |
804 | 804 | ||
805 | static void lp5523_led_brightness_work(struct work_struct *work) | 805 | static int lp5523_led_brightness(struct lp55xx_led *led) |
806 | { | 806 | { |
807 | struct lp55xx_led *led = container_of(work, struct lp55xx_led, | ||
808 | brightness_work); | ||
809 | struct lp55xx_chip *chip = led->chip; | 807 | struct lp55xx_chip *chip = led->chip; |
808 | int ret; | ||
810 | 809 | ||
811 | mutex_lock(&chip->lock); | 810 | mutex_lock(&chip->lock); |
812 | lp55xx_write(chip, LP5523_REG_LED_PWM_BASE + led->chan_nr, | 811 | ret = lp55xx_write(chip, LP5523_REG_LED_PWM_BASE + led->chan_nr, |
813 | led->brightness); | 812 | led->brightness); |
814 | mutex_unlock(&chip->lock); | 813 | mutex_unlock(&chip->lock); |
814 | return ret; | ||
815 | } | 815 | } |
816 | 816 | ||
817 | static LP55XX_DEV_ATTR_RW(engine1_mode, show_engine1_mode, store_engine1_mode); | 817 | static LP55XX_DEV_ATTR_RW(engine1_mode, show_engine1_mode, store_engine1_mode); |
@@ -867,7 +867,7 @@ static struct lp55xx_device_config lp5523_cfg = { | |||
867 | }, | 867 | }, |
868 | .max_channel = LP5523_MAX_LEDS, | 868 | .max_channel = LP5523_MAX_LEDS, |
869 | .post_init_device = lp5523_post_init_device, | 869 | .post_init_device = lp5523_post_init_device, |
870 | .brightness_work_fn = lp5523_led_brightness_work, | 870 | .brightness_fn = lp5523_led_brightness, |
871 | .set_led_current = lp5523_set_led_current, | 871 | .set_led_current = lp5523_set_led_current, |
872 | .firmware_cb = lp5523_firmware_loaded, | 872 | .firmware_cb = lp5523_firmware_loaded, |
873 | .run_engine = lp5523_run_engine, | 873 | .run_engine = lp5523_run_engine, |
diff --git a/drivers/leds/leds-lp5562.c b/drivers/leds/leds-lp5562.c index 0360c59dbdc9..b75333803a63 100644 --- a/drivers/leds/leds-lp5562.c +++ b/drivers/leds/leds-lp5562.c | |||
@@ -311,10 +311,8 @@ static int lp5562_post_init_device(struct lp55xx_chip *chip) | |||
311 | return 0; | 311 | return 0; |
312 | } | 312 | } |
313 | 313 | ||
314 | static void lp5562_led_brightness_work(struct work_struct *work) | 314 | static int lp5562_led_brightness(struct lp55xx_led *led) |
315 | { | 315 | { |
316 | struct lp55xx_led *led = container_of(work, struct lp55xx_led, | ||
317 | brightness_work); | ||
318 | struct lp55xx_chip *chip = led->chip; | 316 | struct lp55xx_chip *chip = led->chip; |
319 | u8 addr[] = { | 317 | u8 addr[] = { |
320 | LP5562_REG_R_PWM, | 318 | LP5562_REG_R_PWM, |
@@ -322,10 +320,13 @@ static void lp5562_led_brightness_work(struct work_struct *work) | |||
322 | LP5562_REG_B_PWM, | 320 | LP5562_REG_B_PWM, |
323 | LP5562_REG_W_PWM, | 321 | LP5562_REG_W_PWM, |
324 | }; | 322 | }; |
323 | int ret; | ||
325 | 324 | ||
326 | mutex_lock(&chip->lock); | 325 | mutex_lock(&chip->lock); |
327 | lp55xx_write(chip, addr[led->chan_nr], led->brightness); | 326 | ret = lp55xx_write(chip, addr[led->chan_nr], led->brightness); |
328 | mutex_unlock(&chip->lock); | 327 | mutex_unlock(&chip->lock); |
328 | |||
329 | return ret; | ||
329 | } | 330 | } |
330 | 331 | ||
331 | static void lp5562_write_program_memory(struct lp55xx_chip *chip, | 332 | static void lp5562_write_program_memory(struct lp55xx_chip *chip, |
@@ -503,7 +504,7 @@ static struct lp55xx_device_config lp5562_cfg = { | |||
503 | }, | 504 | }, |
504 | .post_init_device = lp5562_post_init_device, | 505 | .post_init_device = lp5562_post_init_device, |
505 | .set_led_current = lp5562_set_led_current, | 506 | .set_led_current = lp5562_set_led_current, |
506 | .brightness_work_fn = lp5562_led_brightness_work, | 507 | .brightness_fn = lp5562_led_brightness, |
507 | .run_engine = lp5562_run_engine, | 508 | .run_engine = lp5562_run_engine, |
508 | .firmware_cb = lp5562_firmware_loaded, | 509 | .firmware_cb = lp5562_firmware_loaded, |
509 | .dev_attr_group = &lp5562_group, | 510 | .dev_attr_group = &lp5562_group, |
diff --git a/drivers/leds/leds-lp55xx-common.c b/drivers/leds/leds-lp55xx-common.c index 59b76833f0d3..5377f22ff994 100644 --- a/drivers/leds/leds-lp55xx-common.c +++ b/drivers/leds/leds-lp55xx-common.c | |||
@@ -134,13 +134,14 @@ static struct attribute *lp55xx_led_attrs[] = { | |||
134 | }; | 134 | }; |
135 | ATTRIBUTE_GROUPS(lp55xx_led); | 135 | ATTRIBUTE_GROUPS(lp55xx_led); |
136 | 136 | ||
137 | static void lp55xx_set_brightness(struct led_classdev *cdev, | 137 | static int lp55xx_set_brightness(struct led_classdev *cdev, |
138 | enum led_brightness brightness) | 138 | enum led_brightness brightness) |
139 | { | 139 | { |
140 | struct lp55xx_led *led = cdev_to_lp55xx_led(cdev); | 140 | struct lp55xx_led *led = cdev_to_lp55xx_led(cdev); |
141 | struct lp55xx_device_config *cfg = led->chip->cfg; | ||
141 | 142 | ||
142 | led->brightness = (u8)brightness; | 143 | led->brightness = (u8)brightness; |
143 | schedule_work(&led->brightness_work); | 144 | return cfg->brightness_fn(led); |
144 | } | 145 | } |
145 | 146 | ||
146 | static int lp55xx_init_led(struct lp55xx_led *led, | 147 | static int lp55xx_init_led(struct lp55xx_led *led, |
@@ -172,7 +173,7 @@ static int lp55xx_init_led(struct lp55xx_led *led, | |||
172 | return -EINVAL; | 173 | return -EINVAL; |
173 | } | 174 | } |
174 | 175 | ||
175 | led->cdev.brightness_set = lp55xx_set_brightness; | 176 | led->cdev.brightness_set_blocking = lp55xx_set_brightness; |
176 | led->cdev.groups = lp55xx_led_groups; | 177 | led->cdev.groups = lp55xx_led_groups; |
177 | 178 | ||
178 | if (pdata->led_config[chan].name) { | 179 | if (pdata->led_config[chan].name) { |
@@ -464,7 +465,7 @@ int lp55xx_register_leds(struct lp55xx_led *led, struct lp55xx_chip *chip) | |||
464 | int ret; | 465 | int ret; |
465 | int i; | 466 | int i; |
466 | 467 | ||
467 | if (!cfg->brightness_work_fn) { | 468 | if (!cfg->brightness_fn) { |
468 | dev_err(&chip->cl->dev, "empty brightness configuration\n"); | 469 | dev_err(&chip->cl->dev, "empty brightness configuration\n"); |
469 | return -EINVAL; | 470 | return -EINVAL; |
470 | } | 471 | } |
@@ -481,8 +482,6 @@ int lp55xx_register_leds(struct lp55xx_led *led, struct lp55xx_chip *chip) | |||
481 | if (ret) | 482 | if (ret) |
482 | goto err_init_led; | 483 | goto err_init_led; |
483 | 484 | ||
484 | INIT_WORK(&each->brightness_work, cfg->brightness_work_fn); | ||
485 | |||
486 | chip->num_leds++; | 485 | chip->num_leds++; |
487 | each->chip = chip; | 486 | each->chip = chip; |
488 | 487 | ||
@@ -507,7 +506,6 @@ void lp55xx_unregister_leds(struct lp55xx_led *led, struct lp55xx_chip *chip) | |||
507 | for (i = 0; i < chip->num_leds; i++) { | 506 | for (i = 0; i < chip->num_leds; i++) { |
508 | each = led + i; | 507 | each = led + i; |
509 | led_classdev_unregister(&each->cdev); | 508 | led_classdev_unregister(&each->cdev); |
510 | flush_work(&each->brightness_work); | ||
511 | } | 509 | } |
512 | } | 510 | } |
513 | EXPORT_SYMBOL_GPL(lp55xx_unregister_leds); | 511 | EXPORT_SYMBOL_GPL(lp55xx_unregister_leds); |
diff --git a/drivers/leds/leds-lp55xx-common.h b/drivers/leds/leds-lp55xx-common.h index c7f1e6155001..abf1fb5da37d 100644 --- a/drivers/leds/leds-lp55xx-common.h +++ b/drivers/leds/leds-lp55xx-common.h | |||
@@ -95,7 +95,7 @@ struct lp55xx_reg { | |||
95 | * @enable : Chip specific enable command | 95 | * @enable : Chip specific enable command |
96 | * @max_channel : Maximum number of channels | 96 | * @max_channel : Maximum number of channels |
97 | * @post_init_device : Chip specific initialization code | 97 | * @post_init_device : Chip specific initialization code |
98 | * @brightness_work_fn : Brightness work function | 98 | * @brightness_fn : Brightness function |
99 | * @set_led_current : LED current set function | 99 | * @set_led_current : LED current set function |
100 | * @firmware_cb : Call function when the firmware is loaded | 100 | * @firmware_cb : Call function when the firmware is loaded |
101 | * @run_engine : Run internal engine for pattern | 101 | * @run_engine : Run internal engine for pattern |
@@ -110,7 +110,7 @@ struct lp55xx_device_config { | |||
110 | int (*post_init_device) (struct lp55xx_chip *chip); | 110 | int (*post_init_device) (struct lp55xx_chip *chip); |
111 | 111 | ||
112 | /* access brightness register */ | 112 | /* access brightness register */ |
113 | void (*brightness_work_fn)(struct work_struct *work); | 113 | int (*brightness_fn)(struct lp55xx_led *led); |
114 | 114 | ||
115 | /* current setting function */ | 115 | /* current setting function */ |
116 | void (*set_led_current) (struct lp55xx_led *led, u8 led_current); | 116 | void (*set_led_current) (struct lp55xx_led *led, u8 led_current); |
@@ -164,7 +164,6 @@ struct lp55xx_chip { | |||
164 | * @cdev : LED class device | 164 | * @cdev : LED class device |
165 | * @led_current : Current setting at each led channel | 165 | * @led_current : Current setting at each led channel |
166 | * @max_current : Maximun current at each led channel | 166 | * @max_current : Maximun current at each led channel |
167 | * @brightness_work : Workqueue for brightness control | ||
168 | * @brightness : Brightness value | 167 | * @brightness : Brightness value |
169 | * @chip : The lp55xx chip data | 168 | * @chip : The lp55xx chip data |
170 | */ | 169 | */ |
@@ -173,7 +172,6 @@ struct lp55xx_led { | |||
173 | struct led_classdev cdev; | 172 | struct led_classdev cdev; |
174 | u8 led_current; | 173 | u8 led_current; |
175 | u8 max_current; | 174 | u8 max_current; |
176 | struct work_struct brightness_work; | ||
177 | u8 brightness; | 175 | u8 brightness; |
178 | struct lp55xx_chip *chip; | 176 | struct lp55xx_chip *chip; |
179 | }; | 177 | }; |
diff --git a/drivers/leds/leds-lp8501.c b/drivers/leds/leds-lp8501.c index 3f54f6f2b821..3f9675bd214a 100644 --- a/drivers/leds/leds-lp8501.c +++ b/drivers/leds/leds-lp8501.c | |||
@@ -272,16 +272,17 @@ static void lp8501_firmware_loaded(struct lp55xx_chip *chip) | |||
272 | lp8501_update_program_memory(chip, fw->data, fw->size); | 272 | lp8501_update_program_memory(chip, fw->data, fw->size); |
273 | } | 273 | } |
274 | 274 | ||
275 | static void lp8501_led_brightness_work(struct work_struct *work) | 275 | static int lp8501_led_brightness(struct lp55xx_led *led) |
276 | { | 276 | { |
277 | struct lp55xx_led *led = container_of(work, struct lp55xx_led, | ||
278 | brightness_work); | ||
279 | struct lp55xx_chip *chip = led->chip; | 277 | struct lp55xx_chip *chip = led->chip; |
278 | int ret; | ||
280 | 279 | ||
281 | mutex_lock(&chip->lock); | 280 | mutex_lock(&chip->lock); |
282 | lp55xx_write(chip, LP8501_REG_LED_PWM_BASE + led->chan_nr, | 281 | ret = lp55xx_write(chip, LP8501_REG_LED_PWM_BASE + led->chan_nr, |
283 | led->brightness); | 282 | led->brightness); |
284 | mutex_unlock(&chip->lock); | 283 | mutex_unlock(&chip->lock); |
284 | |||
285 | return ret; | ||
285 | } | 286 | } |
286 | 287 | ||
287 | /* Chip specific configurations */ | 288 | /* Chip specific configurations */ |
@@ -296,7 +297,7 @@ static struct lp55xx_device_config lp8501_cfg = { | |||
296 | }, | 297 | }, |
297 | .max_channel = LP8501_MAX_LEDS, | 298 | .max_channel = LP8501_MAX_LEDS, |
298 | .post_init_device = lp8501_post_init_device, | 299 | .post_init_device = lp8501_post_init_device, |
299 | .brightness_work_fn = lp8501_led_brightness_work, | 300 | .brightness_fn = lp8501_led_brightness, |
300 | .set_led_current = lp8501_set_led_current, | 301 | .set_led_current = lp8501_set_led_current, |
301 | .firmware_cb = lp8501_firmware_loaded, | 302 | .firmware_cb = lp8501_firmware_loaded, |
302 | .run_engine = lp8501_run_engine, | 303 | .run_engine = lp8501_run_engine, |