]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
perf: Switch to use hrtimer_setup()
authorNam Cao <namcao@linutronix.de>
Wed, 5 Feb 2025 10:39:02 +0000 (11:39 +0100)
committerThomas Gleixner <tglx@linutronix.de>
Tue, 18 Feb 2025 09:32:32 +0000 (10:32 +0100)
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@linutronix.de>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Link: https://lore.kernel.org/all/f611e6d3fc6996bbcf0e19fe234f75edebe4332f.1738746821.git.namcao@linutronix.de
kernel/events/core.c

index bcb09e011e9e112787edcb52b4523e50352115d0..db5792d79b7f16a3cd1b6736f5d33853cd15b6ec 100644 (file)
@@ -1147,8 +1147,8 @@ static void __perf_mux_hrtimer_init(struct perf_cpu_pmu_context *cpc, int cpu)
        cpc->hrtimer_interval = ns_to_ktime(NSEC_PER_MSEC * interval);
 
        raw_spin_lock_init(&cpc->hrtimer_lock);
-       hrtimer_init(timer, CLOCK_MONOTONIC, HRTIMER_MODE_ABS_PINNED_HARD);
-       timer->function = perf_mux_hrtimer_handler;
+       hrtimer_setup(timer, perf_mux_hrtimer_handler, CLOCK_MONOTONIC,
+                     HRTIMER_MODE_ABS_PINNED_HARD);
 }
 
 static int perf_mux_hrtimer_restart(struct perf_cpu_pmu_context *cpc)
@@ -11367,8 +11367,7 @@ static void perf_swevent_init_hrtimer(struct perf_event *event)
        if (!is_sampling_event(event))
                return;
 
-       hrtimer_init(&hwc->hrtimer, CLOCK_MONOTONIC, HRTIMER_MODE_REL_HARD);
-       hwc->hrtimer.function = perf_swevent_hrtimer;
+       hrtimer_setup(&hwc->hrtimer, perf_swevent_hrtimer, CLOCK_MONOTONIC, HRTIMER_MODE_REL_HARD);
 
        /*
         * Since hrtimers have a fixed rate, we can do a static freq->period