aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-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