aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/rtc/rtc-max8925.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/rtc/rtc-max8925.c')
-rw-r--r--drivers/rtc/rtc-max8925.c26
1 files changed, 9 insertions, 17 deletions
diff --git a/drivers/rtc/rtc-max8925.c b/drivers/rtc/rtc-max8925.c
index a0c8265646d2..7c90f4e45e27 100644
--- a/drivers/rtc/rtc-max8925.c
+++ b/drivers/rtc/rtc-max8925.c
@@ -253,7 +253,8 @@ static int max8925_rtc_probe(struct platform_device *pdev)
253 struct max8925_rtc_info *info; 253 struct max8925_rtc_info *info;
254 int ret; 254 int ret;
255 255
256 info = kzalloc(sizeof(struct max8925_rtc_info), GFP_KERNEL); 256 info = devm_kzalloc(&pdev->dev, sizeof(struct max8925_rtc_info),
257 GFP_KERNEL);
257 if (!info) 258 if (!info)
258 return -ENOMEM; 259 return -ENOMEM;
259 info->chip = chip; 260 info->chip = chip;
@@ -261,12 +262,13 @@ static int max8925_rtc_probe(struct platform_device *pdev)
261 info->dev = &pdev->dev; 262 info->dev = &pdev->dev;
262 info->irq = platform_get_irq(pdev, 0); 263 info->irq = platform_get_irq(pdev, 0);
263 264
264 ret = request_threaded_irq(info->irq, NULL, rtc_update_handler, 265 ret = devm_request_threaded_irq(&pdev->dev, info->irq, NULL,
265 IRQF_ONESHOT, "rtc-alarm0", info); 266 rtc_update_handler, IRQF_ONESHOT,
267 "rtc-alarm0", info);
266 if (ret < 0) { 268 if (ret < 0) {
267 dev_err(chip->dev, "Failed to request IRQ: #%d: %d\n", 269 dev_err(chip->dev, "Failed to request IRQ: #%d: %d\n",
268 info->irq, ret); 270 info->irq, ret);
269 goto out_irq; 271 goto err;
270 } 272 }
271 273
272 dev_set_drvdata(&pdev->dev, info); 274 dev_set_drvdata(&pdev->dev, info);
@@ -275,32 +277,22 @@ static int max8925_rtc_probe(struct platform_device *pdev)
275 277
276 device_init_wakeup(&pdev->dev, 1); 278 device_init_wakeup(&pdev->dev, 1);
277 279
278 info->rtc_dev = rtc_device_register("max8925-rtc", &pdev->dev, 280 info->rtc_dev = devm_rtc_device_register(&pdev->dev, "max8925-rtc",
279 &max8925_rtc_ops, THIS_MODULE); 281 &max8925_rtc_ops, THIS_MODULE);
280 ret = PTR_ERR(info->rtc_dev); 282 ret = PTR_ERR(info->rtc_dev);
281 if (IS_ERR(info->rtc_dev)) { 283 if (IS_ERR(info->rtc_dev)) {
282 dev_err(&pdev->dev, "Failed to register RTC device: %d\n", ret); 284 dev_err(&pdev->dev, "Failed to register RTC device: %d\n", ret);
283 goto out_rtc; 285 goto err;
284 } 286 }
285 287
286 return 0; 288 return 0;
287out_rtc: 289err:
288 platform_set_drvdata(pdev, NULL); 290 platform_set_drvdata(pdev, NULL);
289 free_irq(info->irq, info);
290out_irq:
291 kfree(info);
292 return ret; 291 return ret;
293} 292}
294 293
295static int max8925_rtc_remove(struct platform_device *pdev) 294static int max8925_rtc_remove(struct platform_device *pdev)
296{ 295{
297 struct max8925_rtc_info *info = platform_get_drvdata(pdev);
298
299 if (info) {
300 free_irq(info->irq, info);
301 rtc_device_unregister(info->rtc_dev);
302 kfree(info);
303 }
304 return 0; 296 return 0;
305} 297}
306 298