aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/rtc/rtc-ab8500.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/rtc/rtc-ab8500.c')
-rw-r--r--drivers/rtc/rtc-ab8500.c15
1 files changed, 14 insertions, 1 deletions
diff --git a/drivers/rtc/rtc-ab8500.c b/drivers/rtc/rtc-ab8500.c
index 370889d0489b..1a57e03e169d 100644
--- a/drivers/rtc/rtc-ab8500.c
+++ b/drivers/rtc/rtc-ab8500.c
@@ -225,7 +225,8 @@ static int ab8500_rtc_set_alarm(struct device *dev, struct rtc_wkalrm *alarm)
225{ 225{
226 int retval, i; 226 int retval, i;
227 unsigned char buf[ARRAY_SIZE(ab8500_rtc_alarm_regs)]; 227 unsigned char buf[ARRAY_SIZE(ab8500_rtc_alarm_regs)];
228 unsigned long mins, secs = 0; 228 unsigned long mins, secs = 0, cursec = 0;
229 struct rtc_time curtm;
229 230
230 if (alarm->time.tm_year < (AB8500_RTC_EPOCH - 1900)) { 231 if (alarm->time.tm_year < (AB8500_RTC_EPOCH - 1900)) {
231 dev_dbg(dev, "year should be equal to or greater than %d\n", 232 dev_dbg(dev, "year should be equal to or greater than %d\n",
@@ -237,6 +238,18 @@ static int ab8500_rtc_set_alarm(struct device *dev, struct rtc_wkalrm *alarm)
237 rtc_tm_to_time(&alarm->time, &secs); 238 rtc_tm_to_time(&alarm->time, &secs);
238 239
239 /* 240 /*
241 * Check whether alarm is set less than 1min.
242 * Since our RTC doesn't support alarm resolution less than 1min,
243 * return -EINVAL, so UIE EMUL can take it up, incase of UIE_ON
244 */
245 ab8500_rtc_read_time(dev, &curtm); /* Read current time */
246 rtc_tm_to_time(&curtm, &cursec);
247 if ((secs - cursec) < 59) {
248 dev_dbg(dev, "Alarm less than 1 minute not supported\r\n");
249 return -EINVAL;
250 }
251
252 /*
240 * Convert it to the number of seconds since 01-01-2000 00:00:00, since 253 * Convert it to the number of seconds since 01-01-2000 00:00:00, since
241 * we only have a small counter in the RTC. 254 * we only have a small counter in the RTC.
242 */ 255 */