diff options
author | Mark Brown <broonie@opensource.wolfsonmicro.com> | 2011-03-22 19:30:14 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2011-03-22 20:43:58 -0400 |
commit | 551ea73838c5eba18d673bd4e7fb0fec77cdcb8a (patch) | |
tree | 93cc18d1a12ca9a7248cf005fe64a6c5aa67fdee /drivers/leds/leds-bd2802.c | |
parent | 8d2587970b8bdf7c8d9208e3f4bb93182aef1a0f (diff) |
leds: convert bd2802 driver to dev_pm_ops
There is a move to deprecate bus-specific PM operations and move to using
dev_pm_ops instead in order to reduce the amount of boilerplate code in
buses and facilitiate updates to the PM core. Do this move for the bs2802
driver.
[akpm@linux-foundation.org: fix warnings]
Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
Cc: Kim Kyuwon <q1.kim@samsung.com>
Cc: Kim Kyuwon <chammoru@gmail.com>
Cc: Richard Purdie <rpurdie@rpsys.net>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'drivers/leds/leds-bd2802.c')
-rw-r--r-- | drivers/leds/leds-bd2802.c | 47 |
1 files changed, 28 insertions, 19 deletions
diff --git a/drivers/leds/leds-bd2802.c b/drivers/leds/leds-bd2802.c index 19dc4b61a105..3ebe3824662d 100644 --- a/drivers/leds/leds-bd2802.c +++ b/drivers/leds/leds-bd2802.c | |||
@@ -19,7 +19,7 @@ | |||
19 | #include <linux/leds.h> | 19 | #include <linux/leds.h> |
20 | #include <linux/leds-bd2802.h> | 20 | #include <linux/leds-bd2802.h> |
21 | #include <linux/slab.h> | 21 | #include <linux/slab.h> |
22 | 22 | #include <linux/pm.h> | |
23 | 23 | ||
24 | #define LED_CTL(rgb2en, rgb1en) ((rgb2en) << 4 | ((rgb1en) << 0)) | 24 | #define LED_CTL(rgb2en, rgb1en) ((rgb2en) << 4 | ((rgb1en) << 0)) |
25 | 25 | ||
@@ -319,20 +319,6 @@ static void bd2802_turn_off(struct bd2802_led *led, enum led_ids id, | |||
319 | bd2802_update_state(led, id, color, BD2802_OFF); | 319 | bd2802_update_state(led, id, color, BD2802_OFF); |
320 | } | 320 | } |
321 | 321 | ||
322 | static void bd2802_restore_state(struct bd2802_led *led) | ||
323 | { | ||
324 | int i; | ||
325 | |||
326 | for (i = 0; i < LED_NUM; i++) { | ||
327 | if (led->led[i].r) | ||
328 | bd2802_turn_on(led, i, RED, led->led[i].r); | ||
329 | if (led->led[i].g) | ||
330 | bd2802_turn_on(led, i, GREEN, led->led[i].g); | ||
331 | if (led->led[i].b) | ||
332 | bd2802_turn_on(led, i, BLUE, led->led[i].b); | ||
333 | } | ||
334 | } | ||
335 | |||
336 | #define BD2802_SET_REGISTER(reg_addr, reg_name) \ | 322 | #define BD2802_SET_REGISTER(reg_addr, reg_name) \ |
337 | static ssize_t bd2802_store_reg##reg_addr(struct device *dev, \ | 323 | static ssize_t bd2802_store_reg##reg_addr(struct device *dev, \ |
338 | struct device_attribute *attr, const char *buf, size_t count) \ | 324 | struct device_attribute *attr, const char *buf, size_t count) \ |
@@ -761,8 +747,25 @@ static int __exit bd2802_remove(struct i2c_client *client) | |||
761 | return 0; | 747 | return 0; |
762 | } | 748 | } |
763 | 749 | ||
764 | static int bd2802_suspend(struct i2c_client *client, pm_message_t mesg) | 750 | #ifdef CONFIG_PM |
751 | |||
752 | static void bd2802_restore_state(struct bd2802_led *led) | ||
765 | { | 753 | { |
754 | int i; | ||
755 | |||
756 | for (i = 0; i < LED_NUM; i++) { | ||
757 | if (led->led[i].r) | ||
758 | bd2802_turn_on(led, i, RED, led->led[i].r); | ||
759 | if (led->led[i].g) | ||
760 | bd2802_turn_on(led, i, GREEN, led->led[i].g); | ||
761 | if (led->led[i].b) | ||
762 | bd2802_turn_on(led, i, BLUE, led->led[i].b); | ||
763 | } | ||
764 | } | ||
765 | |||
766 | static int bd2802_suspend(struct device *dev) | ||
767 | { | ||
768 | struct i2c_client *client = to_i2c_client(dev); | ||
766 | struct bd2802_led *led = i2c_get_clientdata(client); | 769 | struct bd2802_led *led = i2c_get_clientdata(client); |
767 | 770 | ||
768 | gpio_set_value(led->pdata->reset_gpio, 0); | 771 | gpio_set_value(led->pdata->reset_gpio, 0); |
@@ -770,8 +773,9 @@ static int bd2802_suspend(struct i2c_client *client, pm_message_t mesg) | |||
770 | return 0; | 773 | return 0; |
771 | } | 774 | } |
772 | 775 | ||
773 | static int bd2802_resume(struct i2c_client *client) | 776 | static int bd2802_resume(struct device *dev) |
774 | { | 777 | { |
778 | struct i2c_client *client = to_i2c_client(dev); | ||
775 | struct bd2802_led *led = i2c_get_clientdata(client); | 779 | struct bd2802_led *led = i2c_get_clientdata(client); |
776 | 780 | ||
777 | if (!bd2802_is_all_off(led) || led->adf_on) { | 781 | if (!bd2802_is_all_off(led) || led->adf_on) { |
@@ -782,6 +786,12 @@ static int bd2802_resume(struct i2c_client *client) | |||
782 | return 0; | 786 | return 0; |
783 | } | 787 | } |
784 | 788 | ||
789 | static SIMPLE_DEV_PM_OPS(bd2802_pm, bd2802_suspend, bd2802_resume); | ||
790 | #define BD2802_PM (&bd2802_pm) | ||
791 | #else /* CONFIG_PM */ | ||
792 | #define BD2802_PM NULL | ||
793 | #endif | ||
794 | |||
785 | static const struct i2c_device_id bd2802_id[] = { | 795 | static const struct i2c_device_id bd2802_id[] = { |
786 | { "BD2802", 0 }, | 796 | { "BD2802", 0 }, |
787 | { } | 797 | { } |
@@ -791,11 +801,10 @@ MODULE_DEVICE_TABLE(i2c, bd2802_id); | |||
791 | static struct i2c_driver bd2802_i2c_driver = { | 801 | static struct i2c_driver bd2802_i2c_driver = { |
792 | .driver = { | 802 | .driver = { |
793 | .name = "BD2802", | 803 | .name = "BD2802", |
804 | .pm = BD2802_PM, | ||
794 | }, | 805 | }, |
795 | .probe = bd2802_probe, | 806 | .probe = bd2802_probe, |
796 | .remove = __exit_p(bd2802_remove), | 807 | .remove = __exit_p(bd2802_remove), |
797 | .suspend = bd2802_suspend, | ||
798 | .resume = bd2802_resume, | ||
799 | .id_table = bd2802_id, | 808 | .id_table = bd2802_id, |
800 | }; | 809 | }; |
801 | 810 | ||