aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/leds
diff options
context:
space:
mode:
authorJingoo Han <jg1.han@samsung.com>2012-10-23 08:22:11 -0400
committerBryan Wu <cooloney@gmail.com>2012-11-26 17:28:46 -0500
commitf9e007fffd44ba508c0b9c62c8126eb350bcff1e (patch)
tree18e0757dc28d21589ba2e5f0c0732678852a5996 /drivers/leds
parentf87ef101056a34d69d7aa2611da0eb95ff4414f9 (diff)
leds: renesas: use devm_ functions
The devm_ functions allocate memory that is released when a driver detaches. This makes the code smaller and a bit simpler. Signed-off-by: Jingoo Han <jg1.han@samsung.com> Signed-off-by: Bryan Wu <cooloney@gmail.com>
Diffstat (limited to 'drivers/leds')
-rw-r--r--drivers/leds/leds-renesas-tpu.c17
1 files changed, 6 insertions, 11 deletions
diff --git a/drivers/leds/leds-renesas-tpu.c b/drivers/leds/leds-renesas-tpu.c
index 614776a30943..99bec6cf3306 100644
--- a/drivers/leds/leds-renesas-tpu.c
+++ b/drivers/leds/leds-renesas-tpu.c
@@ -263,18 +263,18 @@ static int __devinit r_tpu_probe(struct platform_device *pdev)
263 } 263 }
264 264
265 /* map memory, let mapbase point to our channel */ 265 /* map memory, let mapbase point to our channel */
266 p->mapbase = ioremap_nocache(res->start, resource_size(res)); 266 p->mapbase = devm_ioremap_nocache(&pdev->dev, res->start,
267 resource_size(res));
267 if (p->mapbase == NULL) { 268 if (p->mapbase == NULL) {
268 dev_err(&pdev->dev, "failed to remap I/O memory\n"); 269 dev_err(&pdev->dev, "failed to remap I/O memory\n");
269 return -ENXIO; 270 return -ENXIO;
270 } 271 }
271 272
272 /* get hold of clock */ 273 /* get hold of clock */
273 p->clk = clk_get(&pdev->dev, NULL); 274 p->clk = devm_clk_get(&pdev->dev, NULL);
274 if (IS_ERR(p->clk)) { 275 if (IS_ERR(p->clk)) {
275 dev_err(&pdev->dev, "cannot get clock\n"); 276 dev_err(&pdev->dev, "cannot get clock\n");
276 ret = PTR_ERR(p->clk); 277 return PTR_ERR(p->clk);
277 goto err0;
278 } 278 }
279 279
280 p->pdev = pdev; 280 p->pdev = pdev;
@@ -293,7 +293,7 @@ static int __devinit r_tpu_probe(struct platform_device *pdev)
293 p->ldev.flags |= LED_CORE_SUSPENDRESUME; 293 p->ldev.flags |= LED_CORE_SUSPENDRESUME;
294 ret = led_classdev_register(&pdev->dev, &p->ldev); 294 ret = led_classdev_register(&pdev->dev, &p->ldev);
295 if (ret < 0) 295 if (ret < 0)
296 goto err1; 296 goto err0;
297 297
298 /* max_brightness may be updated by the LED core code */ 298 /* max_brightness may be updated by the LED core code */
299 p->min_rate = p->ldev.max_brightness * p->refresh_rate; 299 p->min_rate = p->ldev.max_brightness * p->refresh_rate;
@@ -301,11 +301,8 @@ static int __devinit r_tpu_probe(struct platform_device *pdev)
301 pm_runtime_enable(&pdev->dev); 301 pm_runtime_enable(&pdev->dev);
302 return 0; 302 return 0;
303 303
304 err1:
305 r_tpu_set_pin(p, R_TPU_PIN_UNUSED, LED_OFF);
306 clk_put(p->clk);
307 err0: 304 err0:
308 iounmap(p->mapbase); 305 r_tpu_set_pin(p, R_TPU_PIN_UNUSED, LED_OFF);
309 return ret; 306 return ret;
310} 307}
311 308
@@ -320,9 +317,7 @@ static int __devexit r_tpu_remove(struct platform_device *pdev)
320 r_tpu_set_pin(p, R_TPU_PIN_UNUSED, LED_OFF); 317 r_tpu_set_pin(p, R_TPU_PIN_UNUSED, LED_OFF);
321 318
322 pm_runtime_disable(&pdev->dev); 319 pm_runtime_disable(&pdev->dev);
323 clk_put(p->clk);
324 320
325 iounmap(p->mapbase);
326 return 0; 321 return 0;
327} 322}
328 323