aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/leds
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/leds')
-rw-r--r--drivers/leds/leds-lp5521.c79
-rw-r--r--drivers/leds/leds-lp5523.c19
2 files changed, 4 insertions, 94 deletions
diff --git a/drivers/leds/leds-lp5521.c b/drivers/leds/leds-lp5521.c
index 1f6d9c7eb4a2..46721c3a8e8b 100644
--- a/drivers/leds/leds-lp5521.c
+++ b/drivers/leds/leds-lp5521.c
@@ -412,36 +412,6 @@ static ssize_t lp5521_selftest(struct device *dev,
412 return sprintf(buf, "%s\n", ret ? "FAIL" : "OK"); 412 return sprintf(buf, "%s\n", ret ? "FAIL" : "OK");
413} 413}
414 414
415static void lp5521_clear_program_memory(struct i2c_client *cl)
416{
417 int i;
418 u8 rgb_mem[] = {
419 LP5521_REG_R_PROG_MEM,
420 LP5521_REG_G_PROG_MEM,
421 LP5521_REG_B_PROG_MEM,
422 };
423
424 for (i = 0; i < ARRAY_SIZE(rgb_mem); i++) {
425 lp5521_write(cl, rgb_mem[i], 0);
426 lp5521_write(cl, rgb_mem[i] + 1, 0);
427 }
428}
429
430static void lp5521_write_program_memory(struct i2c_client *cl,
431 u8 base, u8 *rgb, int size)
432{
433 int i;
434
435 if (!rgb || size <= 0)
436 return;
437
438 for (i = 0; i < size; i++)
439 lp5521_write(cl, base + i, *(rgb + i));
440
441 lp5521_write(cl, base + i, 0);
442 lp5521_write(cl, base + i + 1, 0);
443}
444
445static inline struct lp5521_led_pattern *lp5521_get_pattern 415static inline struct lp5521_led_pattern *lp5521_get_pattern
446 (struct lp5521_chip *chip, u8 offset) 416 (struct lp5521_chip *chip, u8 offset)
447{ 417{
@@ -450,42 +420,6 @@ static inline struct lp5521_led_pattern *lp5521_get_pattern
450 return ptn; 420 return ptn;
451} 421}
452 422
453static void lp5521_run_led_pattern(int mode, struct lp5521_chip *chip)
454{
455 struct lp5521_led_pattern *ptn;
456 struct i2c_client *cl = chip->client;
457 int num_patterns = chip->pdata->num_patterns;
458
459 if (mode > num_patterns || !(chip->pdata->patterns))
460 return;
461
462 if (mode == PATTERN_OFF) {
463 lp5521_write(cl, LP5521_REG_ENABLE, LP5521_ENABLE_DEFAULT);
464 usleep_range(1000, 2000);
465 lp5521_write(cl, LP5521_REG_OP_MODE, LP5521_CMD_DIRECT);
466 } else {
467 ptn = lp5521_get_pattern(chip, mode);
468 if (!ptn)
469 return;
470
471 lp5521_write(cl, LP5521_REG_OP_MODE, LP5521_CMD_LOAD);
472 usleep_range(1000, 2000);
473
474 lp5521_clear_program_memory(cl);
475
476 lp5521_write_program_memory(cl, LP5521_REG_R_PROG_MEM,
477 ptn->r, ptn->size_r);
478 lp5521_write_program_memory(cl, LP5521_REG_G_PROG_MEM,
479 ptn->g, ptn->size_g);
480 lp5521_write_program_memory(cl, LP5521_REG_B_PROG_MEM,
481 ptn->b, ptn->size_b);
482
483 lp5521_write(cl, LP5521_REG_OP_MODE, LP5521_CMD_RUN);
484 usleep_range(1000, 2000);
485 lp5521_write(cl, LP5521_REG_ENABLE, LP5521_ENABLE_RUN_PROGRAM);
486 }
487}
488
489/* device attributes */ 423/* device attributes */
490static DEVICE_ATTR(selftest, S_IRUGO, lp5521_selftest, NULL); 424static DEVICE_ATTR(selftest, S_IRUGO, lp5521_selftest, NULL);
491 425
@@ -498,13 +432,6 @@ static const struct attribute_group lp5521_group = {
498 .attrs = lp5521_attributes, 432 .attrs = lp5521_attributes,
499}; 433};
500 434
501static void lp5521_unregister_sysfs(struct i2c_client *client)
502{
503 struct device *dev = &client->dev;
504
505 sysfs_remove_group(&dev->kobj, &lp5521_group);
506}
507
508/* Chip specific configurations */ 435/* Chip specific configurations */
509static struct lp55xx_device_config lp5521_cfg = { 436static struct lp55xx_device_config lp5521_cfg = {
510 .reset = { 437 .reset = {
@@ -582,13 +509,11 @@ err_init:
582 509
583static int lp5521_remove(struct i2c_client *client) 510static int lp5521_remove(struct i2c_client *client)
584{ 511{
585 struct lp5521_chip *old_chip = i2c_get_clientdata(client);
586 struct lp55xx_led *led = i2c_get_clientdata(client); 512 struct lp55xx_led *led = i2c_get_clientdata(client);
587 struct lp55xx_chip *chip = led->chip; 513 struct lp55xx_chip *chip = led->chip;
588 514
589 lp5521_run_led_pattern(PATTERN_OFF, old_chip); 515 lp5521_stop_engine(chip);
590 lp5521_unregister_sysfs(client); 516 lp55xx_unregister_sysfs(chip);
591
592 lp55xx_unregister_leds(led, chip); 517 lp55xx_unregister_leds(led, chip);
593 lp55xx_deinit_device(chip); 518 lp55xx_deinit_device(chip);
594 519
diff --git a/drivers/leds/leds-lp5523.c b/drivers/leds/leds-lp5523.c
index 577059934f58..cf587c1b2c41 100644
--- a/drivers/leds/leds-lp5523.c
+++ b/drivers/leds/leds-lp5523.c
@@ -173,11 +173,6 @@ static void lp5523_set_led_current(struct lp55xx_led *led, u8 led_current)
173 led_current); 173 led_current);
174} 174}
175 175
176static int lp5523_write(struct i2c_client *client, u8 reg, u8 value)
177{
178 return i2c_smbus_write_byte_data(client, reg, value);
179}
180
181static int lp5523_post_init_device(struct lp55xx_chip *chip) 176static int lp5523_post_init_device(struct lp55xx_chip *chip)
182{ 177{
183 int ret; 178 int ret;
@@ -471,13 +466,6 @@ static const struct attribute_group lp5523_group = {
471 .attrs = lp5523_attributes, 466 .attrs = lp5523_attributes,
472}; 467};
473 468
474static void lp5523_unregister_sysfs(struct i2c_client *client)
475{
476 struct device *dev = &client->dev;
477
478 sysfs_remove_group(&dev->kobj, &lp5523_group);
479}
480
481/* Chip specific configurations */ 469/* Chip specific configurations */
482static struct lp55xx_device_config lp5523_cfg = { 470static struct lp55xx_device_config lp5523_cfg = {
483 .reset = { 471 .reset = {
@@ -558,11 +546,8 @@ static int lp5523_remove(struct i2c_client *client)
558 struct lp55xx_led *led = i2c_get_clientdata(client); 546 struct lp55xx_led *led = i2c_get_clientdata(client);
559 struct lp55xx_chip *chip = led->chip; 547 struct lp55xx_chip *chip = led->chip;
560 548
561 /* Disable engine mode */ 549 lp5523_stop_engine(chip);
562 lp5523_write(client, LP5523_REG_OP_MODE, LP5523_CMD_DISABLED); 550 lp55xx_unregister_sysfs(chip);
563
564 lp5523_unregister_sysfs(client);
565
566 lp55xx_unregister_leds(led, chip); 551 lp55xx_unregister_leds(led, chip);
567 lp55xx_deinit_device(chip); 552 lp55xx_deinit_device(chip);
568 553