mirror of
https://github.com/hardkernel/linux.git
synced 2026-06-07 03:15:31 +09:00
rtc: hym8563: align the alarm time settings
Signed-off-by: Wu Liangqing <wlq@rock-chips.com> Change-Id: I59bacd5ef31f67af52313106382ca33734046c72
This commit is contained in:
@@ -226,12 +226,39 @@ static int hym8563_rtc_set_alarm(struct device *dev, struct rtc_wkalrm *alm)
|
||||
if (alm_tm->tm_hour >= 24) {
|
||||
alm_tm->tm_hour = 0;
|
||||
alm_tm->tm_mday++;
|
||||
if (alm_tm->tm_mday > 31)
|
||||
alm_tm->tm_mday = 0;
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
ret = i2c_smbus_read_byte_data(client, HYM8563_CTL2);
|
||||
if (ret < 0)
|
||||
return ret;
|
||||
|
||||
Reference in New Issue
Block a user