aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMagnus Damm <damm@igel.co.jp>2009-03-19 06:10:44 -0400
committerPaul Mundt <lethal@linux-sh.org>2009-03-20 05:57:30 -0400
commitedf22477dab5ff3be612af56ee4300ca63e11d06 (patch)
treed22c64a0478f9f304b720f8be74245edad1bee55
parent9cd88b90a6008b0d744187fab80ade4c81c6536f (diff)
sh: sh-rtc invalid time rework
This patch modifies invalid time handling in the SuperH RTC driver. Instead of zeroing the returned value at read-out time we just return an error code and reset invalid values during probe. Signed-off-by: Magnus Damm <damm@igel.co.jp> Signed-off-by: Paul Mundt <lethal@linux-sh.org>
-rw-r--r--drivers/rtc/rtc-sh.c15
1 files changed, 9 insertions, 6 deletions
diff --git a/drivers/rtc/rtc-sh.c b/drivers/rtc/rtc-sh.c
index 21e7435daecb..9ab660c28fee 100644
--- a/drivers/rtc/rtc-sh.c
+++ b/drivers/rtc/rtc-sh.c
@@ -431,12 +431,7 @@ static int sh_rtc_read_time(struct device *dev, struct rtc_time *tm)
431 tm->tm_sec, tm->tm_min, tm->tm_hour, 431 tm->tm_sec, tm->tm_min, tm->tm_hour,
432 tm->tm_mday, tm->tm_mon + 1, tm->tm_year, tm->tm_wday); 432 tm->tm_mday, tm->tm_mon + 1, tm->tm_year, tm->tm_wday);
433 433
434 if (rtc_valid_tm(tm) < 0) { 434 return rtc_valid_tm(tm);
435 dev_err(dev, "invalid date\n");
436 rtc_time_to_tm(0, tm);
437 }
438
439 return 0;
440} 435}
441 436
442static int sh_rtc_set_time(struct device *dev, struct rtc_time *tm) 437static int sh_rtc_set_time(struct device *dev, struct rtc_time *tm)
@@ -641,6 +636,7 @@ static int __devinit sh_rtc_probe(struct platform_device *pdev)
641{ 636{
642 struct sh_rtc *rtc; 637 struct sh_rtc *rtc;
643 struct resource *res; 638 struct resource *res;
639 struct rtc_time r;
644 int ret; 640 int ret;
645 641
646 rtc = kzalloc(sizeof(struct sh_rtc), GFP_KERNEL); 642 rtc = kzalloc(sizeof(struct sh_rtc), GFP_KERNEL);
@@ -752,6 +748,13 @@ static int __devinit sh_rtc_probe(struct platform_device *pdev)
752 sh_rtc_setpie(&pdev->dev, 0); 748 sh_rtc_setpie(&pdev->dev, 0);
753 sh_rtc_setaie(&pdev->dev, 0); 749 sh_rtc_setaie(&pdev->dev, 0);
754 sh_rtc_setcie(&pdev->dev, 0); 750 sh_rtc_setcie(&pdev->dev, 0);
751
752 /* reset rtc to epoch 0 if time is invalid */
753 if (rtc_read_time(rtc->rtc_dev, &r) < 0) {
754 rtc_time_to_tm(0, &r);
755 rtc_set_time(rtc->rtc_dev, &r);
756 }
757
755 return 0; 758 return 0;
756 759
757err_unmap: 760err_unmap: