]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
watchdog: Switch to use hrtimer_setup()
authorNam Cao <namcao@linutronix.de>
Wed, 5 Feb 2025 10:39:07 +0000 (11:39 +0100)
committerThomas Gleixner <tglx@linutronix.de>
Tue, 18 Feb 2025 09:32:33 +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/a5c62f2b5e1ea1cf4d32f37bc2d21a8eeab2f875.1738746821.git.namcao@linutronix.de
drivers/watchdog/softdog.c
drivers/watchdog/watchdog_dev.c
drivers/watchdog/watchdog_hrtimer_pretimeout.c
kernel/watchdog.c

index 7a1096265f180772021a439c4e394cf7e7c2fb76..0820e35ad2e3cd60c1b2054c87d5275adbb8deb3 100644 (file)
@@ -187,14 +187,12 @@ static int __init softdog_init(void)
        watchdog_set_nowayout(&softdog_dev, nowayout);
        watchdog_stop_on_reboot(&softdog_dev);
 
-       hrtimer_init(&softdog_ticktock, CLOCK_MONOTONIC, HRTIMER_MODE_REL);
-       softdog_ticktock.function = softdog_fire;
+       hrtimer_setup(&softdog_ticktock, softdog_fire, CLOCK_MONOTONIC, HRTIMER_MODE_REL);
 
        if (IS_ENABLED(CONFIG_SOFT_WATCHDOG_PRETIMEOUT)) {
                softdog_info.options |= WDIOF_PRETIMEOUT;
-               hrtimer_init(&softdog_preticktock, CLOCK_MONOTONIC,
-                            HRTIMER_MODE_REL);
-               softdog_preticktock.function = softdog_pretimeout;
+               hrtimer_setup(&softdog_preticktock, softdog_pretimeout, CLOCK_MONOTONIC,
+                             HRTIMER_MODE_REL);
        }
 
        if (soft_active_on_boot)
index 19698d87dc5728003d5aa29d2efb1b4dac9fdf09..8369fd94fc1a61ec359305ac2bf4be7a42bb8940 100644 (file)
@@ -1051,8 +1051,8 @@ static int watchdog_cdev_register(struct watchdog_device *wdd)
        }
 
        kthread_init_work(&wd_data->work, watchdog_ping_work);
-       hrtimer_init(&wd_data->timer, CLOCK_MONOTONIC, HRTIMER_MODE_REL_HARD);
-       wd_data->timer.function = watchdog_timer_expired;
+       hrtimer_setup(&wd_data->timer, watchdog_timer_expired, CLOCK_MONOTONIC,
+                     HRTIMER_MODE_REL_HARD);
        watchdog_hrtimer_pretimeout_init(wdd);
 
        if (wdd->id == 0) {
index 940b53718a91e76d5d011e1a828557be150718e4..fbc7eecd8b203febde984312781fda4b389c622b 100644 (file)
@@ -23,8 +23,8 @@ void watchdog_hrtimer_pretimeout_init(struct watchdog_device *wdd)
 {
        struct watchdog_core_data *wd_data = wdd->wd_data;
 
-       hrtimer_init(&wd_data->pretimeout_timer, CLOCK_MONOTONIC, HRTIMER_MODE_REL);
-       wd_data->pretimeout_timer.function = watchdog_hrtimer_pretimeout;
+       hrtimer_setup(&wd_data->pretimeout_timer, watchdog_hrtimer_pretimeout, CLOCK_MONOTONIC,
+                     HRTIMER_MODE_REL);
 }
 
 void watchdog_hrtimer_pretimeout_start(struct watchdog_device *wdd)
index b2da7de39d06dd931ac214f230956096d60cdbef..6a98dbc931ac641231b9414d8231645900334849 100644 (file)
@@ -797,8 +797,7 @@ static void watchdog_enable(unsigned int cpu)
         * Start the timer first to prevent the hardlockup watchdog triggering
         * before the timer has a chance to fire.
         */
-       hrtimer_init(hrtimer, CLOCK_MONOTONIC, HRTIMER_MODE_REL_HARD);
-       hrtimer->function = watchdog_timer_fn;
+       hrtimer_setup(hrtimer, watchdog_timer_fn, CLOCK_MONOTONIC, HRTIMER_MODE_REL_HARD);
        hrtimer_start(hrtimer, ns_to_ktime(sample_period),
                      HRTIMER_MODE_REL_PINNED_HARD);