diff options
author | Milo(Woogyom) Kim <milo.kim@ti.com> | 2013-02-05 05:20:45 -0500 |
---|---|---|
committer | Bryan Wu <cooloney@gmail.com> | 2013-02-06 18:59:29 -0500 |
commit | e73c0ce6beaa71bee39b2d11bff0253be84c71a9 (patch) | |
tree | ed279d825d63da71f02770d816fe0c8b15e0a8ca /drivers | |
parent | 240085e255cd2818aff2ccde3066b7db1f29076a (diff) |
leds-lp55xx: use common device attribute driver function
lp5521/5523_register_sysfs() are replaced with lp55xx common driver function,
lp55xx_register_sysfs().
Chip specific device attributes are configurable using 'dev_attr_group'.
Error condition name is changed:
use specific error condition, 'err_register_sysfs' rather than unclear name,
'fail2'.
Signed-off-by: Milo(Woogyom) Kim <milo.kim@ti.com>
Signed-off-by: Bryan Wu <cooloney@gmail.com>
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/leds/leds-lp5521.c | 17 | ||||
-rw-r--r-- | drivers/leds/leds-lp5523.c | 23 |
2 files changed, 14 insertions, 26 deletions
diff --git a/drivers/leds/leds-lp5521.c b/drivers/leds/leds-lp5521.c index 89371e065c13..abc33139e6fa 100644 --- a/drivers/leds/leds-lp5521.c +++ b/drivers/leds/leds-lp5521.c | |||
@@ -506,12 +506,6 @@ static const struct attribute_group lp5521_group = { | |||
506 | .attrs = lp5521_attributes, | 506 | .attrs = lp5521_attributes, |
507 | }; | 507 | }; |
508 | 508 | ||
509 | static int lp5521_register_sysfs(struct i2c_client *client) | ||
510 | { | ||
511 | struct device *dev = &client->dev; | ||
512 | return sysfs_create_group(&dev->kobj, &lp5521_group); | ||
513 | } | ||
514 | |||
515 | static void lp5521_unregister_sysfs(struct i2c_client *client) | 509 | static void lp5521_unregister_sysfs(struct i2c_client *client) |
516 | { | 510 | { |
517 | struct device *dev = &client->dev; | 511 | struct device *dev = &client->dev; |
@@ -535,6 +529,7 @@ static struct lp55xx_device_config lp5521_cfg = { | |||
535 | .set_led_current = lp5521_set_led_current, | 529 | .set_led_current = lp5521_set_led_current, |
536 | .firmware_cb = lp5521_firmware_loaded, | 530 | .firmware_cb = lp5521_firmware_loaded, |
537 | .run_engine = lp5521_run_engine, | 531 | .run_engine = lp5521_run_engine, |
532 | .dev_attr_group = &lp5521_group, | ||
538 | }; | 533 | }; |
539 | 534 | ||
540 | static int lp5521_probe(struct i2c_client *client, | 535 | static int lp5521_probe(struct i2c_client *client, |
@@ -577,13 +572,15 @@ static int lp5521_probe(struct i2c_client *client, | |||
577 | if (ret) | 572 | if (ret) |
578 | goto err_register_leds; | 573 | goto err_register_leds; |
579 | 574 | ||
580 | ret = lp5521_register_sysfs(client); | 575 | ret = lp55xx_register_sysfs(chip); |
581 | if (ret) { | 576 | if (ret) { |
582 | dev_err(&client->dev, "registering sysfs failed\n"); | 577 | dev_err(&client->dev, "registering sysfs failed\n"); |
583 | goto fail2; | 578 | goto err_register_sysfs; |
584 | } | 579 | } |
585 | return ret; | 580 | |
586 | fail2: | 581 | return 0; |
582 | |||
583 | err_register_sysfs: | ||
587 | lp55xx_unregister_leds(led, chip); | 584 | lp55xx_unregister_leds(led, chip); |
588 | err_register_leds: | 585 | err_register_leds: |
589 | lp55xx_deinit_device(chip); | 586 | lp55xx_deinit_device(chip); |
diff --git a/drivers/leds/leds-lp5523.c b/drivers/leds/leds-lp5523.c index 4b1ad9013a51..4192a1ec6062 100644 --- a/drivers/leds/leds-lp5523.c +++ b/drivers/leds/leds-lp5523.c | |||
@@ -484,18 +484,6 @@ static const struct attribute_group lp5523_group = { | |||
484 | .attrs = lp5523_attributes, | 484 | .attrs = lp5523_attributes, |
485 | }; | 485 | }; |
486 | 486 | ||
487 | static int lp5523_register_sysfs(struct i2c_client *client) | ||
488 | { | ||
489 | struct device *dev = &client->dev; | ||
490 | int ret; | ||
491 | |||
492 | ret = sysfs_create_group(&dev->kobj, &lp5523_group); | ||
493 | if (ret < 0) | ||
494 | return ret; | ||
495 | |||
496 | return 0; | ||
497 | } | ||
498 | |||
499 | static void lp5523_unregister_sysfs(struct i2c_client *client) | 487 | static void lp5523_unregister_sysfs(struct i2c_client *client) |
500 | { | 488 | { |
501 | struct device *dev = &client->dev; | 489 | struct device *dev = &client->dev; |
@@ -519,6 +507,7 @@ static struct lp55xx_device_config lp5523_cfg = { | |||
519 | .set_led_current = lp5523_set_led_current, | 507 | .set_led_current = lp5523_set_led_current, |
520 | .firmware_cb = lp5523_firmware_loaded, | 508 | .firmware_cb = lp5523_firmware_loaded, |
521 | .run_engine = lp5523_run_engine, | 509 | .run_engine = lp5523_run_engine, |
510 | .dev_attr_group = &lp5523_group, | ||
522 | }; | 511 | }; |
523 | 512 | ||
524 | static int lp5523_probe(struct i2c_client *client, | 513 | static int lp5523_probe(struct i2c_client *client, |
@@ -561,13 +550,15 @@ static int lp5523_probe(struct i2c_client *client, | |||
561 | if (ret) | 550 | if (ret) |
562 | goto err_register_leds; | 551 | goto err_register_leds; |
563 | 552 | ||
564 | ret = lp5523_register_sysfs(client); | 553 | ret = lp55xx_register_sysfs(chip); |
565 | if (ret) { | 554 | if (ret) { |
566 | dev_err(&client->dev, "registering sysfs failed\n"); | 555 | dev_err(&client->dev, "registering sysfs failed\n"); |
567 | goto fail2; | 556 | goto err_register_sysfs; |
568 | } | 557 | } |
569 | return ret; | 558 | |
570 | fail2: | 559 | return 0; |
560 | |||
561 | err_register_sysfs: | ||
571 | lp55xx_unregister_leds(led, chip); | 562 | lp55xx_unregister_leds(led, chip); |
572 | err_register_leds: | 563 | err_register_leds: |
573 | lp55xx_deinit_device(chip); | 564 | lp55xx_deinit_device(chip); |