[PATCH] thermal: intel: Slighly simplify duration_set()

Christophe JAILLET posted 1 patch 3 weeks, 2 days ago
drivers/thermal/intel/intel_powerclamp.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
[PATCH] thermal: intel: Slighly simplify duration_set()
Posted by Christophe JAILLET 3 weeks, 2 days ago
there is no need to call clamp here(). The same tests have already been
performed a few lines above, and there is a "goto exit;" if outside of the
range.

While at it, also remove an un-needed initialization of 'ret'.

Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
---
Based on my testing, gcc is not smart enough to get rid of the redundnat
tests by itself.

This patch is compile tested only
---
 drivers/thermal/intel/intel_powerclamp.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/thermal/intel/intel_powerclamp.c b/drivers/thermal/intel/intel_powerclamp.c
index bd7fd98dc310..ba9c4a1224ca 100644
--- a/drivers/thermal/intel/intel_powerclamp.c
+++ b/drivers/thermal/intel/intel_powerclamp.c
@@ -80,7 +80,7 @@ static unsigned int window_size;
 
 static int duration_set(const char *arg, const struct kernel_param *kp)
 {
-	int ret = 0;
+	int ret;
 	unsigned long new_duration;
 
 	ret = kstrtoul(arg, 10, &new_duration);
@@ -94,7 +94,7 @@ static int duration_set(const char *arg, const struct kernel_param *kp)
 	}
 
 	mutex_lock(&powerclamp_lock);
-	duration = clamp(new_duration, 6ul, 25ul) * 1000;
+	duration = new_duration * 1000;
 	mutex_unlock(&powerclamp_lock);
 exit:
 
-- 
2.55.0
Re: [PATCH] thermal: intel: Slighly simplify duration_set()
Posted by Markus Elfring 3 weeks ago
…
> While at it, also remove an un-needed initialization of 'ret'.
                              unneeded?

See also once more:
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/Documentation/process/submitting-patches.rst?h=v7.3-rc1#n111


> ---
> Based on my testing, gcc is not smart enough to get rid of the redundnat
…
                                                                 redundant?

How do you think about to avoid another typo in the summary phrase?


> ---
>  drivers/thermal/intel/intel_powerclamp.c | 4 ++--


Regards,
Markus