diff options
author | Milo(Woogyom) Kim <milo.kim@ti.com> | 2013-02-05 05:03:02 -0500 |
---|---|---|
committer | Bryan Wu <cooloney@gmail.com> | 2013-02-06 18:59:27 -0500 |
commit | 6ce6176263393dd80b9a537c1e1462b8529f240b (patch) | |
tree | 9e96351d63c51119625d09d0f3df61376c803367 /drivers/leds | |
parent | 22ebeb488b3dbbb64b81146b366551107ae34af8 (diff) |
leds-lp55xx: use lp55xx common deinit function
Two separate de-init functions are merged into one common function.
And it is used in err_post_init of lp55xx_init_device().
Signed-off-by: Milo(Woogyom) Kim <milo.kim@ti.com>
Signed-off-by: Bryan Wu <cooloney@gmail.com>
Diffstat (limited to 'drivers/leds')
-rw-r--r-- | drivers/leds/leds-lp5521.c | 16 | ||||
-rw-r--r-- | drivers/leds/leds-lp5523.c | 16 | ||||
-rw-r--r-- | drivers/leds/leds-lp55xx-common.c | 15 | ||||
-rw-r--r-- | drivers/leds/leds-lp55xx-common.h | 3 |
4 files changed, 22 insertions, 28 deletions
diff --git a/drivers/leds/leds-lp5521.c b/drivers/leds/leds-lp5521.c index 74dc208fb99f..dd4526e168fa 100644 --- a/drivers/leds/leds-lp5521.c +++ b/drivers/leds/leds-lp5521.c | |||
@@ -689,16 +689,6 @@ static void lp5521_unregister_sysfs(struct i2c_client *client) | |||
689 | &lp5521_led_attribute_group); | 689 | &lp5521_led_attribute_group); |
690 | } | 690 | } |
691 | 691 | ||
692 | static void lp5521_deinit_device(struct lp5521_chip *chip) | ||
693 | { | ||
694 | struct lp5521_platform_data *pdata = chip->pdata; | ||
695 | |||
696 | if (pdata->enable) | ||
697 | pdata->enable(0); | ||
698 | if (pdata->release_resources) | ||
699 | pdata->release_resources(); | ||
700 | } | ||
701 | |||
702 | static int lp5521_init_led(struct lp5521_led *led, | 692 | static int lp5521_init_led(struct lp5521_led *led, |
703 | struct i2c_client *client, | 693 | struct i2c_client *client, |
704 | int chan, struct lp5521_platform_data *pdata) | 694 | int chan, struct lp5521_platform_data *pdata) |
@@ -858,7 +848,7 @@ static int lp5521_probe(struct i2c_client *client, | |||
858 | return ret; | 848 | return ret; |
859 | fail2: | 849 | fail2: |
860 | lp5521_unregister_leds(old_chip); | 850 | lp5521_unregister_leds(old_chip); |
861 | lp5521_deinit_device(old_chip); | 851 | lp55xx_deinit_device(chip); |
862 | err_init: | 852 | err_init: |
863 | return ret; | 853 | return ret; |
864 | } | 854 | } |
@@ -866,13 +856,15 @@ err_init: | |||
866 | static int lp5521_remove(struct i2c_client *client) | 856 | static int lp5521_remove(struct i2c_client *client) |
867 | { | 857 | { |
868 | struct lp5521_chip *old_chip = i2c_get_clientdata(client); | 858 | struct lp5521_chip *old_chip = i2c_get_clientdata(client); |
859 | struct lp55xx_led *led = i2c_get_clientdata(client); | ||
860 | struct lp55xx_chip *chip = led->chip; | ||
869 | 861 | ||
870 | lp5521_run_led_pattern(PATTERN_OFF, old_chip); | 862 | lp5521_run_led_pattern(PATTERN_OFF, old_chip); |
871 | lp5521_unregister_sysfs(client); | 863 | lp5521_unregister_sysfs(client); |
872 | 864 | ||
873 | lp5521_unregister_leds(old_chip); | 865 | lp5521_unregister_leds(old_chip); |
866 | lp55xx_deinit_device(chip); | ||
874 | 867 | ||
875 | lp5521_deinit_device(old_chip); | ||
876 | return 0; | 868 | return 0; |
877 | } | 869 | } |
878 | 870 | ||
diff --git a/drivers/leds/leds-lp5523.c b/drivers/leds/leds-lp5523.c index 80b7fb4a3ad6..3f506e3d4986 100644 --- a/drivers/leds/leds-lp5523.c +++ b/drivers/leds/leds-lp5523.c | |||
@@ -872,16 +872,6 @@ static void lp5523_unregister_leds(struct lp5523_chip *chip) | |||
872 | } | 872 | } |
873 | } | 873 | } |
874 | 874 | ||
875 | static void lp5523_deinit_device(struct lp5523_chip *chip) | ||
876 | { | ||
877 | struct lp5523_platform_data *pdata = chip->pdata; | ||
878 | |||
879 | if (pdata->enable) | ||
880 | pdata->enable(0); | ||
881 | if (pdata->release_resources) | ||
882 | pdata->release_resources(); | ||
883 | } | ||
884 | |||
885 | /* Chip specific configurations */ | 875 | /* Chip specific configurations */ |
886 | static struct lp55xx_device_config lp5523_cfg = { | 876 | static struct lp55xx_device_config lp5523_cfg = { |
887 | .reset = { | 877 | .reset = { |
@@ -944,7 +934,7 @@ static int lp5523_probe(struct i2c_client *client, | |||
944 | return ret; | 934 | return ret; |
945 | fail2: | 935 | fail2: |
946 | lp5523_unregister_leds(old_chip); | 936 | lp5523_unregister_leds(old_chip); |
947 | lp5523_deinit_device(old_chip); | 937 | lp55xx_deinit_device(chip); |
948 | err_init: | 938 | err_init: |
949 | return ret; | 939 | return ret; |
950 | } | 940 | } |
@@ -952,6 +942,8 @@ err_init: | |||
952 | static int lp5523_remove(struct i2c_client *client) | 942 | static int lp5523_remove(struct i2c_client *client) |
953 | { | 943 | { |
954 | struct lp5523_chip *old_chip = i2c_get_clientdata(client); | 944 | struct lp5523_chip *old_chip = i2c_get_clientdata(client); |
945 | struct lp55xx_led *led = i2c_get_clientdata(client); | ||
946 | struct lp55xx_chip *chip = led->chip; | ||
955 | 947 | ||
956 | /* Disable engine mode */ | 948 | /* Disable engine mode */ |
957 | lp5523_write(client, LP5523_REG_OP_MODE, LP5523_CMD_DISABLED); | 949 | lp5523_write(client, LP5523_REG_OP_MODE, LP5523_CMD_DISABLED); |
@@ -959,8 +951,8 @@ static int lp5523_remove(struct i2c_client *client) | |||
959 | lp5523_unregister_sysfs(client); | 951 | lp5523_unregister_sysfs(client); |
960 | 952 | ||
961 | lp5523_unregister_leds(old_chip); | 953 | lp5523_unregister_leds(old_chip); |
954 | lp55xx_deinit_device(chip); | ||
962 | 955 | ||
963 | lp5523_deinit_device(old_chip); | ||
964 | return 0; | 956 | return 0; |
965 | } | 957 | } |
966 | 958 | ||
diff --git a/drivers/leds/leds-lp55xx-common.c b/drivers/leds/leds-lp55xx-common.c index c06745f160c3..bcabf2cb949a 100644 --- a/drivers/leds/leds-lp55xx-common.c +++ b/drivers/leds/leds-lp55xx-common.c | |||
@@ -152,14 +152,23 @@ int lp55xx_init_device(struct lp55xx_chip *chip) | |||
152 | return 0; | 152 | return 0; |
153 | 153 | ||
154 | err_post_init: | 154 | err_post_init: |
155 | lp55xx_deinit_device(chip); | ||
156 | err: | ||
157 | return ret; | ||
158 | } | ||
159 | EXPORT_SYMBOL_GPL(lp55xx_init_device); | ||
160 | |||
161 | void lp55xx_deinit_device(struct lp55xx_chip *chip) | ||
162 | { | ||
163 | struct lp55xx_platform_data *pdata = chip->pdata; | ||
164 | |||
155 | if (pdata->enable) | 165 | if (pdata->enable) |
156 | pdata->enable(0); | 166 | pdata->enable(0); |
167 | |||
157 | if (pdata->release_resources) | 168 | if (pdata->release_resources) |
158 | pdata->release_resources(); | 169 | pdata->release_resources(); |
159 | err: | ||
160 | return ret; | ||
161 | } | 170 | } |
162 | EXPORT_SYMBOL_GPL(lp55xx_init_device); | 171 | EXPORT_SYMBOL_GPL(lp55xx_deinit_device); |
163 | 172 | ||
164 | MODULE_AUTHOR("Milo Kim <milo.kim@ti.com>"); | 173 | MODULE_AUTHOR("Milo Kim <milo.kim@ti.com>"); |
165 | MODULE_DESCRIPTION("LP55xx Common Driver"); | 174 | MODULE_DESCRIPTION("LP55xx Common Driver"); |
diff --git a/drivers/leds/leds-lp55xx-common.h b/drivers/leds/leds-lp55xx-common.h index ffedc7723d84..908b00a56b7e 100644 --- a/drivers/leds/leds-lp55xx-common.h +++ b/drivers/leds/leds-lp55xx-common.h | |||
@@ -84,7 +84,8 @@ extern int lp55xx_read(struct lp55xx_chip *chip, u8 reg, u8 *val); | |||
84 | extern int lp55xx_update_bits(struct lp55xx_chip *chip, u8 reg, | 84 | extern int lp55xx_update_bits(struct lp55xx_chip *chip, u8 reg, |
85 | u8 mask, u8 val); | 85 | u8 mask, u8 val); |
86 | 86 | ||
87 | /* common device init functions */ | 87 | /* common device init/deinit functions */ |
88 | extern int lp55xx_init_device(struct lp55xx_chip *chip); | 88 | extern int lp55xx_init_device(struct lp55xx_chip *chip); |
89 | extern void lp55xx_deinit_device(struct lp55xx_chip *chip); | ||
89 | 90 | ||
90 | #endif /* _LEDS_LP55XX_COMMON_H */ | 91 | #endif /* _LEDS_LP55XX_COMMON_H */ |