[tip: timers/cleanups] fork: Switch to use hrtimer_setup()

From: tip-bot2 for Nam Cao
Date: Tue Feb 18 2025 - 04:50:49 EST


The following commit has been merged into the timers/cleanups branch of tip:

Commit-ID: 91b7be704dd4991bb6ec8bb67480993e82a673bb
Gitweb: https://git.kernel.org/tip/91b7be704dd4991bb6ec8bb67480993e82a673bb
Author: Nam Cao <namcao@xxxxxxxxxxxxx>
AuthorDate: Wed, 05 Feb 2025 11:39:01 +01:00
Committer: Thomas Gleixner <tglx@xxxxxxxxxxxxx>
CommitterDate: Tue, 18 Feb 2025 10:32:32 +01:00

fork: Switch to use hrtimer_setup()

hrtimer_setup() takes the callback function pointer as argument and
initializes the timer completely.

Replace hrtimer_init() and the open coded initialization of
hrtimer::function with the new setup mechanism.

Patch was created by using Coccinelle.

Signed-off-by: Nam Cao <namcao@xxxxxxxxxxxxx>
Signed-off-by: Thomas Gleixner <tglx@xxxxxxxxxxxxx>
Link: https://lore.kernel.org/all/174111145b945391e48936d6debcd43caec3e406.1738746821.git.namcao@xxxxxxxxxxxxx

---
kernel/fork.c | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/kernel/fork.c b/kernel/fork.c
index 735405a..e27fe5d 100644
--- a/kernel/fork.c
+++ b/kernel/fork.c
@@ -1891,8 +1891,7 @@ static int copy_signal(unsigned long clone_flags, struct task_struct *tsk)
#ifdef CONFIG_POSIX_TIMERS
INIT_HLIST_HEAD(&sig->posix_timers);
INIT_HLIST_HEAD(&sig->ignored_posix_timers);
- hrtimer_init(&sig->real_timer, CLOCK_MONOTONIC, HRTIMER_MODE_REL);
- sig->real_timer.function = it_real_fn;
+ hrtimer_setup(&sig->real_timer, it_real_fn, CLOCK_MONOTONIC, HRTIMER_MODE_REL);
#endif

task_lock(current->group_leader);