Skip to content

Commit fdd4bc9

Browse files
ukleinekgregkh
authored andcommitted
rtc: s35390a: make sure all members in the output are set
The rtc core calls the .read_alarm with all fields initialized to 0. As the s35390a driver doesn't touch some fields the returned date is interpreted as a date in January 1900. So make sure all fields are set to -1; some of them are then overwritten with the right data depending on the hardware state. In mainline this is done by commit d68778b80dd7 ("rtc: initialize output parameter for read alarm to "uninitialized"") in the core. This is considered to dangerous for stable as it might have side effects for other rtc drivers that might for example rely on alarm->time.tm_sec being initialized to 0. Signed-off-by: Uwe Kleine-König <uwe@kleine-koenig.org> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent b3ed386 commit fdd4bc9

1 file changed

Lines changed: 14 additions & 0 deletions

File tree

drivers/rtc/rtc-s35390a.c

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -267,6 +267,20 @@ static int s35390a_read_alarm(struct i2c_client *client, struct rtc_wkalrm *alm)
267267
char buf[3], sts;
268268
int i, err;
269269

270+
/*
271+
* initialize all members to -1 to signal the core that they are not
272+
* defined by the hardware.
273+
*/
274+
alm->time.tm_sec = -1;
275+
alm->time.tm_min = -1;
276+
alm->time.tm_hour = -1;
277+
alm->time.tm_mday = -1;
278+
alm->time.tm_mon = -1;
279+
alm->time.tm_year = -1;
280+
alm->time.tm_wday = -1;
281+
alm->time.tm_yday = -1;
282+
alm->time.tm_isdst = -1;
283+
270284
err = s35390a_get_reg(s35390a, S35390A_CMD_STATUS2, &sts, sizeof(sts));
271285
if (err < 0)
272286
return err;

0 commit comments

Comments
 (0)