aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/leds
diff options
context:
space:
mode:
authorBryan Wu <bryan.wu@canonical.com>2012-07-03 23:16:09 -0400
committerBryan Wu <bryan.wu@canonical.com>2012-07-23 19:52:37 -0400
commite430dc003f023f3f5244418aa26cc64e78ab8b6e (patch)
tree8ee653d0279687dd348b0903f1598c808632b889 /drivers/leds
parentbad1c898e8b70c644c6542f79802326cc7b11c77 (diff)
leds: convert LP5521 LED driver to devm_kzalloc() and cleanup error exit path
Signed-off-by: Bryan Wu <bryan.wu@canonical.com>
Diffstat (limited to 'drivers/leds')
-rw-r--r--drivers/leds/leds-lp5521.c20
1 files changed, 8 insertions, 12 deletions
diff --git a/drivers/leds/leds-lp5521.c b/drivers/leds/leds-lp5521.c
index 23815624f35e..2064aefedc07 100644
--- a/drivers/leds/leds-lp5521.c
+++ b/drivers/leds/leds-lp5521.c
@@ -744,7 +744,7 @@ static int __devinit lp5521_probe(struct i2c_client *client,
744 int ret, i, led; 744 int ret, i, led;
745 u8 buf; 745 u8 buf;
746 746
747 chip = kzalloc(sizeof(*chip), GFP_KERNEL); 747 chip = devm_kzalloc(&client->dev, sizeof(*chip), GFP_KERNEL);
748 if (!chip) 748 if (!chip)
749 return -ENOMEM; 749 return -ENOMEM;
750 750
@@ -755,8 +755,7 @@ static int __devinit lp5521_probe(struct i2c_client *client,
755 755
756 if (!pdata) { 756 if (!pdata) {
757 dev_err(&client->dev, "no platform data\n"); 757 dev_err(&client->dev, "no platform data\n");
758 ret = -EINVAL; 758 return -EINVAL;
759 goto fail1;
760 } 759 }
761 760
762 mutex_init(&chip->lock); 761 mutex_init(&chip->lock);
@@ -766,7 +765,7 @@ static int __devinit lp5521_probe(struct i2c_client *client,
766 if (pdata->setup_resources) { 765 if (pdata->setup_resources) {
767 ret = pdata->setup_resources(); 766 ret = pdata->setup_resources();
768 if (ret < 0) 767 if (ret < 0)
769 goto fail1; 768 return ret;
770 } 769 }
771 770
772 if (pdata->enable) { 771 if (pdata->enable) {
@@ -807,7 +806,7 @@ static int __devinit lp5521_probe(struct i2c_client *client,
807 ret = lp5521_configure(client); 806 ret = lp5521_configure(client);
808 if (ret < 0) { 807 if (ret < 0) {
809 dev_err(&client->dev, "error configuring chip\n"); 808 dev_err(&client->dev, "error configuring chip\n");
810 goto fail2; 809 goto fail1;
811 } 810 }
812 811
813 /* Initialize leds */ 812 /* Initialize leds */
@@ -822,7 +821,7 @@ static int __devinit lp5521_probe(struct i2c_client *client,
822 ret = lp5521_init_led(&chip->leds[led], client, i, pdata); 821 ret = lp5521_init_led(&chip->leds[led], client, i, pdata);
823 if (ret) { 822 if (ret) {
824 dev_err(&client->dev, "error initializing leds\n"); 823 dev_err(&client->dev, "error initializing leds\n");
825 goto fail3; 824 goto fail2;
826 } 825 }
827 chip->num_leds++; 826 chip->num_leds++;
828 827
@@ -840,21 +839,19 @@ static int __devinit lp5521_probe(struct i2c_client *client,
840 ret = lp5521_register_sysfs(client); 839 ret = lp5521_register_sysfs(client);
841 if (ret) { 840 if (ret) {
842 dev_err(&client->dev, "registering sysfs failed\n"); 841 dev_err(&client->dev, "registering sysfs failed\n");
843 goto fail3; 842 goto fail2;
844 } 843 }
845 return ret; 844 return ret;
846fail3: 845fail2:
847 for (i = 0; i < chip->num_leds; i++) { 846 for (i = 0; i < chip->num_leds; i++) {
848 led_classdev_unregister(&chip->leds[i].cdev); 847 led_classdev_unregister(&chip->leds[i].cdev);
849 cancel_work_sync(&chip->leds[i].brightness_work); 848 cancel_work_sync(&chip->leds[i].brightness_work);
850 } 849 }
851fail2: 850fail1:
852 if (pdata->enable) 851 if (pdata->enable)
853 pdata->enable(0); 852 pdata->enable(0);
854 if (pdata->release_resources) 853 if (pdata->release_resources)
855 pdata->release_resources(); 854 pdata->release_resources();
856fail1:
857 kfree(chip);
858 return ret; 855 return ret;
859} 856}
860 857
@@ -875,7 +872,6 @@ static int __devexit lp5521_remove(struct i2c_client *client)
875 chip->pdata->enable(0); 872 chip->pdata->enable(0);
876 if (chip->pdata->release_resources) 873 if (chip->pdata->release_resources)
877 chip->pdata->release_resources(); 874 chip->pdata->release_resources();
878 kfree(chip);
879 return 0; 875 return 0;
880} 876}
881 877