rtc: rv8803: invalidate date/time if alarm time is invalid
authorSascha Hauer <s.hauer@pengutronix.de>
Wed, 23 Nov 2022 09:55:27 +0000 (10:55 +0100)
committerAlexandre Belloni <alexandre.belloni@bootlin.com>
Thu, 9 Feb 2023 22:01:49 +0000 (23:01 +0100)
commite5c594233fcf1a55a439dec103aa815cdbf392a7
tree7050bb9d95aafa01a1bc374fa12efcacab588237
parent19409796578c879a41e88ddbdbce50c19457658d
rtc: rv8803: invalidate date/time if alarm time is invalid

RTC core never calls rv8803_set_alarm with an invalid alarm time,
so if an invalid alarm time > 0 is set, external factors must have
corrupted the RTC's alarm time and possibly other registers.

Play it safe by marking the date/time invalid, so all registers are
reinitialized on a ->set_time.

This may cause existing setups to lose time if they so far set only
date/time, but ignored that the alarm registers had an invalid date
value, e.g.:

  rtc rtc0: invalid alarm value: 2020-3-27 7:82:0

These systems will have their ->get_time return -EINVAL till
->set_time initializes the alarm value (and sets a new time).

Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Link: https://lore.kernel.org/r/20221123095527.2771434-3-s.hauer@pengutronix.de
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
drivers/rtc/rtc-rv8803.c