mirror of
https://github.com/hardkernel/linux.git
synced 2026-06-07 03:15:31 +09:00
rtc: s35390a: fix rtc alarm wake up problem if time < 60s
Signed-off-by: Luo Wei <lw@rock-chips.com> Change-Id: I946fd0742405b0b0fb6261231f41a53e3aacd9cb
This commit is contained in:
@@ -278,9 +278,56 @@ static int s35390a_rtc_set_alarm(struct device *dev, struct rtc_wkalrm *alm)
|
||||
{
|
||||
struct i2c_client *client = to_i2c_client(dev);
|
||||
struct s35390a *s35390a = i2c_get_clientdata(client);
|
||||
struct rtc_time *alm_tm = &alm->time;
|
||||
char buf[3], sts = 0;
|
||||
int err, i;
|
||||
|
||||
/*
|
||||
* The alarm has no seconds so deal with it
|
||||
*/
|
||||
if (alm_tm->tm_sec) {
|
||||
alm_tm->tm_sec = 0;
|
||||
alm_tm->tm_min++;
|
||||
if (alm_tm->tm_min >= 60) {
|
||||
alm_tm->tm_min = 0;
|
||||
alm_tm->tm_hour++;
|
||||
if (alm_tm->tm_hour >= 24) {
|
||||
alm_tm->tm_hour = 0;
|
||||
alm_tm->tm_mday++;
|
||||
alm_tm->tm_wday++;
|
||||
if (alm_tm->tm_wday > 6)
|
||||
alm_tm->tm_wday = 0;
|
||||
switch (alm_tm->tm_mon + 1) {
|
||||
case 1:
|
||||
case 3:
|
||||
case 5:
|
||||
case 7:
|
||||
case 8:
|
||||
case 10:
|
||||
case 12:
|
||||
if (alm_tm->tm_mday > 31)
|
||||
alm_tm->tm_mday = 1;
|
||||
break;
|
||||
case 4:
|
||||
case 6:
|
||||
case 9:
|
||||
case 11:
|
||||
if (alm_tm->tm_mday > 30)
|
||||
alm_tm->tm_mday = 1;
|
||||
break;
|
||||
case 2:
|
||||
if (alm_tm->tm_year / 4 == 0) {
|
||||
if (alm_tm->tm_mday > 29)
|
||||
alm_tm->tm_mday = 1;
|
||||
} else if (alm_tm->tm_mday > 28) {
|
||||
alm_tm->tm_mday = 1;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
dev_dbg(&client->dev, "%s: alm is secs=%d, mins=%d, hours=%d mday=%d, "\
|
||||
"mon=%d, year=%d, wday=%d\n", __func__, alm->time.tm_sec,
|
||||
alm->time.tm_min, alm->time.tm_hour, alm->time.tm_mday,
|
||||
|
||||
Reference in New Issue
Block a user