aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/rtc/rtc-puv3.c
diff options
context:
space:
mode:
authorJingoo Han <jg1.han@samsung.com>2013-04-29 19:21:02 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2013-04-29 21:28:39 -0400
commit5936fdb9b267990158601b634bcc959cef39d33f (patch)
treefa022d7e128c0f9c187d0bfe4432e2ba78e6aaf0 /drivers/rtc/rtc-puv3.c
parent04ebc35973745c1b9af281931d6ebd3842496e8e (diff)
rtc: rtc-puv3: convert puv3_rtc_driver to dev_pm_ops
Instead of using legacy suspend/resume methods, using newer dev_pm_ops structure allows better control over power management. 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>
Diffstat (limited to 'drivers/rtc/rtc-puv3.c')
-rw-r--r--drivers/rtc/rtc-puv3.c27
1 files changed, 12 insertions, 15 deletions
diff --git a/drivers/rtc/rtc-puv3.c b/drivers/rtc/rtc-puv3.c
index 0407e13d4de4..72f437170d2e 100644
--- a/drivers/rtc/rtc-puv3.c
+++ b/drivers/rtc/rtc-puv3.c
@@ -207,14 +207,14 @@ static const struct rtc_class_ops puv3_rtcops = {
207 .proc = puv3_rtc_proc, 207 .proc = puv3_rtc_proc,
208}; 208};
209 209
210static void puv3_rtc_enable(struct platform_device *pdev, int en) 210static void puv3_rtc_enable(struct device *dev, int en)
211{ 211{
212 if (!en) { 212 if (!en) {
213 writel(readl(RTC_RTSR) & ~RTC_RTSR_HZE, RTC_RTSR); 213 writel(readl(RTC_RTSR) & ~RTC_RTSR_HZE, RTC_RTSR);
214 } else { 214 } else {
215 /* re-enable the device, and check it is ok */ 215 /* re-enable the device, and check it is ok */
216 if ((readl(RTC_RTSR) & RTC_RTSR_HZE) == 0) { 216 if ((readl(RTC_RTSR) & RTC_RTSR_HZE) == 0) {
217 dev_info(&pdev->dev, "rtc disabled, re-enabling\n"); 217 dev_info(dev, "rtc disabled, re-enabling\n");
218 writel(readl(RTC_RTSR) | RTC_RTSR_HZE, RTC_RTSR); 218 writel(readl(RTC_RTSR) | RTC_RTSR_HZE, RTC_RTSR);
219 } 219 }
220 } 220 }
@@ -276,7 +276,7 @@ static int puv3_rtc_probe(struct platform_device *pdev)
276 goto err_nores; 276 goto err_nores;
277 } 277 }
278 278
279 puv3_rtc_enable(pdev, 1); 279 puv3_rtc_enable(&pdev->dev, 1);
280 280
281 /* register RTC and exit */ 281 /* register RTC and exit */
282 rtc = rtc_device_register("pkunity", &pdev->dev, &puv3_rtcops, 282 rtc = rtc_device_register("pkunity", &pdev->dev, &puv3_rtcops,
@@ -296,44 +296,41 @@ static int puv3_rtc_probe(struct platform_device *pdev)
296 return 0; 296 return 0;
297 297
298 err_nortc: 298 err_nortc:
299 puv3_rtc_enable(pdev, 0); 299 puv3_rtc_enable(&pdev->dev, 0);
300 release_resource(puv3_rtc_mem); 300 release_resource(puv3_rtc_mem);
301 301
302 err_nores: 302 err_nores:
303 return ret; 303 return ret;
304} 304}
305 305
306#ifdef CONFIG_PM 306#ifdef CONFIG_PM_SLEEP
307
308static int ticnt_save; 307static int ticnt_save;
309 308
310static int puv3_rtc_suspend(struct platform_device *pdev, pm_message_t state) 309static int puv3_rtc_suspend(struct device *dev)
311{ 310{
312 /* save RTAR for anyone using periodic interrupts */ 311 /* save RTAR for anyone using periodic interrupts */
313 ticnt_save = readl(RTC_RTAR); 312 ticnt_save = readl(RTC_RTAR);
314 puv3_rtc_enable(pdev, 0); 313 puv3_rtc_enable(dev, 0);
315 return 0; 314 return 0;
316} 315}
317 316
318static int puv3_rtc_resume(struct platform_device *pdev) 317static int puv3_rtc_resume(struct device *dev)
319{ 318{
320 puv3_rtc_enable(pdev, 1); 319 puv3_rtc_enable(dev, 1);
321 writel(ticnt_save, RTC_RTAR); 320 writel(ticnt_save, RTC_RTAR);
322 return 0; 321 return 0;
323} 322}
324#else
325#define puv3_rtc_suspend NULL
326#define puv3_rtc_resume NULL
327#endif 323#endif
328 324
325static SIMPLE_DEV_PM_OPS(puv3_rtc_pm_ops, puv3_rtc_suspend, puv3_rtc_resume);
326
329static struct platform_driver puv3_rtc_driver = { 327static struct platform_driver puv3_rtc_driver = {
330 .probe = puv3_rtc_probe, 328 .probe = puv3_rtc_probe,
331 .remove = puv3_rtc_remove, 329 .remove = puv3_rtc_remove,
332 .suspend = puv3_rtc_suspend,
333 .resume = puv3_rtc_resume,
334 .driver = { 330 .driver = {
335 .name = "PKUnity-v3-RTC", 331 .name = "PKUnity-v3-RTC",
336 .owner = THIS_MODULE, 332 .owner = THIS_MODULE,
333 .pm = &puv3_rtc_pm_ops,
337 } 334 }
338}; 335};
339 336