Commit 618c300305c6ee7c71a1493da97c48c24205268c
Committed by
Linus Torvalds
1 parent
c417299ce7
Exists in
master
and in
20 other branches
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>
Showing 1 changed file with 12 additions and 31 deletions Side-by-side Diff
drivers/rtc/rtc-pxa.c
... | ... | @@ -324,37 +324,35 @@ |
324 | 324 | int ret; |
325 | 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 | 328 | if (!pxa_rtc) |
329 | 329 | return -ENOMEM; |
330 | 330 | |
331 | 331 | spin_lock_init(&pxa_rtc->lock); |
332 | 332 | platform_set_drvdata(pdev, pxa_rtc); |
333 | 333 | |
334 | - ret = -ENXIO; | |
335 | 334 | pxa_rtc->ress = platform_get_resource(pdev, IORESOURCE_MEM, 0); |
336 | 335 | if (!pxa_rtc->ress) { |
337 | 336 | dev_err(dev, "No I/O memory resource defined\n"); |
338 | - goto err_ress; | |
337 | + return -ENXIO; | |
339 | 338 | } |
340 | 339 | |
341 | 340 | pxa_rtc->irq_1Hz = platform_get_irq(pdev, 0); |
342 | 341 | if (pxa_rtc->irq_1Hz < 0) { |
343 | 342 | dev_err(dev, "No 1Hz IRQ resource defined\n"); |
344 | - goto err_ress; | |
343 | + return -ENXIO; | |
345 | 344 | } |
346 | 345 | pxa_rtc->irq_Alrm = platform_get_irq(pdev, 1); |
347 | 346 | if (pxa_rtc->irq_Alrm < 0) { |
348 | 347 | dev_err(dev, "No alarm IRQ resource defined\n"); |
349 | - goto err_ress; | |
348 | + return -ENXIO; | |
350 | 349 | } |
351 | 350 | pxa_rtc_open(dev); |
352 | - ret = -ENOMEM; | |
353 | - pxa_rtc->base = ioremap(pxa_rtc->ress->start, | |
351 | + pxa_rtc->base = devm_ioremap(dev, pxa_rtc->ress->start, | |
354 | 352 | resource_size(pxa_rtc->ress)); |
355 | 353 | if (!pxa_rtc->base) { |
356 | - dev_err(&pdev->dev, "Unable to map pxa RTC I/O memory\n"); | |
357 | - goto err_map; | |
354 | + dev_err(dev, "Unable to map pxa RTC I/O memory\n"); | |
355 | + return -ENOMEM; | |
358 | 356 | } |
359 | 357 | |
360 | 358 | /* |
361 | 359 | |
362 | 360 | |
363 | 361 | |
364 | 362 | |
365 | 363 | |
366 | 364 | |
... | ... | @@ -370,41 +368,24 @@ |
370 | 368 | |
371 | 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, | |
374 | - THIS_MODULE); | |
375 | - ret = PTR_ERR(pxa_rtc->rtc); | |
371 | + pxa_rtc->rtc = devm_rtc_device_register(&pdev->dev, "pxa-rtc", | |
372 | + &pxa_rtc_ops, THIS_MODULE); | |
376 | 373 | if (IS_ERR(pxa_rtc->rtc)) { |
374 | + ret = PTR_ERR(pxa_rtc->rtc); | |
377 | 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 | 379 | device_init_wakeup(dev, 1); |
382 | 380 | |
383 | 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 | 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 | 386 | struct device *dev = &pdev->dev; |
398 | - pxa_rtc_release(dev); | |
399 | 387 | |
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 | - | |
388 | + pxa_rtc_release(dev); | |
408 | 389 | return 0; |
409 | 390 | } |
410 | 391 |