lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date: Thu, 4 Apr 2024 12:15:22 +0100
From: Lukasz Luba <lukasz.luba@....com>
To: "Rafael J. Wysocki" <rjw@...ysocki.net>
Cc: LKML <linux-kernel@...r.kernel.org>,
 Daniel Lezcano <daniel.lezcano@...aro.org>,
 Linux PM <linux-pm@...r.kernel.org>
Subject: Re: [PATCH v1 1/2] thermal: gov_step_wise: Simplify
 get_target_state()

Hi Rafael,

On 4/3/24 19:11, Rafael J. Wysocki wrote:
> From: Rafael J. Wysocki <rafael.j.wysocki@...el.com>
> 
> The step-wise governor's get_target_state() function contains redundant
> braces, redundant parens and a redundant next_target local variable, so
> get rid of all that stuff.
> 
> No intentional functional impact.
> 
> Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@...el.com>
> ---
>   drivers/thermal/gov_step_wise.c |   27 ++++++++++-----------------
>   1 file changed, 10 insertions(+), 17 deletions(-)
> 
> Index: linux-pm/drivers/thermal/gov_step_wise.c
> ===================================================================
> --- linux-pm.orig/drivers/thermal/gov_step_wise.c
> +++ linux-pm/drivers/thermal/gov_step_wise.c
> @@ -32,7 +32,6 @@ static unsigned long get_target_state(st
>   {
>   	struct thermal_cooling_device *cdev = instance->cdev;
>   	unsigned long cur_state;
> -	unsigned long next_target;
>   
>   	/*
>   	 * We keep this instance the way it is by default.
> @@ -40,32 +39,26 @@ static unsigned long get_target_state(st
>   	 * cdev in use to determine the next_target.
>   	 */
>   	cdev->ops->get_cur_state(cdev, &cur_state);
> -	next_target = instance->target;
>   	dev_dbg(&cdev->device, "cur_state=%ld\n", cur_state);
>   
>   	if (!instance->initialized) {
> -		if (throttle) {
> -			next_target = clamp((cur_state + 1), instance->lower, instance->upper);
> -		} else {
> -			next_target = THERMAL_NO_TARGET;
> -		}
> +		if (throttle)
> +			return clamp(cur_state + 1, instance->lower, instance->upper);
>   
> -		return next_target;
> +		return THERMAL_NO_TARGET;
>   	}
>   
>   	if (throttle) {
>   		if (trend == THERMAL_TREND_RAISING)
> -			next_target = clamp((cur_state + 1), instance->lower, instance->upper);
> -	} else {
> -		if (trend == THERMAL_TREND_DROPPING) {
> -			if (cur_state <= instance->lower)
> -				next_target = THERMAL_NO_TARGET;
> -			else
> -				next_target = clamp((cur_state - 1), instance->lower, instance->upper);
> -		}
> +			return clamp(cur_state + 1, instance->lower, instance->upper);
> +	} else if (trend == THERMAL_TREND_DROPPING) {
> +		if (cur_state <= instance->lower)
> +			return THERMAL_NO_TARGET;
> +
> +		return clamp(cur_state - 1, instance->lower, instance->upper);
>   	}
>   
> -	return next_target;
> +	return instance->target;
>   }
>   
>   static void thermal_zone_trip_update(struct thermal_zone_device *tz,
> 
> 
> 

LGTM,

Reviewed-by: Lukasz Luba <lukasz.luba@....com>

Regards,
Lukasz

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ