aboutsummaryrefslogtreecommitdiffstats
path: root/kernel
diff options
context:
space:
mode:
authorJohn Stultz <john.stultz@linaro.org>2011-06-16 21:47:37 -0400
committerJohn Stultz <john.stultz@linaro.org>2011-06-21 19:32:28 -0400
commit1c6b39ad3f01514fd8dd84b5b412bafb75c19388 (patch)
treebd31cf5d3e67acc9ef23c97ddd92c961b73f40c7 /kernel
parentc008ba58af24dc5d0d8e9fe6e59d876910254761 (diff)
alarmtimers: Return -ENOTSUPP if no RTC device is present
Toralf Förster and Richard Weinberger noted that if there is no RTC device, the alarm timers core prints out an annoying "ALARM timers will not wake from suspend" message. This warning has been removed in a previous patch, however the issue still remains: The original idea was to support alarm timers even if there was no rtc device, as long as the system didn't go into suspend. However, after further consideration, communicating to the application that alarmtimers are not fully functional seems like the better solution. So this patch makes it so we return -ENOTSUPP to any posix _ALARM clockid calls if there is no backing RTC device on the system. Further this changes the behavior where when there is no rtc device we will check for one on clock_getres, clock_gettime, timer_create, and timer_nsleep instead of on suspend. CC: Toralf Förster <toralf.foerster@gmx.de> CC: Richard Weinberger <richard@nod.at CC: Peter Zijlstra <peterz@infradead.org> CC: Thomas Gleixner <tglx@linutronix.de> Reported-by: Toralf Förster <toralf.foerster@gmx.de> Reported by: Richard Weinberger <richard@nod.at> Signed-off-by: John Stultz <john.stultz@linaro.org>
Diffstat (limited to 'kernel')
-rw-r--r--kernel/time/alarmtimer.c23
1 files changed, 22 insertions, 1 deletions
diff --git a/kernel/time/alarmtimer.c b/kernel/time/alarmtimer.c
index 98ecf4e36f2f..59f369f98a04 100644
--- a/kernel/time/alarmtimer.c
+++ b/kernel/time/alarmtimer.c
@@ -107,6 +107,9 @@ static struct rtc_device *alarmtimer_get_rtcdev(void)
107 107
108 return ret; 108 return ret;
109} 109}
110#else
111#define alarmtimer_get_rtcdev() (0)
112#define rtcdev (0)
110#endif 113#endif
111 114
112 115
@@ -231,7 +234,7 @@ static int alarmtimer_suspend(struct device *dev)
231 freezer_delta = ktime_set(0, 0); 234 freezer_delta = ktime_set(0, 0);
232 spin_unlock_irqrestore(&freezer_delta_lock, flags); 235 spin_unlock_irqrestore(&freezer_delta_lock, flags);
233 236
234 rtc = alarmtimer_get_rtcdev(); 237 rtc = rtcdev;
235 /* If we have no rtcdev, just return */ 238 /* If we have no rtcdev, just return */
236 if (!rtc) 239 if (!rtc)
237 return 0; 240 return 0;
@@ -381,6 +384,9 @@ static int alarm_clock_getres(const clockid_t which_clock, struct timespec *tp)
381{ 384{
382 clockid_t baseid = alarm_bases[clock2alarm(which_clock)].base_clockid; 385 clockid_t baseid = alarm_bases[clock2alarm(which_clock)].base_clockid;
383 386
387 if (!alarmtimer_get_rtcdev())
388 return -ENOTSUPP;
389
384 return hrtimer_get_res(baseid, tp); 390 return hrtimer_get_res(baseid, tp);
385} 391}
386 392
@@ -395,6 +401,9 @@ static int alarm_clock_get(clockid_t which_clock, struct timespec *tp)
395{ 401{
396 struct alarm_base *base = &alarm_bases[clock2alarm(which_clock)]; 402 struct alarm_base *base = &alarm_bases[clock2alarm(which_clock)];
397 403
404 if (!alarmtimer_get_rtcdev())
405 return -ENOTSUPP;
406
398 *tp = ktime_to_timespec(base->gettime()); 407 *tp = ktime_to_timespec(base->gettime());
399 return 0; 408 return 0;
400} 409}
@@ -410,6 +419,9 @@ static int alarm_timer_create(struct k_itimer *new_timer)
410 enum alarmtimer_type type; 419 enum alarmtimer_type type;
411 struct alarm_base *base; 420 struct alarm_base *base;
412 421
422 if (!alarmtimer_get_rtcdev())
423 return -ENOTSUPP;
424
413 if (!capable(CAP_WAKE_ALARM)) 425 if (!capable(CAP_WAKE_ALARM))
414 return -EPERM; 426 return -EPERM;
415 427
@@ -444,6 +456,9 @@ static void alarm_timer_get(struct k_itimer *timr,
444 */ 456 */
445static int alarm_timer_del(struct k_itimer *timr) 457static int alarm_timer_del(struct k_itimer *timr)
446{ 458{
459 if (!rtcdev)
460 return -ENOTSUPP;
461
447 alarm_cancel(&timr->it.alarmtimer); 462 alarm_cancel(&timr->it.alarmtimer);
448 return 0; 463 return 0;
449} 464}
@@ -461,6 +476,9 @@ static int alarm_timer_set(struct k_itimer *timr, int flags,
461 struct itimerspec *new_setting, 476 struct itimerspec *new_setting,
462 struct itimerspec *old_setting) 477 struct itimerspec *old_setting)
463{ 478{
479 if (!rtcdev)
480 return -ENOTSUPP;
481
464 /* Save old values */ 482 /* Save old values */
465 old_setting->it_interval = 483 old_setting->it_interval =
466 ktime_to_timespec(timr->it.alarmtimer.period); 484 ktime_to_timespec(timr->it.alarmtimer.period);
@@ -600,6 +618,9 @@ static int alarm_timer_nsleep(const clockid_t which_clock, int flags,
600 int ret = 0; 618 int ret = 0;
601 struct restart_block *restart; 619 struct restart_block *restart;
602 620
621 if (!alarmtimer_get_rtcdev())
622 return -ENOTSUPP;
623
603 if (!capable(CAP_WAKE_ALARM)) 624 if (!capable(CAP_WAKE_ALARM))
604 return -EPERM; 625 return -EPERM;
605 626