aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/clocksource
diff options
context:
space:
mode:
authorLaurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>2013-07-30 10:24:37 -0400
committerDaniel Lezcano <daniel.lezcano@linaro.org>2013-08-21 18:18:42 -0400
commit1745e696e174b54e37c057882970e50af1e80a7f (patch)
tree12f69068646b9deec2ef0a3b41d46b12b2dd46cc /drivers/clocksource
parentcfb6d656d569510ac9239583ce09e4c92ad54719 (diff)
clocksource: em_sti: Convert to devm_* managed helpers
Replace kzalloc, clk_get, ioremap and request_irq by their managed counterparts to simplify error paths. Signed-off-by: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com> Reviewed-by: Daniel Lezcano <daniel.lezcano@linaro.org>
Diffstat (limited to 'drivers/clocksource')
-rw-r--r--drivers/clocksource/em_sti.c49
1 files changed, 14 insertions, 35 deletions
diff --git a/drivers/clocksource/em_sti.c b/drivers/clocksource/em_sti.c
index 4329a29a5310..b9c81b7c3a3b 100644
--- a/drivers/clocksource/em_sti.c
+++ b/drivers/clocksource/em_sti.c
@@ -315,68 +315,47 @@ static int em_sti_probe(struct platform_device *pdev)
315{ 315{
316 struct em_sti_priv *p; 316 struct em_sti_priv *p;
317 struct resource *res; 317 struct resource *res;
318 int irq, ret; 318 int irq;
319 319
320 p = kzalloc(sizeof(*p), GFP_KERNEL); 320 p = devm_kzalloc(&pdev->dev, sizeof(*p), GFP_KERNEL);
321 if (p == NULL) { 321 if (p == NULL) {
322 dev_err(&pdev->dev, "failed to allocate driver data\n"); 322 dev_err(&pdev->dev, "failed to allocate driver data\n");
323 ret = -ENOMEM; 323 return -ENOMEM;
324 goto err0;
325 } 324 }
326 325
327 p->pdev = pdev; 326 p->pdev = pdev;
328 platform_set_drvdata(pdev, p); 327 platform_set_drvdata(pdev, p);
329 328
330 res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
331 if (!res) {
332 dev_err(&pdev->dev, "failed to get I/O memory\n");
333 ret = -EINVAL;
334 goto err0;
335 }
336
337 irq = platform_get_irq(pdev, 0); 329 irq = platform_get_irq(pdev, 0);
338 if (irq < 0) { 330 if (irq < 0) {
339 dev_err(&pdev->dev, "failed to get irq\n"); 331 dev_err(&pdev->dev, "failed to get irq\n");
340 ret = -EINVAL; 332 return -EINVAL;
341 goto err0;
342 } 333 }
343 334
344 /* map memory, let base point to the STI instance */ 335 /* map memory, let base point to the STI instance */
345 p->base = ioremap_nocache(res->start, resource_size(res)); 336 res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
346 if (p->base == NULL) { 337 p->base = devm_ioremap_resource(&pdev->dev, res);
347 dev_err(&pdev->dev, "failed to remap I/O memory\n"); 338 if (IS_ERR(p->base))
348 ret = -ENXIO; 339 return PTR_ERR(p->base);
349 goto err0;
350 }
351 340
352 /* get hold of clock */ 341 /* get hold of clock */
353 p->clk = clk_get(&pdev->dev, "sclk"); 342 p->clk = devm_clk_get(&pdev->dev, "sclk");
354 if (IS_ERR(p->clk)) { 343 if (IS_ERR(p->clk)) {
355 dev_err(&pdev->dev, "cannot get clock\n"); 344 dev_err(&pdev->dev, "cannot get clock\n");
356 ret = PTR_ERR(p->clk); 345 return PTR_ERR(p->clk);
357 goto err1;
358 } 346 }
359 347
360 if (request_irq(irq, em_sti_interrupt, 348 if (devm_request_irq(&pdev->dev, irq, em_sti_interrupt,
361 IRQF_TIMER | IRQF_IRQPOLL | IRQF_NOBALANCING, 349 IRQF_TIMER | IRQF_IRQPOLL | IRQF_NOBALANCING,
362 dev_name(&pdev->dev), p)) { 350 dev_name(&pdev->dev), p)) {
363 dev_err(&pdev->dev, "failed to request low IRQ\n"); 351 dev_err(&pdev->dev, "failed to request low IRQ\n");
364 ret = -ENOENT; 352 return -ENOENT;
365 goto err2;
366 } 353 }
367 354
368 raw_spin_lock_init(&p->lock); 355 raw_spin_lock_init(&p->lock);
369 em_sti_register_clockevent(p); 356 em_sti_register_clockevent(p);
370 em_sti_register_clocksource(p); 357 em_sti_register_clocksource(p);
371 return 0; 358 return 0;
372
373err2:
374 clk_put(p->clk);
375err1:
376 iounmap(p->base);
377err0:
378 kfree(p);
379 return ret;
380} 359}
381 360
382static int em_sti_remove(struct platform_device *pdev) 361static int em_sti_remove(struct platform_device *pdev)