thermal: intel: powerclamp: Simplify idle_inject_update()
PATCH v2 1/1 thermal: intel: powerclamp: Simplify idle_inject_update()
Drop the local update variable and call idle_inject_set_duration() directly instead. Also return !should_skip directly.
---
Changes in v2:
- Call get_run_time() after powerclamp_adjust_controls() as before and as suggested by Sashiko [1]
- v1: https://lore.kernel.org/r/[email protected]/
[1] https://sashiko.dev/#/patchset/20260828184354.39423-2-blum%40kernel.org
--- drivers/thermal/intel/intel_powerclamp.c | 15 +++------------ 1 file changed, 3 insertions(+), 12 deletions(-)
drivers/thermal/intel/intel_powerclamp.c +3 -12
@@ -536,23 +536,17 @@ static struct idle_inject_device *ii_dev;*/ static bool idle_inject_update (void ) { -bool update = false; -/* We can't sleep in this callback */ if (!mutex_trylock (&powerclamp_lock))return true;if (!(powerclamp_data.count % powerclamp_data.window_size_now)) { +unsigned int runtime; should_skip =powerclamp_adjust_controls (powerclamp_data.target_ratio, powerclamp_data.guard, powerclamp_data.window_size_now); - update = true; - } - -if (update) { -unsigned int runtime =get_run_time (); - + runtime =get_run_time ();idle_inject_set_duration (ii_dev, runtime, duration); }
@@ -560,10 +554,7 @@ static bool idle_inject_update(void)mutex_unlock (&powerclamp_lock); -if (should_skip) -return false; - -return true; +return !should_skip; }/* This function starts idle injection by calling idle_inject_start() */
Quoted 48 lines · Thorsten Blum
Drop the local update variable and call
idle_inject_set_duration()directly instead. Also return !should_skip directly.Signed-off-by Thorsten Blum <[email protected]>---
Changes in v2:
- Callget_run_time()afterpowerclamp_adjust_controls()as before and as suggested by Sashiko [1]
- v1: https://lore.kernel.org/r/[email protected]/[1] https://sashiko.dev/#/patchset/20260828184354.39423-2-blum%40kernel.org
--- drivers/thermal/intel/intel_powerclamp.c | 15 +++------------ 1 file changed, 3 insertions(+), 12 deletions(-)drivers/thermal/intel/intel_powerclamp.c +2
-8@@ -536,23 +536,17 @@ static struct idle_inject_device *ii_dev;*/ static bool idle_inject_update (void ) { -bool update = false; -/* We can't sleep in this callback */ if (!mutex_trylock (&powerclamp_lock))return true;if (!(powerclamp_data.count % powerclamp_data.window_size_now)) { +unsigned int runtime; should_skip =powerclamp_adjust_controls (powerclamp_data.target_ratio, powerclamp_data.guard, powerclamp_data.window_size_now); - update = true; - } - -if (update) { -unsigned int runtime =get_run_time (); - + runtime =get_run_time ();idle_inject_set_duration (ii_dev, runtime, duration); }@@ -560,10 +554,7 @@ static bool idle_inject_update(void)
drivers/thermal/intel/intel_powerclamp.c static bool idle_inject_update(void) · line 560
Quoted 10 lines
drivers/thermal/intel/intel_powerclamp.c +1
-4mutex_unlock (&powerclamp_lock); -if (should_skip) -return false; - -return true; +return !should_skip; }/* This function starts idle injection by calling idle_inject_start() */
Applied as 7.4 material, thanks!