summary refs log tree commit diff
path: root/drivers
diff options
context:
space:
mode:
authorAlexandre Belloni <alexandre.belloni@bootlin.com>2019-03-20 12:30:08 +0100
committerAlexandre Belloni <alexandre.belloni@bootlin.com>2019-04-04 10:07:09 +0200
commit9852023d204b97324e7fa84f50f28a9d602b79fb (patch)
treed240a4c972e3f24da3493997226c272f7d9d6b28 /drivers
parentc1576497b286f71e7abd0208f846245f01b3671e (diff)
downloadlinux-9852023d204b97324e7fa84f50f28a9d602b79fb.tar.gz
rtc: sh: stop resetting time to epoch
There is no point in resetting the time to epoch as this means that
userspace will never get the valuable information that time is actually
invalid.

Reviewed-by: Geert Uytterhoeven <geert+renesas@glider.be>
Tested-by: Geert Uytterhoeven <geert+renesas@glider.be>
[Anders Roxell <anders.roxell@linaro.org>: remove unused variable r]
Signed-off-by: Anders Roxell <anders.roxell@linaro.org>
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/rtc/rtc-sh.c10
1 files changed, 3 insertions, 7 deletions
diff --git a/drivers/rtc/rtc-sh.c b/drivers/rtc/rtc-sh.c
index d417b203cbc5..7fffe6da9478 100644
--- a/drivers/rtc/rtc-sh.c
+++ b/drivers/rtc/rtc-sh.c
@@ -276,6 +276,9 @@ static int sh_rtc_read_time(struct device *dev, struct rtc_time *tm)
 	struct sh_rtc *rtc = dev_get_drvdata(dev);
 	unsigned int sec128, sec2, yr, yr100, cf_bit;
 
+	if (!(readb(rtc->regbase + RCR2) & RCR2_RTCEN))
+		return -EINVAL;
+
 	do {
 		unsigned int tmp;
 
@@ -466,7 +469,6 @@ static int __init sh_rtc_probe(struct platform_device *pdev)
 {
 	struct sh_rtc *rtc;
 	struct resource *res;
-	struct rtc_time r;
 	char clk_name[6];
 	int clk_id, ret;
 
@@ -600,12 +602,6 @@ static int __init sh_rtc_probe(struct platform_device *pdev)
 
 	rtc->rtc_dev->max_user_freq = 256;
 
-	/* reset rtc to epoch 0 if time is invalid */
-	if (rtc_read_time(rtc->rtc_dev, &r) < 0) {
-		rtc_time_to_tm(0, &r);
-		rtc_set_time(rtc->rtc_dev, &r);
-	}
-
 	device_init_wakeup(&pdev->dev, 1);
 	return 0;