Skip to content

Commit c9bd83a

Browse files
covanamKAGA-KOKO
authored andcommitted
hrtimers: Introduce hrtimer_setup_sleeper_on_stack()
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 <[email protected]> Signed-off-by: Thomas Gleixner <[email protected]> Link: https://lore.kernel.org/all/7b5e18e6dd0ace9eaa211201528cb9dc23752454.1730386209.git.namcao@linutronix.de
1 parent 444cb7d commit c9bd83a

File tree

2 files changed

+16
-0
lines changed

2 files changed

+16
-0
lines changed

include/linux/hrtimer.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -238,6 +238,8 @@ extern void hrtimer_setup_on_stack(struct hrtimer *timer,
238238
extern void hrtimer_init_sleeper_on_stack(struct hrtimer_sleeper *sl,
239239
clockid_t clock_id,
240240
enum hrtimer_mode mode);
241+
extern void hrtimer_setup_sleeper_on_stack(struct hrtimer_sleeper *sl, clockid_t clock_id,
242+
enum hrtimer_mode mode);
241243

242244
#ifdef CONFIG_DEBUG_OBJECTS_TIMERS
243245
extern void destroy_hrtimer_on_stack(struct hrtimer *timer);

kernel/time/hrtimer.c

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2065,6 +2065,20 @@ void hrtimer_init_sleeper_on_stack(struct hrtimer_sleeper *sl,
20652065
}
20662066
EXPORT_SYMBOL_GPL(hrtimer_init_sleeper_on_stack);
20672067

2068+
/**
2069+
* hrtimer_setup_sleeper_on_stack - initialize a sleeper in stack memory
2070+
* @sl: sleeper to be initialized
2071+
* @clock_id: the clock to be used
2072+
* @mode: timer mode abs/rel
2073+
*/
2074+
void hrtimer_setup_sleeper_on_stack(struct hrtimer_sleeper *sl,
2075+
clockid_t clock_id, enum hrtimer_mode mode)
2076+
{
2077+
debug_init_on_stack(&sl->timer, clock_id, mode);
2078+
__hrtimer_init_sleeper(sl, clock_id, mode);
2079+
}
2080+
EXPORT_SYMBOL_GPL(hrtimer_setup_sleeper_on_stack);
2081+
20682082
int nanosleep_copyout(struct restart_block *restart, struct timespec64 *ts)
20692083
{
20702084
switch(restart->nanosleep.type) {

0 commit comments

Comments
 (0)