cpufreq: conservative: Simplify the condition of storing 'down_threshold'

Message ID 20230912060942.2516761-1-liaochang1@huawei.com
State New
Headers
Series cpufreq: conservative: Simplify the condition of storing 'down_threshold' |

Commit Message

Liao Chang Sept. 12, 2023, 6:09 a.m. UTC
  The governor currently checks if the input new down_threshold is less
than 100 before storing it. However, the up_threshold field of dbs_data
structure is also limited to be less than 100, so this check is
unnecessary and remove it.

Signed-off-by: Liao Chang <liaochang1@huawei.com>
---
 drivers/cpufreq/cpufreq_conservative.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
  

Comments

Viresh Kumar Oct. 5, 2023, 10:59 a.m. UTC | #1
On 12-09-23, 06:09, Liao Chang wrote:
> The governor currently checks if the input new down_threshold is less
> than 100 before storing it. However, the up_threshold field of dbs_data
> structure is also limited to be less than 100, so this check is
> unnecessary and remove it.
> 
> Signed-off-by: Liao Chang <liaochang1@huawei.com>
> ---
>  drivers/cpufreq/cpufreq_conservative.c | 3 +--
>  1 file changed, 1 insertion(+), 2 deletions(-)
> 
> diff --git a/drivers/cpufreq/cpufreq_conservative.c b/drivers/cpufreq/cpufreq_conservative.c
> index b6bd0ff35323..56500b25d77c 100644
> --- a/drivers/cpufreq/cpufreq_conservative.c
> +++ b/drivers/cpufreq/cpufreq_conservative.c
> @@ -187,8 +187,7 @@ static ssize_t down_threshold_store(struct gov_attr_set *attr_set,
>  	ret = sscanf(buf, "%u", &input);
>  
>  	/* cannot be lower than 1 otherwise freq will not fall */
> -	if (ret != 1 || input < 1 || input > 100 ||
> -			input >= dbs_data->up_threshold)
> +	if (ret != 1 || input < 1 || input >= dbs_data->up_threshold)
>  		return -EINVAL;
>  
>  	cs_tuners->down_threshold = input;

Acked-by: Viresh Kumar <viresh.kumar@linaro.org>
  
Rafael J. Wysocki Oct. 6, 2023, 7:56 p.m. UTC | #2
On Thu, Oct 5, 2023 at 12:59 PM Viresh Kumar <viresh.kumar@linaro.org> wrote:
>
> On 12-09-23, 06:09, Liao Chang wrote:
> > The governor currently checks if the input new down_threshold is less
> > than 100 before storing it. However, the up_threshold field of dbs_data
> > structure is also limited to be less than 100, so this check is
> > unnecessary and remove it.
> >
> > Signed-off-by: Liao Chang <liaochang1@huawei.com>
> > ---
> >  drivers/cpufreq/cpufreq_conservative.c | 3 +--
> >  1 file changed, 1 insertion(+), 2 deletions(-)
> >
> > diff --git a/drivers/cpufreq/cpufreq_conservative.c b/drivers/cpufreq/cpufreq_conservative.c
> > index b6bd0ff35323..56500b25d77c 100644
> > --- a/drivers/cpufreq/cpufreq_conservative.c
> > +++ b/drivers/cpufreq/cpufreq_conservative.c
> > @@ -187,8 +187,7 @@ static ssize_t down_threshold_store(struct gov_attr_set *attr_set,
> >       ret = sscanf(buf, "%u", &input);
> >
> >       /* cannot be lower than 1 otherwise freq will not fall */
> > -     if (ret != 1 || input < 1 || input > 100 ||
> > -                     input >= dbs_data->up_threshold)
> > +     if (ret != 1 || input < 1 || input >= dbs_data->up_threshold)
> >               return -EINVAL;
> >
> >       cs_tuners->down_threshold = input;
>
> Acked-by: Viresh Kumar <viresh.kumar@linaro.org>

Applied as 6.7 material, thanks!
  

Patch

diff --git a/drivers/cpufreq/cpufreq_conservative.c b/drivers/cpufreq/cpufreq_conservative.c
index b6bd0ff35323..56500b25d77c 100644
--- a/drivers/cpufreq/cpufreq_conservative.c
+++ b/drivers/cpufreq/cpufreq_conservative.c
@@ -187,8 +187,7 @@  static ssize_t down_threshold_store(struct gov_attr_set *attr_set,
 	ret = sscanf(buf, "%u", &input);
 
 	/* cannot be lower than 1 otherwise freq will not fall */
-	if (ret != 1 || input < 1 || input > 100 ||
-			input >= dbs_data->up_threshold)
+	if (ret != 1 || input < 1 || input >= dbs_data->up_threshold)
 		return -EINVAL;
 
 	cs_tuners->down_threshold = input;