aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/rtc/rtc-sa1100.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/rtc/rtc-sa1100.c')
-rw-r--r--drivers/rtc/rtc-sa1100.c29
1 files changed, 9 insertions, 20 deletions
diff --git a/drivers/rtc/rtc-sa1100.c b/drivers/rtc/rtc-sa1100.c
index 5ec5036df0bc..00605601dbf7 100644
--- a/drivers/rtc/rtc-sa1100.c
+++ b/drivers/rtc/rtc-sa1100.c
@@ -234,14 +234,13 @@ static int sa1100_rtc_probe(struct platform_device *pdev)
234 if (irq_1hz < 0 || irq_alarm < 0) 234 if (irq_1hz < 0 || irq_alarm < 0)
235 return -ENODEV; 235 return -ENODEV;
236 236
237 info = kzalloc(sizeof(struct sa1100_rtc), GFP_KERNEL); 237 info = devm_kzalloc(&pdev->dev, sizeof(struct sa1100_rtc), GFP_KERNEL);
238 if (!info) 238 if (!info)
239 return -ENOMEM; 239 return -ENOMEM;
240 info->clk = clk_get(&pdev->dev, NULL); 240 info->clk = devm_clk_get(&pdev->dev, NULL);
241 if (IS_ERR(info->clk)) { 241 if (IS_ERR(info->clk)) {
242 dev_err(&pdev->dev, "failed to find rtc clock source\n"); 242 dev_err(&pdev->dev, "failed to find rtc clock source\n");
243 ret = PTR_ERR(info->clk); 243 return PTR_ERR(info->clk);
244 goto err_clk;
245 } 244 }
246 info->irq_1hz = irq_1hz; 245 info->irq_1hz = irq_1hz;
247 info->irq_alarm = irq_alarm; 246 info->irq_alarm = irq_alarm;
@@ -268,8 +267,8 @@ static int sa1100_rtc_probe(struct platform_device *pdev)
268 267
269 device_init_wakeup(&pdev->dev, 1); 268 device_init_wakeup(&pdev->dev, 1);
270 269
271 rtc = rtc_device_register(pdev->name, &pdev->dev, &sa1100_rtc_ops, 270 rtc = devm_rtc_device_register(&pdev->dev, pdev->name, &sa1100_rtc_ops,
272 THIS_MODULE); 271 THIS_MODULE);
273 272
274 if (IS_ERR(rtc)) { 273 if (IS_ERR(rtc)) {
275 ret = PTR_ERR(rtc); 274 ret = PTR_ERR(rtc);
@@ -306,9 +305,6 @@ err_dev:
306 clk_disable_unprepare(info->clk); 305 clk_disable_unprepare(info->clk);
307err_enable_clk: 306err_enable_clk:
308 platform_set_drvdata(pdev, NULL); 307 platform_set_drvdata(pdev, NULL);
309 clk_put(info->clk);
310err_clk:
311 kfree(info);
312 return ret; 308 return ret;
313} 309}
314 310
@@ -317,17 +313,14 @@ static int sa1100_rtc_remove(struct platform_device *pdev)
317 struct sa1100_rtc *info = platform_get_drvdata(pdev); 313 struct sa1100_rtc *info = platform_get_drvdata(pdev);
318 314
319 if (info) { 315 if (info) {
320 rtc_device_unregister(info->rtc);
321 clk_disable_unprepare(info->clk); 316 clk_disable_unprepare(info->clk);
322 clk_put(info->clk);
323 platform_set_drvdata(pdev, NULL); 317 platform_set_drvdata(pdev, NULL);
324 kfree(info);
325 } 318 }
326 319
327 return 0; 320 return 0;
328} 321}
329 322
330#ifdef CONFIG_PM 323#ifdef CONFIG_PM_SLEEP
331static int sa1100_rtc_suspend(struct device *dev) 324static int sa1100_rtc_suspend(struct device *dev)
332{ 325{
333 struct sa1100_rtc *info = dev_get_drvdata(dev); 326 struct sa1100_rtc *info = dev_get_drvdata(dev);
@@ -343,13 +336,11 @@ static int sa1100_rtc_resume(struct device *dev)
343 disable_irq_wake(info->irq_alarm); 336 disable_irq_wake(info->irq_alarm);
344 return 0; 337 return 0;
345} 338}
346
347static const struct dev_pm_ops sa1100_rtc_pm_ops = {
348 .suspend = sa1100_rtc_suspend,
349 .resume = sa1100_rtc_resume,
350};
351#endif 339#endif
352 340
341static SIMPLE_DEV_PM_OPS(sa1100_rtc_pm_ops, sa1100_rtc_suspend,
342 sa1100_rtc_resume);
343
353#ifdef CONFIG_OF 344#ifdef CONFIG_OF
354static struct of_device_id sa1100_rtc_dt_ids[] = { 345static struct of_device_id sa1100_rtc_dt_ids[] = {
355 { .compatible = "mrvl,sa1100-rtc", }, 346 { .compatible = "mrvl,sa1100-rtc", },
@@ -364,9 +355,7 @@ static struct platform_driver sa1100_rtc_driver = {
364 .remove = sa1100_rtc_remove, 355 .remove = sa1100_rtc_remove,
365 .driver = { 356 .driver = {
366 .name = "sa1100-rtc", 357 .name = "sa1100-rtc",
367#ifdef CONFIG_PM
368 .pm = &sa1100_rtc_pm_ops, 358 .pm = &sa1100_rtc_pm_ops,
369#endif
370 .of_match_table = of_match_ptr(sa1100_rtc_dt_ids), 359 .of_match_table = of_match_ptr(sa1100_rtc_dt_ids),
371 }, 360 },
372}; 361};