* [PATCH] powercap: use us_to_ktime() where appropriate
@ 2025-08-13 7:54 Xichao Zhao
2025-08-21 19:59 ` Rafael J. Wysocki
0 siblings, 1 reply; 2+ messages in thread
From: Xichao Zhao @ 2025-08-13 7:54 UTC (permalink / raw)
To: rafael; +Cc: linux-pm, linux-kernel, Xichao Zhao
The duration_us, idle_duration_us, and run_duration_us are more suitable
for using the us_to_ktime() function. This can make the code more concise
and enhance readability.
Signed-off-by: Xichao Zhao <zhao.xichao@vivo.com>
---
drivers/powercap/idle_inject.c | 5 ++---
1 file changed, 2 insertions(+), 3 deletions(-)
diff --git a/drivers/powercap/idle_inject.c b/drivers/powercap/idle_inject.c
index 5ad7cc438068..a25eb2018acd 100644
--- a/drivers/powercap/idle_inject.c
+++ b/drivers/powercap/idle_inject.c
@@ -133,7 +133,7 @@ static enum hrtimer_restart idle_inject_timer_fn(struct hrtimer *timer)
duration_us = READ_ONCE(ii_dev->run_duration_us);
duration_us += READ_ONCE(ii_dev->idle_duration_us);
- hrtimer_forward_now(timer, ns_to_ktime(duration_us * NSEC_PER_USEC));
+ hrtimer_forward_now(timer, us_to_ktime(duration_us));
return HRTIMER_RESTART;
}
@@ -232,8 +232,7 @@ int idle_inject_start(struct idle_inject_device *ii_dev)
idle_inject_wakeup(ii_dev);
hrtimer_start(&ii_dev->timer,
- ns_to_ktime((idle_duration_us + run_duration_us) *
- NSEC_PER_USEC),
+ us_to_ktime(idle_duration_us + run_duration_us),
HRTIMER_MODE_REL);
return 0;
--
2.34.1
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] powercap: use us_to_ktime() where appropriate
2025-08-13 7:54 [PATCH] powercap: use us_to_ktime() where appropriate Xichao Zhao
@ 2025-08-21 19:59 ` Rafael J. Wysocki
0 siblings, 0 replies; 2+ messages in thread
From: Rafael J. Wysocki @ 2025-08-21 19:59 UTC (permalink / raw)
To: Xichao Zhao; +Cc: rafael, linux-pm, linux-kernel
On Wed, Aug 13, 2025 at 9:54 AM Xichao Zhao <zhao.xichao@vivo.com> wrote:
>
> The duration_us, idle_duration_us, and run_duration_us are more suitable
> for using the us_to_ktime() function. This can make the code more concise
> and enhance readability.
>
> Signed-off-by: Xichao Zhao <zhao.xichao@vivo.com>
> ---
> drivers/powercap/idle_inject.c | 5 ++---
> 1 file changed, 2 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/powercap/idle_inject.c b/drivers/powercap/idle_inject.c
> index 5ad7cc438068..a25eb2018acd 100644
> --- a/drivers/powercap/idle_inject.c
> +++ b/drivers/powercap/idle_inject.c
> @@ -133,7 +133,7 @@ static enum hrtimer_restart idle_inject_timer_fn(struct hrtimer *timer)
> duration_us = READ_ONCE(ii_dev->run_duration_us);
> duration_us += READ_ONCE(ii_dev->idle_duration_us);
>
> - hrtimer_forward_now(timer, ns_to_ktime(duration_us * NSEC_PER_USEC));
> + hrtimer_forward_now(timer, us_to_ktime(duration_us));
>
> return HRTIMER_RESTART;
> }
> @@ -232,8 +232,7 @@ int idle_inject_start(struct idle_inject_device *ii_dev)
> idle_inject_wakeup(ii_dev);
>
> hrtimer_start(&ii_dev->timer,
> - ns_to_ktime((idle_duration_us + run_duration_us) *
> - NSEC_PER_USEC),
> + us_to_ktime(idle_duration_us + run_duration_us),
> HRTIMER_MODE_REL);
>
> return 0;
> --
Applied as 6.18 material with adjusted subject and changelog, thanks!
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2025-08-21 20:00 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-08-13 7:54 [PATCH] powercap: use us_to_ktime() where appropriate Xichao Zhao
2025-08-21 19:59 ` Rafael J. Wysocki
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).