[PATCH 24/31] tracing/osnoise: Switch to use hrtimer_setup()

Nam Cao posted 31 patches 4 weeks ago
[PATCH 24/31] tracing/osnoise: Switch to use hrtimer_setup()
Posted by Nam Cao 4 weeks ago
There is a newly introduced hrtimer_setup() which will replace
hrtimer_init(). This new function is similar to the old one, except that it
also sanity-checks and initializes the timer's callback function.

Switch to use this new function.

Patch was created by using Coccinelle.

Signed-off-by: Nam Cao <namcao@linutronix.de>
---
Cc: Steven Rostedt <rostedt@goodmis.org>
---
 kernel/trace/trace_osnoise.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/kernel/trace/trace_osnoise.c b/kernel/trace/trace_osnoise.c
index 1439064f65d6..e50f7a1aae6d 100644
--- a/kernel/trace/trace_osnoise.c
+++ b/kernel/trace/trace_osnoise.c
@@ -1896,8 +1896,7 @@ static int timerlat_main(void *data)
 	tlat->count = 0;
 	tlat->tracing_thread = false;
 
-	hrtimer_init(&tlat->timer, CLOCK_MONOTONIC, HRTIMER_MODE_ABS_PINNED_HARD);
-	tlat->timer.function = timerlat_irq;
+	hrtimer_setup(&tlat->timer, timerlat_irq, CLOCK_MONOTONIC, HRTIMER_MODE_ABS_PINNED_HARD);
 	tlat->kthread = current;
 	osn_var->pid = current->pid;
 	/*
@@ -2461,8 +2460,7 @@ static int timerlat_fd_open(struct inode *inode, struct file *file)
 	tlat = this_cpu_tmr_var();
 	tlat->count = 0;
 
-	hrtimer_init(&tlat->timer, CLOCK_MONOTONIC, HRTIMER_MODE_ABS_PINNED_HARD);
-	tlat->timer.function = timerlat_irq;
+	hrtimer_setup(&tlat->timer, timerlat_irq, CLOCK_MONOTONIC, HRTIMER_MODE_ABS_PINNED_HARD);
 
 	migrate_enable();
 	return 0;
-- 
2.39.5
Re: [PATCH 24/31] tracing/osnoise: Switch to use hrtimer_setup()
Posted by Steven Rostedt 4 weeks ago
On Mon, 28 Oct 2024 08:31:57 +0100
Nam Cao <namcao@linutronix.de> wrote:

> There is a newly introduced hrtimer_setup() which will replace
> hrtimer_init(). This new function is similar to the old one, except that it
> also sanity-checks and initializes the timer's callback function.
> 
> Switch to use this new function.
> 
> Patch was created by using Coccinelle.
> 

Acked-by: Steven Rostedt (Google) <rostedt@goodmis.org>

-- Steve

> Signed-off-by: Nam Cao <namcao@linutronix.de>
> ---
> Cc: Steven Rostedt <rostedt@goodmis.org>
> ---
>  kernel/trace/trace_osnoise.c | 6 ++----
>  1 file changed, 2 insertions(+), 4 deletions(-)
> 
> diff --git a/kernel/trace/trace_osnoise.c b/kernel/trace/trace_osnoise.c
> index 1439064f65d6..e50f7a1aae6d 100644
> --- a/kernel/trace/trace_osnoise.c
> +++ b/kernel/trace/trace_osnoise.c
> @@ -1896,8 +1896,7 @@ static int timerlat_main(void *data)
>  	tlat->count = 0;
>  	tlat->tracing_thread = false;
>  
> -	hrtimer_init(&tlat->timer, CLOCK_MONOTONIC, HRTIMER_MODE_ABS_PINNED_HARD);
> -	tlat->timer.function = timerlat_irq;
> +	hrtimer_setup(&tlat->timer, timerlat_irq, CLOCK_MONOTONIC, HRTIMER_MODE_ABS_PINNED_HARD);
>  	tlat->kthread = current;
>  	osn_var->pid = current->pid;
>  	/*
> @@ -2461,8 +2460,7 @@ static int timerlat_fd_open(struct inode *inode, struct file *file)
>  	tlat = this_cpu_tmr_var();
>  	tlat->count = 0;
>  
> -	hrtimer_init(&tlat->timer, CLOCK_MONOTONIC, HRTIMER_MODE_ABS_PINNED_HARD);
> -	tlat->timer.function = timerlat_irq;
> +	hrtimer_setup(&tlat->timer, timerlat_irq, CLOCK_MONOTONIC, HRTIMER_MODE_ABS_PINNED_HARD);
>  
>  	migrate_enable();
>  	return 0;