aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authorBryan Wu <bryan.wu@canonical.com>2012-07-03 23:48:57 -0400
committerBryan Wu <bryan.wu@canonical.com>2012-07-23 19:52:38 -0400
commitbfe4c0419397ffe33ed7accf1729a95737e7ee9e (patch)
treedb9fe6ad04be1a0bc12c118118f593dcabfa0056 /drivers
parent94ca4bccac0f4cc521148134895498826a63aa2a (diff)
leds: convert Renesas TPU LED driver to devm_kzalloc() and cleanup error exit path
Cc: Magnus Damm <damm@opensource.se> Signed-off-by: Bryan Wu <bryan.wu@canonical.com>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/leds/leds-renesas-tpu.c23
1 files changed, 9 insertions, 14 deletions
diff --git a/drivers/leds/leds-renesas-tpu.c b/drivers/leds/leds-renesas-tpu.c
index 32fe337d5c68..9ee12c28059a 100644
--- a/drivers/leds/leds-renesas-tpu.c
+++ b/drivers/leds/leds-renesas-tpu.c
@@ -243,31 +243,30 @@ static int __devinit r_tpu_probe(struct platform_device *pdev)
243 struct led_renesas_tpu_config *cfg = pdev->dev.platform_data; 243 struct led_renesas_tpu_config *cfg = pdev->dev.platform_data;
244 struct r_tpu_priv *p; 244 struct r_tpu_priv *p;
245 struct resource *res; 245 struct resource *res;
246 int ret = -ENXIO; 246 int ret;
247 247
248 if (!cfg) { 248 if (!cfg) {
249 dev_err(&pdev->dev, "missing platform data\n"); 249 dev_err(&pdev->dev, "missing platform data\n");
250 goto err0; 250 goto err0;
251 } 251 }
252 252
253 p = kzalloc(sizeof(*p), GFP_KERNEL); 253 p = devm_kzalloc(&pdev->dev, sizeof(*p), GFP_KERNEL);
254 if (p == NULL) { 254 if (p == NULL) {
255 dev_err(&pdev->dev, "failed to allocate driver data\n"); 255 dev_err(&pdev->dev, "failed to allocate driver data\n");
256 ret = -ENOMEM; 256 return -ENOMEM;
257 goto err0;
258 } 257 }
259 258
260 res = platform_get_resource(pdev, IORESOURCE_MEM, 0); 259 res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
261 if (!res) { 260 if (!res) {
262 dev_err(&pdev->dev, "failed to get I/O memory\n"); 261 dev_err(&pdev->dev, "failed to get I/O memory\n");
263 goto err1; 262 return -ENXIO;
264 } 263 }
265 264
266 /* map memory, let mapbase point to our channel */ 265 /* map memory, let mapbase point to our channel */
267 p->mapbase = ioremap_nocache(res->start, resource_size(res)); 266 p->mapbase = ioremap_nocache(res->start, resource_size(res));
268 if (p->mapbase == NULL) { 267 if (p->mapbase == NULL) {
269 dev_err(&pdev->dev, "failed to remap I/O memory\n"); 268 dev_err(&pdev->dev, "failed to remap I/O memory\n");
270 goto err1; 269 return -ENXIO;
271 } 270 }
272 271
273 /* get hold of clock */ 272 /* get hold of clock */
@@ -275,7 +274,7 @@ static int __devinit r_tpu_probe(struct platform_device *pdev)
275 if (IS_ERR(p->clk)) { 274 if (IS_ERR(p->clk)) {
276 dev_err(&pdev->dev, "cannot get clock\n"); 275 dev_err(&pdev->dev, "cannot get clock\n");
277 ret = PTR_ERR(p->clk); 276 ret = PTR_ERR(p->clk);
278 goto err2; 277 goto err0;
279 } 278 }
280 279
281 p->pdev = pdev; 280 p->pdev = pdev;
@@ -294,7 +293,7 @@ static int __devinit r_tpu_probe(struct platform_device *pdev)
294 p->ldev.flags |= LED_CORE_SUSPENDRESUME; 293 p->ldev.flags |= LED_CORE_SUSPENDRESUME;
295 ret = led_classdev_register(&pdev->dev, &p->ldev); 294 ret = led_classdev_register(&pdev->dev, &p->ldev);
296 if (ret < 0) 295 if (ret < 0)
297 goto err3; 296 goto err1;
298 297
299 /* max_brightness may be updated by the LED core code */ 298 /* max_brightness may be updated by the LED core code */
300 p->min_rate = p->ldev.max_brightness * p->refresh_rate; 299 p->min_rate = p->ldev.max_brightness * p->refresh_rate;
@@ -302,14 +301,11 @@ static int __devinit r_tpu_probe(struct platform_device *pdev)
302 pm_runtime_enable(&pdev->dev); 301 pm_runtime_enable(&pdev->dev);
303 return 0; 302 return 0;
304 303
305 err3: 304 err1:
306 r_tpu_set_pin(p, R_TPU_PIN_UNUSED, LED_OFF); 305 r_tpu_set_pin(p, R_TPU_PIN_UNUSED, LED_OFF);
307 clk_put(p->clk); 306 clk_put(p->clk);
308 err2:
309 iounmap(p->mapbase);
310 err1:
311 kfree(p);
312 err0: 307 err0:
308 iounmap(p->mapbase);
313 return ret; 309 return ret;
314} 310}
315 311
@@ -327,7 +323,6 @@ static int __devexit r_tpu_remove(struct platform_device *pdev)
327 clk_put(p->clk); 323 clk_put(p->clk);
328 324
329 iounmap(p->mapbase); 325 iounmap(p->mapbase);
330 kfree(p);
331 return 0; 326 return 0;
332} 327}
333 328