[PATCH 15/44] powercap: Switch to use hrtimer_setup()

Nam Cao posted 44 patches 4 weeks ago
[PATCH 15/44] powercap: 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: "Rafael J. Wysocki" <rafael@kernel.org>
---
 drivers/powercap/idle_inject.c       | 3 +--
 drivers/powercap/intel_rapl_common.c | 3 +--
 2 files changed, 2 insertions(+), 4 deletions(-)

diff --git a/drivers/powercap/idle_inject.c b/drivers/powercap/idle_inject.c
index bafc59904ed3..29f9f452d445 100644
--- a/drivers/powercap/idle_inject.c
+++ b/drivers/powercap/idle_inject.c
@@ -339,8 +339,7 @@ struct idle_inject_device *idle_inject_register_full(struct cpumask *cpumask,
 		return NULL;
 
 	cpumask_copy(to_cpumask(ii_dev->cpumask), cpumask);
-	hrtimer_init(&ii_dev->timer, CLOCK_MONOTONIC, HRTIMER_MODE_REL);
-	ii_dev->timer.function = idle_inject_timer_fn;
+	hrtimer_setup(&ii_dev->timer, idle_inject_timer_fn, CLOCK_MONOTONIC, HRTIMER_MODE_REL);
 	ii_dev->latency_us = UINT_MAX;
 	ii_dev->update = update;
 
diff --git a/drivers/powercap/intel_rapl_common.c b/drivers/powercap/intel_rapl_common.c
index 5e793b80fd6b..e675d4240d9f 100644
--- a/drivers/powercap/intel_rapl_common.c
+++ b/drivers/powercap/intel_rapl_common.c
@@ -2063,8 +2063,7 @@ int rapl_package_add_pmu(struct rapl_package *rp)
 	raw_spin_lock_init(&data->lock);
 	INIT_LIST_HEAD(&data->active_list);
 	data->timer_interval = ms_to_ktime(rapl_pmu.timer_ms);
-	hrtimer_init(&data->hrtimer, CLOCK_MONOTONIC, HRTIMER_MODE_REL);
-	data->hrtimer.function = rapl_hrtimer_handle;
+	hrtimer_setup(&data->hrtimer, rapl_hrtimer_handle, CLOCK_MONOTONIC, HRTIMER_MODE_REL);
 
 	return rapl_pmu_update(rp);
 }
-- 
2.39.5
Re: [PATCH 15/44] powercap: Switch to use hrtimer_setup()
Posted by Rafael J. Wysocki 3 weeks, 6 days ago
On Mon, Oct 28, 2024 at 8:35 AM 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.
>
> Signed-off-by: Nam Cao <namcao@linutronix.de>
> ---
> Cc: "Rafael J. Wysocki" <rafael@kernel.org>

Fine by me.

Acked-by: "Rafael J. Wysocki" <rafael@kernel.org>

> ---
>  drivers/powercap/idle_inject.c       | 3 +--
>  drivers/powercap/intel_rapl_common.c | 3 +--
>  2 files changed, 2 insertions(+), 4 deletions(-)
>
> diff --git a/drivers/powercap/idle_inject.c b/drivers/powercap/idle_inject.c
> index bafc59904ed3..29f9f452d445 100644
> --- a/drivers/powercap/idle_inject.c
> +++ b/drivers/powercap/idle_inject.c
> @@ -339,8 +339,7 @@ struct idle_inject_device *idle_inject_register_full(struct cpumask *cpumask,
>                 return NULL;
>
>         cpumask_copy(to_cpumask(ii_dev->cpumask), cpumask);
> -       hrtimer_init(&ii_dev->timer, CLOCK_MONOTONIC, HRTIMER_MODE_REL);
> -       ii_dev->timer.function = idle_inject_timer_fn;
> +       hrtimer_setup(&ii_dev->timer, idle_inject_timer_fn, CLOCK_MONOTONIC, HRTIMER_MODE_REL);
>         ii_dev->latency_us = UINT_MAX;
>         ii_dev->update = update;
>
> diff --git a/drivers/powercap/intel_rapl_common.c b/drivers/powercap/intel_rapl_common.c
> index 5e793b80fd6b..e675d4240d9f 100644
> --- a/drivers/powercap/intel_rapl_common.c
> +++ b/drivers/powercap/intel_rapl_common.c
> @@ -2063,8 +2063,7 @@ int rapl_package_add_pmu(struct rapl_package *rp)
>         raw_spin_lock_init(&data->lock);
>         INIT_LIST_HEAD(&data->active_list);
>         data->timer_interval = ms_to_ktime(rapl_pmu.timer_ms);
> -       hrtimer_init(&data->hrtimer, CLOCK_MONOTONIC, HRTIMER_MODE_REL);
> -       data->hrtimer.function = rapl_hrtimer_handle;
> +       hrtimer_setup(&data->hrtimer, rapl_hrtimer_handle, CLOCK_MONOTONIC, HRTIMER_MODE_REL);
>
>         return rapl_pmu_update(rp);
>  }
> --
> 2.39.5
>