aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/leds
diff options
context:
space:
mode:
authorBryan Wu <bryan.wu@canonical.com>2012-07-04 00:11:40 -0400
committerBryan Wu <bryan.wu@canonical.com>2012-07-23 19:52:39 -0400
commitbcbf01624f8e551d2c3c13a2b0c394fb270fd774 (patch)
tree09694b0aa9e7bbd9636e27d72ce5cea3f8bc551c /drivers/leds
parent73759f6ab3620d605a5ce07d5316df1abb7edf18 (diff)
leds: convert ADP5520 LED driver to devm_kzalloc() and cleanup error exit path
Cc: Michael Hennerich <hennerich@blackfin.uclinux.org> Signed-off-by: Bryan Wu <bryan.wu@canonical.com>
Diffstat (limited to 'drivers/leds')
-rw-r--r--drivers/leds/leds-adp5520.c8
1 files changed, 3 insertions, 5 deletions
diff --git a/drivers/leds/leds-adp5520.c b/drivers/leds/leds-adp5520.c
index b1400db3f83..aa56a867693 100644
--- a/drivers/leds/leds-adp5520.c
+++ b/drivers/leds/leds-adp5520.c
@@ -119,7 +119,8 @@ static int __devinit adp5520_led_probe(struct platform_device *pdev)
119 return -EFAULT; 119 return -EFAULT;
120 } 120 }
121 121
122 led = kzalloc(sizeof(*led) * pdata->num_leds, GFP_KERNEL); 122 led = devm_kzalloc(&pdev->dev, sizeof(*led) * pdata->num_leds,
123 GFP_KERNEL);
123 if (led == NULL) { 124 if (led == NULL) {
124 dev_err(&pdev->dev, "failed to alloc memory\n"); 125 dev_err(&pdev->dev, "failed to alloc memory\n");
125 return -ENOMEM; 126 return -ENOMEM;
@@ -129,7 +130,7 @@ static int __devinit adp5520_led_probe(struct platform_device *pdev)
129 130
130 if (ret) { 131 if (ret) {
131 dev_err(&pdev->dev, "failed to write\n"); 132 dev_err(&pdev->dev, "failed to write\n");
132 goto err_free; 133 return ret;
133 } 134 }
134 135
135 for (i = 0; i < pdata->num_leds; ++i) { 136 for (i = 0; i < pdata->num_leds; ++i) {
@@ -179,8 +180,6 @@ err:
179 } 180 }
180 } 181 }
181 182
182err_free:
183 kfree(led);
184 return ret; 183 return ret;
185} 184}
186 185
@@ -200,7 +199,6 @@ static int __devexit adp5520_led_remove(struct platform_device *pdev)
200 cancel_work_sync(&led[i].work); 199 cancel_work_sync(&led[i].work);
201 } 200 }
202 201
203 kfree(led);
204 return 0; 202 return 0;
205} 203}
206 204