Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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>

+3 -7
+3 -7
drivers/rtc/rtc-sh.c
··· 276 276 struct sh_rtc *rtc = dev_get_drvdata(dev); 277 277 unsigned int sec128, sec2, yr, yr100, cf_bit; 278 278 279 + if (!(readb(rtc->regbase + RCR2) & RCR2_RTCEN)) 280 + return -EINVAL; 281 + 279 282 do { 280 283 unsigned int tmp; 281 284 ··· 469 466 { 470 467 struct sh_rtc *rtc; 471 468 struct resource *res; 472 - struct rtc_time r; 473 469 char clk_name[6]; 474 470 int clk_id, ret; 475 471 ··· 601 599 } 602 600 603 601 rtc->rtc_dev->max_user_freq = 256; 604 - 605 - /* reset rtc to epoch 0 if time is invalid */ 606 - if (rtc_read_time(rtc->rtc_dev, &r) < 0) { 607 - rtc_time_to_tm(0, &r); 608 - rtc_set_time(rtc->rtc_dev, &r); 609 - } 610 602 611 603 device_init_wakeup(&pdev->dev, 1); 612 604 return 0;