Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

watchdog: 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@linutronix.de>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Link: https://lore.kernel.org/all/a5c62f2b5e1ea1cf4d32f37bc2d21a8eeab2f875.1738746821.git.namcao@linutronix.de

authored by

Nam Cao and committed by
Thomas Gleixner
d2254b06 1654eba8

+8 -11
+3 -5
drivers/watchdog/softdog.c
··· 187 187 watchdog_set_nowayout(&softdog_dev, nowayout); 188 188 watchdog_stop_on_reboot(&softdog_dev); 189 189 190 - hrtimer_init(&softdog_ticktock, CLOCK_MONOTONIC, HRTIMER_MODE_REL); 191 - softdog_ticktock.function = softdog_fire; 190 + hrtimer_setup(&softdog_ticktock, softdog_fire, CLOCK_MONOTONIC, HRTIMER_MODE_REL); 192 191 193 192 if (IS_ENABLED(CONFIG_SOFT_WATCHDOG_PRETIMEOUT)) { 194 193 softdog_info.options |= WDIOF_PRETIMEOUT; 195 - hrtimer_init(&softdog_preticktock, CLOCK_MONOTONIC, 196 - HRTIMER_MODE_REL); 197 - softdog_preticktock.function = softdog_pretimeout; 194 + hrtimer_setup(&softdog_preticktock, softdog_pretimeout, CLOCK_MONOTONIC, 195 + HRTIMER_MODE_REL); 198 196 } 199 197 200 198 if (soft_active_on_boot)
+2 -2
drivers/watchdog/watchdog_dev.c
··· 1051 1051 } 1052 1052 1053 1053 kthread_init_work(&wd_data->work, watchdog_ping_work); 1054 - hrtimer_init(&wd_data->timer, CLOCK_MONOTONIC, HRTIMER_MODE_REL_HARD); 1055 - wd_data->timer.function = watchdog_timer_expired; 1054 + hrtimer_setup(&wd_data->timer, watchdog_timer_expired, CLOCK_MONOTONIC, 1055 + HRTIMER_MODE_REL_HARD); 1056 1056 watchdog_hrtimer_pretimeout_init(wdd); 1057 1057 1058 1058 if (wdd->id == 0) {
+2 -2
drivers/watchdog/watchdog_hrtimer_pretimeout.c
··· 23 23 { 24 24 struct watchdog_core_data *wd_data = wdd->wd_data; 25 25 26 - hrtimer_init(&wd_data->pretimeout_timer, CLOCK_MONOTONIC, HRTIMER_MODE_REL); 27 - wd_data->pretimeout_timer.function = watchdog_hrtimer_pretimeout; 26 + hrtimer_setup(&wd_data->pretimeout_timer, watchdog_hrtimer_pretimeout, CLOCK_MONOTONIC, 27 + HRTIMER_MODE_REL); 28 28 } 29 29 30 30 void watchdog_hrtimer_pretimeout_start(struct watchdog_device *wdd)
+1 -2
kernel/watchdog.c
··· 797 797 * Start the timer first to prevent the hardlockup watchdog triggering 798 798 * before the timer has a chance to fire. 799 799 */ 800 - hrtimer_init(hrtimer, CLOCK_MONOTONIC, HRTIMER_MODE_REL_HARD); 801 - hrtimer->function = watchdog_timer_fn; 800 + hrtimer_setup(hrtimer, watchdog_timer_fn, CLOCK_MONOTONIC, HRTIMER_MODE_REL_HARD); 802 801 hrtimer_start(hrtimer, ns_to_ktime(sample_period), 803 802 HRTIMER_MODE_REL_PINNED_HARD); 804 803