rtc: ds1307: properly handle oscillator failure flags
authorAlexandre Belloni <alexandre.belloni@bootlin.com>
Wed, 10 Apr 2019 22:16:29 +0000 (00:16 +0200)
committerAlexandre Belloni <alexandre.belloni@bootlin.com>
Thu, 23 May 2019 15:53:03 +0000 (17:53 +0200)
commitb3a50169762b14102a296a410d785f9ec1132ae1
tree1eef64d1c9fb772200ad736dda2b2ef6fea4a753
parent097aa24b5db09a852516c467f2cd62e8adfd6bba
rtc: ds1307: properly handle oscillator failure flags

Stop enabling the oscillator and removing the oscillator failure flags in
probe. Instead, return -EINVAL in .read_time when the oscillaotr is not
start or when it failed at some point. The oscillator gets enabled on the
first .set_time after failure and the failure flags are cleared.

This also removes the possibility of an infinite loop at probe where a
failing RTC will make the goto read_rtc to be taken every time.

Tested on mcp79411.

Reported-by: Mastro Gippo <gipmad@gmail.com>
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
drivers/rtc/rtc-ds1307.c