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

rtc: use rtc_valid_tm() error code when reading date/time

There's a wrong comment in some RTC drivers that say it's better to ignore
rtc_valid_tm() when reading RTC timestamp. However this is wrong and is
better to return to the userspace the error if timestamp is not valid.

Signed-off-by: Andrea Scian <andrea.scian@dave.eu>
Signed-off-by: Alexandre Belloni <alexandre.belloni@free-electrons.com>

authored by

Andrea Scian and committed by
Alexandre Belloni
821f51c4 4ab82103

+3 -20
+1 -6
drivers/rtc/rtc-isl12022.c
··· 151 151 tm->tm_sec, tm->tm_min, tm->tm_hour, 152 152 tm->tm_mday, tm->tm_mon, tm->tm_year, tm->tm_wday); 153 153 154 - /* The clock can give out invalid datetime, but we cannot return 155 - * -EINVAL otherwise hwclock will refuse to set the time on bootup. */ 156 - if (rtc_valid_tm(tm) < 0) 157 - dev_err(&client->dev, "retrieved date and time is invalid.\n"); 158 - 159 - return 0; 154 + return rtc_valid_tm(tm); 160 155 } 161 156 162 157 static int isl12022_set_datetime(struct i2c_client *client, struct rtc_time *tm)
+1 -7
drivers/rtc/rtc-pcf2123.c
··· 165 165 tm->tm_sec, tm->tm_min, tm->tm_hour, 166 166 tm->tm_mday, tm->tm_mon, tm->tm_year, tm->tm_wday); 167 167 168 - /* the clock can give out invalid datetime, but we cannot return 169 - * -EINVAL otherwise hwclock will refuse to set the time on bootup. 170 - */ 171 - if (rtc_valid_tm(tm) < 0) 172 - dev_err(dev, "retrieved date/time is not valid.\n"); 173 - 174 - return 0; 168 + return rtc_valid_tm(tm); 175 169 } 176 170 177 171 static int pcf2123_rtc_set_time(struct device *dev, struct rtc_time *tm)
+1 -7
drivers/rtc/rtc-pcf2127.c
··· 88 88 tm->tm_sec, tm->tm_min, tm->tm_hour, 89 89 tm->tm_mday, tm->tm_mon, tm->tm_year, tm->tm_wday); 90 90 91 - /* the clock can give out invalid datetime, but we cannot return 92 - * -EINVAL otherwise hwclock will refuse to set the time on bootup. 93 - */ 94 - if (rtc_valid_tm(tm) < 0) 95 - dev_err(&client->dev, "retrieved date/time is not valid.\n"); 96 - 97 - return 0; 91 + return rtc_valid_tm(tm); 98 92 } 99 93 100 94 static int pcf2127_set_datetime(struct i2c_client *client, struct rtc_time *tm)