Commit 41b3b8df authored by Andrei Vagin's avatar Andrei Vagin Committed by Thomas Gleixner

alarmtimer: Rename gettime() callback to get_ktime()

The upcoming support for time namespaces requires to have access to:

  - The time in a tasks time namespace for sys_clock_gettime()
  - The time in the root name space for common_timer_get()

struct alarm_base needs to follow the same naming convention, so rename
.gettime() callback into get_ktime() as a preparation for introducing
get_timespec().
Suggested-by: default avatarThomas Gleixner <tglx@linutronix.de>
Co-developed-by: default avatarDmitry Safonov <dima@arista.com>
Signed-off-by: default avatarAndrei Vagin <avagin@gmail.com>
Signed-off-by: default avatarDmitry Safonov <dima@arista.com>
Signed-off-by: default avatarThomas Gleixner <tglx@linutronix.de>
Link: https://lore.kernel.org/r/20191112012724.250792-8-dima@arista.com
parent eaf80194
...@@ -36,13 +36,13 @@ ...@@ -36,13 +36,13 @@
* struct alarm_base - Alarm timer bases * struct alarm_base - Alarm timer bases
* @lock: Lock for syncrhonized access to the base * @lock: Lock for syncrhonized access to the base
* @timerqueue: Timerqueue head managing the list of events * @timerqueue: Timerqueue head managing the list of events
* @gettime: Function to read the time correlating to the base * @get_ktime: Function to read the time correlating to the base
* @base_clockid: clockid for the base * @base_clockid: clockid for the base
*/ */
static struct alarm_base { static struct alarm_base {
spinlock_t lock; spinlock_t lock;
struct timerqueue_head timerqueue; struct timerqueue_head timerqueue;
ktime_t (*gettime)(void); ktime_t (*get_ktime)(void);
clockid_t base_clockid; clockid_t base_clockid;
} alarm_bases[ALARM_NUMTYPE]; } alarm_bases[ALARM_NUMTYPE];
...@@ -207,7 +207,7 @@ static enum hrtimer_restart alarmtimer_fired(struct hrtimer *timer) ...@@ -207,7 +207,7 @@ static enum hrtimer_restart alarmtimer_fired(struct hrtimer *timer)
spin_unlock_irqrestore(&base->lock, flags); spin_unlock_irqrestore(&base->lock, flags);
if (alarm->function) if (alarm->function)
restart = alarm->function(alarm, base->gettime()); restart = alarm->function(alarm, base->get_ktime());
spin_lock_irqsave(&base->lock, flags); spin_lock_irqsave(&base->lock, flags);
if (restart != ALARMTIMER_NORESTART) { if (restart != ALARMTIMER_NORESTART) {
...@@ -217,7 +217,7 @@ static enum hrtimer_restart alarmtimer_fired(struct hrtimer *timer) ...@@ -217,7 +217,7 @@ static enum hrtimer_restart alarmtimer_fired(struct hrtimer *timer)
} }
spin_unlock_irqrestore(&base->lock, flags); spin_unlock_irqrestore(&base->lock, flags);
trace_alarmtimer_fired(alarm, base->gettime()); trace_alarmtimer_fired(alarm, base->get_ktime());
return ret; return ret;
} }
...@@ -225,7 +225,7 @@ static enum hrtimer_restart alarmtimer_fired(struct hrtimer *timer) ...@@ -225,7 +225,7 @@ static enum hrtimer_restart alarmtimer_fired(struct hrtimer *timer)
ktime_t alarm_expires_remaining(const struct alarm *alarm) ktime_t alarm_expires_remaining(const struct alarm *alarm)
{ {
struct alarm_base *base = &alarm_bases[alarm->type]; struct alarm_base *base = &alarm_bases[alarm->type];
return ktime_sub(alarm->node.expires, base->gettime()); return ktime_sub(alarm->node.expires, base->get_ktime());
} }
EXPORT_SYMBOL_GPL(alarm_expires_remaining); EXPORT_SYMBOL_GPL(alarm_expires_remaining);
...@@ -270,7 +270,7 @@ static int alarmtimer_suspend(struct device *dev) ...@@ -270,7 +270,7 @@ static int alarmtimer_suspend(struct device *dev)
spin_unlock_irqrestore(&base->lock, flags); spin_unlock_irqrestore(&base->lock, flags);
if (!next) if (!next)
continue; continue;
delta = ktime_sub(next->expires, base->gettime()); delta = ktime_sub(next->expires, base->get_ktime());
if (!min || (delta < min)) { if (!min || (delta < min)) {
expires = next->expires; expires = next->expires;
min = delta; min = delta;
...@@ -364,7 +364,7 @@ void alarm_start(struct alarm *alarm, ktime_t start) ...@@ -364,7 +364,7 @@ void alarm_start(struct alarm *alarm, ktime_t start)
hrtimer_start(&alarm->timer, alarm->node.expires, HRTIMER_MODE_ABS); hrtimer_start(&alarm->timer, alarm->node.expires, HRTIMER_MODE_ABS);
spin_unlock_irqrestore(&base->lock, flags); spin_unlock_irqrestore(&base->lock, flags);
trace_alarmtimer_start(alarm, base->gettime()); trace_alarmtimer_start(alarm, base->get_ktime());
} }
EXPORT_SYMBOL_GPL(alarm_start); EXPORT_SYMBOL_GPL(alarm_start);
...@@ -377,7 +377,7 @@ void alarm_start_relative(struct alarm *alarm, ktime_t start) ...@@ -377,7 +377,7 @@ void alarm_start_relative(struct alarm *alarm, ktime_t start)
{ {
struct alarm_base *base = &alarm_bases[alarm->type]; struct alarm_base *base = &alarm_bases[alarm->type];
start = ktime_add_safe(start, base->gettime()); start = ktime_add_safe(start, base->get_ktime());
alarm_start(alarm, start); alarm_start(alarm, start);
} }
EXPORT_SYMBOL_GPL(alarm_start_relative); EXPORT_SYMBOL_GPL(alarm_start_relative);
...@@ -414,7 +414,7 @@ int alarm_try_to_cancel(struct alarm *alarm) ...@@ -414,7 +414,7 @@ int alarm_try_to_cancel(struct alarm *alarm)
alarmtimer_dequeue(base, alarm); alarmtimer_dequeue(base, alarm);
spin_unlock_irqrestore(&base->lock, flags); spin_unlock_irqrestore(&base->lock, flags);
trace_alarmtimer_cancel(alarm, base->gettime()); trace_alarmtimer_cancel(alarm, base->get_ktime());
return ret; return ret;
} }
EXPORT_SYMBOL_GPL(alarm_try_to_cancel); EXPORT_SYMBOL_GPL(alarm_try_to_cancel);
...@@ -474,7 +474,7 @@ u64 alarm_forward_now(struct alarm *alarm, ktime_t interval) ...@@ -474,7 +474,7 @@ u64 alarm_forward_now(struct alarm *alarm, ktime_t interval)
{ {
struct alarm_base *base = &alarm_bases[alarm->type]; struct alarm_base *base = &alarm_bases[alarm->type];
return alarm_forward(alarm, base->gettime(), interval); return alarm_forward(alarm, base->get_ktime(), interval);
} }
EXPORT_SYMBOL_GPL(alarm_forward_now); EXPORT_SYMBOL_GPL(alarm_forward_now);
...@@ -500,7 +500,7 @@ static void alarmtimer_freezerset(ktime_t absexp, enum alarmtimer_type type) ...@@ -500,7 +500,7 @@ static void alarmtimer_freezerset(ktime_t absexp, enum alarmtimer_type type)
return; return;
} }
delta = ktime_sub(absexp, base->gettime()); delta = ktime_sub(absexp, base->get_ktime());
spin_lock_irqsave(&freezer_delta_lock, flags); spin_lock_irqsave(&freezer_delta_lock, flags);
if (!freezer_delta || (delta < freezer_delta)) { if (!freezer_delta || (delta < freezer_delta)) {
...@@ -632,7 +632,7 @@ static void alarm_timer_arm(struct k_itimer *timr, ktime_t expires, ...@@ -632,7 +632,7 @@ static void alarm_timer_arm(struct k_itimer *timr, ktime_t expires,
struct alarm_base *base = &alarm_bases[alarm->type]; struct alarm_base *base = &alarm_bases[alarm->type];
if (!absolute) if (!absolute)
expires = ktime_add_safe(expires, base->gettime()); expires = ktime_add_safe(expires, base->get_ktime());
if (sigev_none) if (sigev_none)
alarm->node.expires = expires; alarm->node.expires = expires;
else else
...@@ -670,7 +670,7 @@ static int alarm_clock_get_timespec(clockid_t which_clock, struct timespec64 *tp ...@@ -670,7 +670,7 @@ static int alarm_clock_get_timespec(clockid_t which_clock, struct timespec64 *tp
if (!alarmtimer_get_rtcdev()) if (!alarmtimer_get_rtcdev())
return -EINVAL; return -EINVAL;
*tp = ktime_to_timespec64(base->gettime()); *tp = ktime_to_timespec64(base->get_ktime());
return 0; return 0;
} }
...@@ -747,7 +747,7 @@ static int alarmtimer_do_nsleep(struct alarm *alarm, ktime_t absexp, ...@@ -747,7 +747,7 @@ static int alarmtimer_do_nsleep(struct alarm *alarm, ktime_t absexp,
struct timespec64 rmt; struct timespec64 rmt;
ktime_t rem; ktime_t rem;
rem = ktime_sub(absexp, alarm_bases[type].gettime()); rem = ktime_sub(absexp, alarm_bases[type].get_ktime());
if (rem <= 0) if (rem <= 0)
return 0; return 0;
...@@ -816,7 +816,7 @@ static int alarm_timer_nsleep(const clockid_t which_clock, int flags, ...@@ -816,7 +816,7 @@ static int alarm_timer_nsleep(const clockid_t which_clock, int flags,
exp = timespec64_to_ktime(*tsreq); exp = timespec64_to_ktime(*tsreq);
/* Convert (if necessary) to absolute time */ /* Convert (if necessary) to absolute time */
if (flags != TIMER_ABSTIME) { if (flags != TIMER_ABSTIME) {
ktime_t now = alarm_bases[type].gettime(); ktime_t now = alarm_bases[type].get_ktime();
exp = ktime_add_safe(now, exp); exp = ktime_add_safe(now, exp);
} }
...@@ -882,9 +882,9 @@ static int __init alarmtimer_init(void) ...@@ -882,9 +882,9 @@ static int __init alarmtimer_init(void)
/* Initialize alarm bases */ /* Initialize alarm bases */
alarm_bases[ALARM_REALTIME].base_clockid = CLOCK_REALTIME; alarm_bases[ALARM_REALTIME].base_clockid = CLOCK_REALTIME;
alarm_bases[ALARM_REALTIME].gettime = &ktime_get_real; alarm_bases[ALARM_REALTIME].get_ktime = &ktime_get_real;
alarm_bases[ALARM_BOOTTIME].base_clockid = CLOCK_BOOTTIME; alarm_bases[ALARM_BOOTTIME].base_clockid = CLOCK_BOOTTIME;
alarm_bases[ALARM_BOOTTIME].gettime = &ktime_get_boottime; alarm_bases[ALARM_BOOTTIME].get_ktime = &ktime_get_boottime;
for (i = 0; i < ALARM_NUMTYPE; i++) { for (i = 0; i < ALARM_NUMTYPE; i++) {
timerqueue_init_head(&alarm_bases[i].timerqueue); timerqueue_init_head(&alarm_bases[i].timerqueue);
spin_lock_init(&alarm_bases[i].lock); spin_lock_init(&alarm_bases[i].lock);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment