Skip to content

Commit 819a95f

Browse files
avaginKAGA-KOKO
authored andcommitted
posix-clocks: Rename the clock_get() callback to clock_get_timespec()
The upcoming support for time namespaces requires to have access to: - The time in a task's time namespace for sys_clock_gettime() - The time in the root name space for common_timer_get() That adds a valid reason to finally implement a separate callback which returns the time in ktime_t format, rather than in (struct timespec). Rename the clock_get() callback to clock_get_timespec() as a preparation for introducing clock_get_ktime(). Suggested-by: Thomas Gleixner <[email protected]> Co-developed-by: Dmitry Safonov <[email protected]> Signed-off-by: Andrei Vagin <[email protected]> Signed-off-by: Dmitry Safonov <[email protected]> Signed-off-by: Thomas Gleixner <[email protected]> Link: https://lore.kernel.org/r/[email protected]
1 parent af993f5 commit 819a95f

File tree

5 files changed

+35
-35
lines changed

5 files changed

+35
-35
lines changed

kernel/time/alarmtimer.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -657,7 +657,7 @@ static int alarm_clock_getres(const clockid_t which_clock, struct timespec64 *tp
657657
}
658658

659659
/**
660-
* alarm_clock_get - posix clock_get interface
660+
* alarm_clock_get - posix clock_get_timespec interface
661661
* @which_clock: clockid
662662
* @tp: timespec to fill.
663663
*
@@ -837,7 +837,7 @@ static int alarm_timer_nsleep(const clockid_t which_clock, int flags,
837837

838838
const struct k_clock alarm_clock = {
839839
.clock_getres = alarm_clock_getres,
840-
.clock_get = alarm_clock_get,
840+
.clock_get_timespec = alarm_clock_get,
841841
.timer_create = alarm_timer_create,
842842
.timer_set = common_timer_set,
843843
.timer_del = common_timer_del,

kernel/time/posix-clock.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -310,8 +310,8 @@ static int pc_clock_settime(clockid_t id, const struct timespec64 *ts)
310310
}
311311

312312
const struct k_clock clock_posix_dynamic = {
313-
.clock_getres = pc_clock_getres,
314-
.clock_set = pc_clock_settime,
315-
.clock_get = pc_clock_gettime,
316-
.clock_adj = pc_clock_adjtime,
313+
.clock_getres = pc_clock_getres,
314+
.clock_set = pc_clock_settime,
315+
.clock_get_timespec = pc_clock_gettime,
316+
.clock_adj = pc_clock_adjtime,
317317
};

kernel/time/posix-cpu-timers.c

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1391,26 +1391,26 @@ static int thread_cpu_timer_create(struct k_itimer *timer)
13911391
}
13921392

13931393
const struct k_clock clock_posix_cpu = {
1394-
.clock_getres = posix_cpu_clock_getres,
1395-
.clock_set = posix_cpu_clock_set,
1396-
.clock_get = posix_cpu_clock_get,
1397-
.timer_create = posix_cpu_timer_create,
1398-
.nsleep = posix_cpu_nsleep,
1399-
.timer_set = posix_cpu_timer_set,
1400-
.timer_del = posix_cpu_timer_del,
1401-
.timer_get = posix_cpu_timer_get,
1402-
.timer_rearm = posix_cpu_timer_rearm,
1394+
.clock_getres = posix_cpu_clock_getres,
1395+
.clock_set = posix_cpu_clock_set,
1396+
.clock_get_timespec = posix_cpu_clock_get,
1397+
.timer_create = posix_cpu_timer_create,
1398+
.nsleep = posix_cpu_nsleep,
1399+
.timer_set = posix_cpu_timer_set,
1400+
.timer_del = posix_cpu_timer_del,
1401+
.timer_get = posix_cpu_timer_get,
1402+
.timer_rearm = posix_cpu_timer_rearm,
14031403
};
14041404

14051405
const struct k_clock clock_process = {
1406-
.clock_getres = process_cpu_clock_getres,
1407-
.clock_get = process_cpu_clock_get,
1408-
.timer_create = process_cpu_timer_create,
1409-
.nsleep = process_cpu_nsleep,
1406+
.clock_getres = process_cpu_clock_getres,
1407+
.clock_get_timespec = process_cpu_clock_get,
1408+
.timer_create = process_cpu_timer_create,
1409+
.nsleep = process_cpu_nsleep,
14101410
};
14111411

14121412
const struct k_clock clock_thread = {
1413-
.clock_getres = thread_cpu_clock_getres,
1414-
.clock_get = thread_cpu_clock_get,
1415-
.timer_create = thread_cpu_timer_create,
1413+
.clock_getres = thread_cpu_clock_getres,
1414+
.clock_get_timespec = thread_cpu_clock_get,
1415+
.timer_create = thread_cpu_timer_create,
14161416
};

kernel/time/posix-timers.c

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -667,7 +667,7 @@ void common_timer_get(struct k_itimer *timr, struct itimerspec64 *cur_setting)
667667
* The timespec64 based conversion is suboptimal, but it's not
668668
* worth to implement yet another callback.
669669
*/
670-
kc->clock_get(timr->it_clock, &ts64);
670+
kc->clock_get_timespec(timr->it_clock, &ts64);
671671
now = timespec64_to_ktime(ts64);
672672

673673
/*
@@ -781,7 +781,7 @@ static void common_hrtimer_arm(struct k_itimer *timr, ktime_t expires,
781781
* Posix magic: Relative CLOCK_REALTIME timers are not affected by
782782
* clock modifications, so they become CLOCK_MONOTONIC based under the
783783
* hood. See hrtimer_init(). Update timr->kclock, so the generic
784-
* functions which use timr->kclock->clock_get() work.
784+
* functions which use timr->kclock->clock_get_timespec() work.
785785
*
786786
* Note: it_clock stays unmodified, because the next timer_set() might
787787
* use ABSTIME, so it needs to switch back.
@@ -1067,7 +1067,7 @@ SYSCALL_DEFINE2(clock_gettime, const clockid_t, which_clock,
10671067
if (!kc)
10681068
return -EINVAL;
10691069

1070-
error = kc->clock_get(which_clock, &kernel_tp);
1070+
error = kc->clock_get_timespec(which_clock, &kernel_tp);
10711071

10721072
if (!error && put_timespec64(&kernel_tp, tp))
10731073
error = -EFAULT;
@@ -1149,7 +1149,7 @@ SYSCALL_DEFINE2(clock_gettime32, clockid_t, which_clock,
11491149
if (!kc)
11501150
return -EINVAL;
11511151

1152-
err = kc->clock_get(which_clock, &ts);
1152+
err = kc->clock_get_timespec(which_clock, &ts);
11531153

11541154
if (!err && put_old_timespec32(&ts, tp))
11551155
err = -EFAULT;
@@ -1261,7 +1261,7 @@ SYSCALL_DEFINE4(clock_nanosleep_time32, clockid_t, which_clock, int, flags,
12611261

12621262
static const struct k_clock clock_realtime = {
12631263
.clock_getres = posix_get_hrtimer_res,
1264-
.clock_get = posix_clock_realtime_get,
1264+
.clock_get_timespec = posix_clock_realtime_get,
12651265
.clock_set = posix_clock_realtime_set,
12661266
.clock_adj = posix_clock_realtime_adj,
12671267
.nsleep = common_nsleep,
@@ -1279,7 +1279,7 @@ static const struct k_clock clock_realtime = {
12791279

12801280
static const struct k_clock clock_monotonic = {
12811281
.clock_getres = posix_get_hrtimer_res,
1282-
.clock_get = posix_ktime_get_ts,
1282+
.clock_get_timespec = posix_ktime_get_ts,
12831283
.nsleep = common_nsleep,
12841284
.timer_create = common_timer_create,
12851285
.timer_set = common_timer_set,
@@ -1295,22 +1295,22 @@ static const struct k_clock clock_monotonic = {
12951295

12961296
static const struct k_clock clock_monotonic_raw = {
12971297
.clock_getres = posix_get_hrtimer_res,
1298-
.clock_get = posix_get_monotonic_raw,
1298+
.clock_get_timespec = posix_get_monotonic_raw,
12991299
};
13001300

13011301
static const struct k_clock clock_realtime_coarse = {
13021302
.clock_getres = posix_get_coarse_res,
1303-
.clock_get = posix_get_realtime_coarse,
1303+
.clock_get_timespec = posix_get_realtime_coarse,
13041304
};
13051305

13061306
static const struct k_clock clock_monotonic_coarse = {
13071307
.clock_getres = posix_get_coarse_res,
1308-
.clock_get = posix_get_monotonic_coarse,
1308+
.clock_get_timespec = posix_get_monotonic_coarse,
13091309
};
13101310

13111311
static const struct k_clock clock_tai = {
13121312
.clock_getres = posix_get_hrtimer_res,
1313-
.clock_get = posix_get_tai,
1313+
.clock_get_timespec = posix_get_tai,
13141314
.nsleep = common_nsleep,
13151315
.timer_create = common_timer_create,
13161316
.timer_set = common_timer_set,
@@ -1326,7 +1326,7 @@ static const struct k_clock clock_tai = {
13261326

13271327
static const struct k_clock clock_boottime = {
13281328
.clock_getres = posix_get_hrtimer_res,
1329-
.clock_get = posix_get_boottime,
1329+
.clock_get_timespec = posix_get_boottime,
13301330
.nsleep = common_nsleep,
13311331
.timer_create = common_timer_create,
13321332
.timer_set = common_timer_set,

kernel/time/posix-timers.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@ struct k_clock {
66
struct timespec64 *tp);
77
int (*clock_set)(const clockid_t which_clock,
88
const struct timespec64 *tp);
9-
int (*clock_get)(const clockid_t which_clock,
10-
struct timespec64 *tp);
9+
int (*clock_get_timespec)(const clockid_t which_clock,
10+
struct timespec64 *tp);
1111
int (*clock_adj)(const clockid_t which_clock, struct __kernel_timex *tx);
1212
int (*timer_create)(struct k_itimer *timer);
1313
int (*nsleep)(const clockid_t which_clock, int flags,

0 commit comments

Comments
 (0)