aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/leds
diff options
context:
space:
mode:
authorBryan Wu <bryan.wu@canonical.com>2012-07-03 23:44:18 -0400
committerBryan Wu <bryan.wu@canonical.com>2012-07-23 19:52:38 -0400
commit94ca4bccac0f4cc521148134895498826a63aa2a (patch)
tree0408d0841640cdc91aa8ede083d11d3f2ad554ee /drivers/leds
parent983ce8840c9cbafefd568f6973e531d77119a977 (diff)
leds: convert LP5523 LED driver to devm_kzalloc() and cleanup error exit path
Cc: Mathias Nyman <mathias.nyman@nokia.com> Signed-off-by: Bryan Wu <bryan.wu@canonical.com>
Diffstat (limited to 'drivers/leds')
-rw-r--r--drivers/leds/leds-lp5523.c24
1 files changed, 10 insertions, 14 deletions
diff --git a/drivers/leds/leds-lp5523.c b/drivers/leds/leds-lp5523.c
index e8a271232cd0..fbc12acada95 100644
--- a/drivers/leds/leds-lp5523.c
+++ b/drivers/leds/leds-lp5523.c
@@ -877,7 +877,7 @@ static int __devinit lp5523_probe(struct i2c_client *client,
877 struct lp5523_platform_data *pdata; 877 struct lp5523_platform_data *pdata;
878 int ret, i, led; 878 int ret, i, led;
879 879
880 chip = kzalloc(sizeof(*chip), GFP_KERNEL); 880 chip = devm_kzalloc(&client->dev, sizeof(*chip), GFP_KERNEL);
881 if (!chip) 881 if (!chip)
882 return -ENOMEM; 882 return -ENOMEM;
883 883
@@ -888,8 +888,7 @@ static int __devinit lp5523_probe(struct i2c_client *client,
888 888
889 if (!pdata) { 889 if (!pdata) {
890 dev_err(&client->dev, "no platform data\n"); 890 dev_err(&client->dev, "no platform data\n");
891 ret = -EINVAL; 891 return -EINVAL;
892 goto fail1;
893 } 892 }
894 893
895 mutex_init(&chip->lock); 894 mutex_init(&chip->lock);
@@ -899,7 +898,7 @@ static int __devinit lp5523_probe(struct i2c_client *client,
899 if (pdata->setup_resources) { 898 if (pdata->setup_resources) {
900 ret = pdata->setup_resources(); 899 ret = pdata->setup_resources();
901 if (ret < 0) 900 if (ret < 0)
902 goto fail1; 901 return ret;
903 } 902 }
904 903
905 if (pdata->enable) { 904 if (pdata->enable) {
@@ -916,7 +915,7 @@ static int __devinit lp5523_probe(struct i2c_client *client,
916 */ 915 */
917 ret = lp5523_detect(client); 916 ret = lp5523_detect(client);
918 if (ret) 917 if (ret)
919 goto fail2; 918 goto fail1;
920 919
921 dev_info(&client->dev, "LP5523 Programmable led chip found\n"); 920 dev_info(&client->dev, "LP5523 Programmable led chip found\n");
922 921
@@ -925,13 +924,13 @@ static int __devinit lp5523_probe(struct i2c_client *client,
925 ret = lp5523_init_engine(&chip->engines[i], i + 1); 924 ret = lp5523_init_engine(&chip->engines[i], i + 1);
926 if (ret) { 925 if (ret) {
927 dev_err(&client->dev, "error initializing engine\n"); 926 dev_err(&client->dev, "error initializing engine\n");
928 goto fail2; 927 goto fail1;
929 } 928 }
930 } 929 }
931 ret = lp5523_configure(client); 930 ret = lp5523_configure(client);
932 if (ret < 0) { 931 if (ret < 0) {
933 dev_err(&client->dev, "error configuring chip\n"); 932 dev_err(&client->dev, "error configuring chip\n");
934 goto fail2; 933 goto fail1;
935 } 934 }
936 935
937 /* Initialize leds */ 936 /* Initialize leds */
@@ -949,7 +948,7 @@ static int __devinit lp5523_probe(struct i2c_client *client,
949 ret = lp5523_init_led(&chip->leds[led], &client->dev, i, pdata); 948 ret = lp5523_init_led(&chip->leds[led], &client->dev, i, pdata);
950 if (ret) { 949 if (ret) {
951 dev_err(&client->dev, "error initializing leds\n"); 950 dev_err(&client->dev, "error initializing leds\n");
952 goto fail3; 951 goto fail2;
953 } 952 }
954 chip->num_leds++; 953 chip->num_leds++;
955 954
@@ -965,21 +964,19 @@ static int __devinit lp5523_probe(struct i2c_client *client,
965 ret = lp5523_register_sysfs(client); 964 ret = lp5523_register_sysfs(client);
966 if (ret) { 965 if (ret) {
967 dev_err(&client->dev, "registering sysfs failed\n"); 966 dev_err(&client->dev, "registering sysfs failed\n");
968 goto fail3; 967 goto fail2;
969 } 968 }
970 return ret; 969 return ret;
971fail3: 970fail2:
972 for (i = 0; i < chip->num_leds; i++) { 971 for (i = 0; i < chip->num_leds; i++) {
973 led_classdev_unregister(&chip->leds[i].cdev); 972 led_classdev_unregister(&chip->leds[i].cdev);
974 cancel_work_sync(&chip->leds[i].brightness_work); 973 cancel_work_sync(&chip->leds[i].brightness_work);
975 } 974 }
976fail2: 975fail1:
977 if (pdata->enable) 976 if (pdata->enable)
978 pdata->enable(0); 977 pdata->enable(0);
979 if (pdata->release_resources) 978 if (pdata->release_resources)
980 pdata->release_resources(); 979 pdata->release_resources();
981fail1:
982 kfree(chip);
983 return ret; 980 return ret;
984} 981}
985 982
@@ -999,7 +996,6 @@ static int lp5523_remove(struct i2c_client *client)
999 chip->pdata->enable(0); 996 chip->pdata->enable(0);
1000 if (chip->pdata->release_resources) 997 if (chip->pdata->release_resources)
1001 chip->pdata->release_resources(); 998 chip->pdata->release_resources();
1002 kfree(chip);
1003 return 0; 999 return 0;
1004} 1000}
1005 1001