]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
hrtimers: Introduce hrtimer_setup_sleeper_on_stack()
authorNam Cao <namcao@linutronix.de>
Thu, 31 Oct 2024 15:14:22 +0000 (16:14 +0100)
committerThomas Gleixner <tglx@linutronix.de>
Thu, 7 Nov 2024 01:47:05 +0000 (02:47 +0100)
The hrtimer_init*() API is replaced by hrtimer_setup*() variants to
initialize the timer including the callback function at once.

hrtimer_init_sleeper_on_stack() does not need user to setup the callback
function separately, so a new variant would not be strictly necessary.

Nonetheless, to keep the naming convention consistent, introduce
hrtimer_setup_sleeper_on_stack(). hrtimer_init_on_stack() will be removed
once all users are converted.

Signed-off-by: Nam Cao <namcao@linutronix.de>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Link: https://lore.kernel.org/all/7b5e18e6dd0ace9eaa211201528cb9dc23752454.1730386209.git.namcao@linutronix.de
include/linux/hrtimer.h
kernel/time/hrtimer.c

index 2da513f8d66acc628ac420c93dae2cbed5680a27..48872a2b40718cc7d0c1893651767a3c992483b9 100644 (file)
@@ -238,6 +238,8 @@ extern void hrtimer_setup_on_stack(struct hrtimer *timer,
 extern void hrtimer_init_sleeper_on_stack(struct hrtimer_sleeper *sl,
                                          clockid_t clock_id,
                                          enum hrtimer_mode mode);
+extern void hrtimer_setup_sleeper_on_stack(struct hrtimer_sleeper *sl, clockid_t clock_id,
+                                          enum hrtimer_mode mode);
 
 #ifdef CONFIG_DEBUG_OBJECTS_TIMERS
 extern void destroy_hrtimer_on_stack(struct hrtimer *timer);
index daee4e27f839509236c35b867ddd979733d1170d..1d1f5c03673cef90474e54c09e16ba840d91a19c 100644 (file)
@@ -2065,6 +2065,20 @@ void hrtimer_init_sleeper_on_stack(struct hrtimer_sleeper *sl,
 }
 EXPORT_SYMBOL_GPL(hrtimer_init_sleeper_on_stack);
 
+/**
+ * hrtimer_setup_sleeper_on_stack - initialize a sleeper in stack memory
+ * @sl:                sleeper to be initialized
+ * @clock_id:  the clock to be used
+ * @mode:      timer mode abs/rel
+ */
+void hrtimer_setup_sleeper_on_stack(struct hrtimer_sleeper *sl,
+                                   clockid_t clock_id, enum hrtimer_mode mode)
+{
+       debug_init_on_stack(&sl->timer, clock_id, mode);
+       __hrtimer_init_sleeper(sl, clock_id, mode);
+}
+EXPORT_SYMBOL_GPL(hrtimer_setup_sleeper_on_stack);
+
 int nanosleep_copyout(struct restart_block *restart, struct timespec64 *ts)
 {
        switch(restart->nanosleep.type) {