diff options
author | Jingoo Han <jg1.han@samsung.com> | 2013-07-03 18:07:09 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2013-07-03 19:07:55 -0400 |
commit | 618c300305c6ee7c71a1493da97c48c24205268c (patch) | |
tree | 594713bf21e7be0dad784e10c1c4c1c657d7d6cc /drivers/rtc/rtc-pxa.c | |
parent | c417299ce7d77521225f2aff471d3f7ee5f34b1e (diff) |
rtc: rtc-pxa: use devm_*() functions
Use devm_*() functions to make cleanup paths simpler.
Signed-off-by: Jingoo Han <jg1.han@samsung.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'drivers/rtc/rtc-pxa.c')
-rw-r--r-- | drivers/rtc/rtc-pxa.c | 43 |
1 files changed, 12 insertions, 31 deletions
diff --git a/drivers/rtc/rtc-pxa.c b/drivers/rtc/rtc-pxa.c index ed037ae91c5f..a355f2b82bb8 100644 --- a/drivers/rtc/rtc-pxa.c +++ b/drivers/rtc/rtc-pxa.c | |||
@@ -324,37 +324,35 @@ static int __init pxa_rtc_probe(struct platform_device *pdev) | |||
324 | int ret; | 324 | int ret; |
325 | u32 rttr; | 325 | u32 rttr; |
326 | 326 | ||
327 | pxa_rtc = kzalloc(sizeof(struct pxa_rtc), GFP_KERNEL); | 327 | pxa_rtc = devm_kzalloc(dev, sizeof(*pxa_rtc), GFP_KERNEL); |
328 | if (!pxa_rtc) | 328 | if (!pxa_rtc) |
329 | return -ENOMEM; | 329 | return -ENOMEM; |
330 | 330 | ||
331 | spin_lock_init(&pxa_rtc->lock); | 331 | spin_lock_init(&pxa_rtc->lock); |
332 | platform_set_drvdata(pdev, pxa_rtc); | 332 | platform_set_drvdata(pdev, pxa_rtc); |
333 | 333 | ||
334 | ret = -ENXIO; | ||
335 | pxa_rtc->ress = platform_get_resource(pdev, IORESOURCE_MEM, 0); | 334 | pxa_rtc->ress = platform_get_resource(pdev, IORESOURCE_MEM, 0); |
336 | if (!pxa_rtc->ress) { | 335 | if (!pxa_rtc->ress) { |
337 | dev_err(dev, "No I/O memory resource defined\n"); | 336 | dev_err(dev, "No I/O memory resource defined\n"); |
338 | goto err_ress; | 337 | return -ENXIO; |
339 | } | 338 | } |
340 | 339 | ||
341 | pxa_rtc->irq_1Hz = platform_get_irq(pdev, 0); | 340 | pxa_rtc->irq_1Hz = platform_get_irq(pdev, 0); |
342 | if (pxa_rtc->irq_1Hz < 0) { | 341 | if (pxa_rtc->irq_1Hz < 0) { |
343 | dev_err(dev, "No 1Hz IRQ resource defined\n"); | 342 | dev_err(dev, "No 1Hz IRQ resource defined\n"); |
344 | goto err_ress; | 343 | return -ENXIO; |
345 | } | 344 | } |
346 | pxa_rtc->irq_Alrm = platform_get_irq(pdev, 1); | 345 | pxa_rtc->irq_Alrm = platform_get_irq(pdev, 1); |
347 | if (pxa_rtc->irq_Alrm < 0) { | 346 | if (pxa_rtc->irq_Alrm < 0) { |
348 | dev_err(dev, "No alarm IRQ resource defined\n"); | 347 | dev_err(dev, "No alarm IRQ resource defined\n"); |
349 | goto err_ress; | 348 | return -ENXIO; |
350 | } | 349 | } |
351 | pxa_rtc_open(dev); | 350 | pxa_rtc_open(dev); |
352 | ret = -ENOMEM; | 351 | pxa_rtc->base = devm_ioremap(dev, pxa_rtc->ress->start, |
353 | pxa_rtc->base = ioremap(pxa_rtc->ress->start, | ||
354 | resource_size(pxa_rtc->ress)); | 352 | resource_size(pxa_rtc->ress)); |
355 | if (!pxa_rtc->base) { | 353 | if (!pxa_rtc->base) { |
356 | dev_err(&pdev->dev, "Unable to map pxa RTC I/O memory\n"); | 354 | dev_err(dev, "Unable to map pxa RTC I/O memory\n"); |
357 | goto err_map; | 355 | return -ENOMEM; |
358 | } | 356 | } |
359 | 357 | ||
360 | /* | 358 | /* |
@@ -370,41 +368,24 @@ static int __init pxa_rtc_probe(struct platform_device *pdev) | |||
370 | 368 | ||
371 | rtsr_clear_bits(pxa_rtc, RTSR_PIALE | RTSR_RDALE1 | RTSR_HZE); | 369 | rtsr_clear_bits(pxa_rtc, RTSR_PIALE | RTSR_RDALE1 | RTSR_HZE); |
372 | 370 | ||
373 | pxa_rtc->rtc = rtc_device_register("pxa-rtc", &pdev->dev, &pxa_rtc_ops, | 371 | pxa_rtc->rtc = devm_rtc_device_register(&pdev->dev, "pxa-rtc", |
374 | THIS_MODULE); | 372 | &pxa_rtc_ops, THIS_MODULE); |
375 | ret = PTR_ERR(pxa_rtc->rtc); | ||
376 | if (IS_ERR(pxa_rtc->rtc)) { | 373 | if (IS_ERR(pxa_rtc->rtc)) { |
374 | ret = PTR_ERR(pxa_rtc->rtc); | ||
377 | dev_err(dev, "Failed to register RTC device -> %d\n", ret); | 375 | dev_err(dev, "Failed to register RTC device -> %d\n", ret); |
378 | goto err_rtc_reg; | 376 | return ret; |
379 | } | 377 | } |
380 | 378 | ||
381 | device_init_wakeup(dev, 1); | 379 | device_init_wakeup(dev, 1); |
382 | 380 | ||
383 | return 0; | 381 | return 0; |
384 | |||
385 | err_rtc_reg: | ||
386 | iounmap(pxa_rtc->base); | ||
387 | err_ress: | ||
388 | err_map: | ||
389 | kfree(pxa_rtc); | ||
390 | return ret; | ||
391 | } | 382 | } |
392 | 383 | ||
393 | static int __exit pxa_rtc_remove(struct platform_device *pdev) | 384 | static int __exit pxa_rtc_remove(struct platform_device *pdev) |
394 | { | 385 | { |
395 | struct pxa_rtc *pxa_rtc = platform_get_drvdata(pdev); | ||
396 | |||
397 | struct device *dev = &pdev->dev; | 386 | struct device *dev = &pdev->dev; |
398 | pxa_rtc_release(dev); | ||
399 | |||
400 | rtc_device_unregister(pxa_rtc->rtc); | ||
401 | |||
402 | spin_lock_irq(&pxa_rtc->lock); | ||
403 | iounmap(pxa_rtc->base); | ||
404 | spin_unlock_irq(&pxa_rtc->lock); | ||
405 | |||
406 | kfree(pxa_rtc); | ||
407 | 387 | ||
388 | pxa_rtc_release(dev); | ||
408 | return 0; | 389 | return 0; |
409 | } | 390 | } |
410 | 391 | ||