aboutsummaryrefslogtreecommitdiffstats
path: root/kernel
diff options
context:
space:
mode:
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