aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/rtc
diff options
context:
space:
mode:
authorSachin Kamat <sachin.kamat@linaro.org>2013-04-29 19:20:27 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2013-04-29 21:28:35 -0400
commit3087b3d090d2fd3bc0c26c0dc6cbe49e493c7988 (patch)
treeb3f2dba413ba60827385e805a64a0f116bd3b431 /drivers/rtc
parent7f391f54cdbc68a9617642c2141c696ed368f594 (diff)
drivers/rtc/rtc-88pm860x.c: use devm_* APIs
devm_* functions are device managed and make cleanup code simpler. Signed-off-by: Sachin Kamat <sachin.kamat@linaro.org> Acked-by: Haojian Zhuang <haojian.zhuang@linaro.org> Cc: 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')
-rw-r--r--drivers/rtc/rtc-88pm860x.c29
1 files changed, 11 insertions, 18 deletions
diff --git a/drivers/rtc/rtc-88pm860x.c b/drivers/rtc/rtc-88pm860x.c
index f663746f4603..0f2b91bfee37 100644
--- a/drivers/rtc/rtc-88pm860x.c
+++ b/drivers/rtc/rtc-88pm860x.c
@@ -318,14 +318,14 @@ static int pm860x_rtc_probe(struct platform_device *pdev)
318 318
319 pdata = pdev->dev.platform_data; 319 pdata = pdev->dev.platform_data;
320 320
321 info = kzalloc(sizeof(struct pm860x_rtc_info), GFP_KERNEL); 321 info = devm_kzalloc(&pdev->dev, sizeof(struct pm860x_rtc_info),
322 GFP_KERNEL);
322 if (!info) 323 if (!info)
323 return -ENOMEM; 324 return -ENOMEM;
324 info->irq = platform_get_irq(pdev, 0); 325 info->irq = platform_get_irq(pdev, 0);
325 if (info->irq < 0) { 326 if (info->irq < 0) {
326 dev_err(&pdev->dev, "No IRQ resource!\n"); 327 dev_err(&pdev->dev, "No IRQ resource!\n");
327 ret = -EINVAL; 328 return info->irq;
328 goto out;
329 } 329 }
330 330
331 info->chip = chip; 331 info->chip = chip;
@@ -333,12 +333,13 @@ static int pm860x_rtc_probe(struct platform_device *pdev)
333 info->dev = &pdev->dev; 333 info->dev = &pdev->dev;
334 dev_set_drvdata(&pdev->dev, info); 334 dev_set_drvdata(&pdev->dev, info);
335 335
336 ret = request_threaded_irq(info->irq, NULL, rtc_update_handler, 336 ret = devm_request_threaded_irq(&pdev->dev, info->irq, NULL,
337 IRQF_ONESHOT, "rtc", info); 337 rtc_update_handler, IRQF_ONESHOT, "rtc",
338 info);
338 if (ret < 0) { 339 if (ret < 0) {
339 dev_err(chip->dev, "Failed to request IRQ: #%d: %d\n", 340 dev_err(chip->dev, "Failed to request IRQ: #%d: %d\n",
340 info->irq, ret); 341 info->irq, ret);
341 goto out; 342 return ret;
342 } 343 }
343 344
344 /* set addresses of 32-bit base value for RTC time */ 345 /* set addresses of 32-bit base value for RTC time */
@@ -350,7 +351,7 @@ static int pm860x_rtc_probe(struct platform_device *pdev)
350 ret = pm860x_rtc_read_time(&pdev->dev, &tm); 351 ret = pm860x_rtc_read_time(&pdev->dev, &tm);
351 if (ret < 0) { 352 if (ret < 0) {
352 dev_err(&pdev->dev, "Failed to read initial time.\n"); 353 dev_err(&pdev->dev, "Failed to read initial time.\n");
353 goto out_rtc; 354 return ret;
354 } 355 }
355 if ((tm.tm_year < 70) || (tm.tm_year > 138)) { 356 if ((tm.tm_year < 70) || (tm.tm_year > 138)) {
356 tm.tm_year = 70; 357 tm.tm_year = 70;
@@ -362,7 +363,7 @@ static int pm860x_rtc_probe(struct platform_device *pdev)
362 ret = pm860x_rtc_set_time(&pdev->dev, &tm); 363 ret = pm860x_rtc_set_time(&pdev->dev, &tm);
363 if (ret < 0) { 364 if (ret < 0) {
364 dev_err(&pdev->dev, "Failed to set initial time.\n"); 365 dev_err(&pdev->dev, "Failed to set initial time.\n");
365 goto out_rtc; 366 return ret;
366 } 367 }
367 } 368 }
368 rtc_tm_to_time(&tm, &ticks); 369 rtc_tm_to_time(&tm, &ticks);
@@ -373,12 +374,12 @@ static int pm860x_rtc_probe(struct platform_device *pdev)
373 } 374 }
374 } 375 }
375 376
376 info->rtc_dev = rtc_device_register("88pm860x-rtc", &pdev->dev, 377 info->rtc_dev = devm_rtc_device_register(&pdev->dev, "88pm860x-rtc",
377 &pm860x_rtc_ops, THIS_MODULE); 378 &pm860x_rtc_ops, THIS_MODULE);
378 ret = PTR_ERR(info->rtc_dev); 379 ret = PTR_ERR(info->rtc_dev);
379 if (IS_ERR(info->rtc_dev)) { 380 if (IS_ERR(info->rtc_dev)) {
380 dev_err(&pdev->dev, "Failed to register RTC device: %d\n", ret); 381 dev_err(&pdev->dev, "Failed to register RTC device: %d\n", ret);
381 goto out_rtc; 382 return ret;
382 } 383 }
383 384
384 /* 385 /*
@@ -405,11 +406,6 @@ static int pm860x_rtc_probe(struct platform_device *pdev)
405 device_init_wakeup(&pdev->dev, 1); 406 device_init_wakeup(&pdev->dev, 1);
406 407
407 return 0; 408 return 0;
408out_rtc:
409 free_irq(info->irq, info);
410out:
411 kfree(info);
412 return ret;
413} 409}
414 410
415static int pm860x_rtc_remove(struct platform_device *pdev) 411static int pm860x_rtc_remove(struct platform_device *pdev)
@@ -423,9 +419,6 @@ static int pm860x_rtc_remove(struct platform_device *pdev)
423#endif /* VRTC_CALIBRATION */ 419#endif /* VRTC_CALIBRATION */
424 420
425 platform_set_drvdata(pdev, NULL); 421 platform_set_drvdata(pdev, NULL);
426 rtc_device_unregister(info->rtc_dev);
427 free_irq(info->irq, info);
428 kfree(info);
429 return 0; 422 return 0;
430} 423}
431 424