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]
Message-ID: <b51726f2-7a6d-4ef2-8fdc-28e76e4ab5d0@arm.com>
Date: Tue, 22 Oct 2024 22:45:47 +0100
From: Lukasz Luba <lukasz.luba@....com>
To: "Rafael J. Wysocki" <rjw@...ysocki.net>
Cc: LKML <linux-kernel@...r.kernel.org>, Linux PM <linux-pm@...r.kernel.org>,
 Daniel Lezcano <daniel.lezcano@...aro.org>, Zhang Rui <rui.zhang@...el.com>,
 Srinivas Pandruvada <srinivas.pandruvada@...ux.intel.com>
Subject: Re: [PATCH v2 06/11] thermal: core: Introduce thermal_instance_add()



On 10/10/24 23:13, Rafael J. Wysocki wrote:
> From: Rafael J. Wysocki <rafael.j.wysocki@...el.com>
> 
> To reduce the number of redundant result checks in
> thermal_bind_cdev_to_trip() and make the code in it easier to
> follow, move some of it to a new function called thermal_instance_add()
> and make thermal_bind_cdev_to_trip() invoke that function.
> 
> No intentional functional impact.
> 
> Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@...el.com>
> ---
> 
> This is a resend of
> 
> https://lore.kernel.org/linux-pm/2641944.Lt9SDvczpP@rjwysocki.net/
> 
> ---
>   drivers/thermal/thermal_core.c |   46 ++++++++++++++++++++++++++---------------
>   1 file changed, 30 insertions(+), 16 deletions(-)
> 
> Index: linux-pm/drivers/thermal/thermal_core.c
> ===================================================================
> --- linux-pm.orig/drivers/thermal/thermal_core.c
> +++ linux-pm/drivers/thermal/thermal_core.c
> @@ -743,6 +743,28 @@ struct thermal_zone_device *thermal_zone
>    *				     binding, and unbinding.
>    */
>   
> +static int thermal_instance_add(struct thermal_instance *new_instance,
> +				struct thermal_cooling_device *cdev,
> +				struct thermal_trip_desc *td)
> +{
> +	struct thermal_instance *instance;
> +
> +	list_for_each_entry(instance, &td->thermal_instances, trip_node) {
> +		if (instance->cdev == cdev)
> +			return -EEXIST;
> +	}
> +
> +	list_add_tail(&new_instance->trip_node, &td->thermal_instances);
> +
> +	mutex_lock(&cdev->lock);
> +
> +	list_add_tail(&new_instance->cdev_node, &cdev->thermal_instances);
> +
> +	mutex_unlock(&cdev->lock);
> +
> +	return 0;
> +}
> +
>   /**
>    * thermal_bind_cdev_to_trip - bind a cooling device to a thermal zone
>    * @tz:		pointer to struct thermal_zone_device
> @@ -761,7 +783,7 @@ static int thermal_bind_cdev_to_trip(str
>   				     struct thermal_cooling_device *cdev,
>   				     struct cooling_spec *cool_spec)
>   {
> -	struct thermal_instance *dev, *instance;
> +	struct thermal_instance *dev;
>   	bool upper_no_limit;
>   	int result;
>   
> @@ -823,23 +845,15 @@ static int thermal_bind_cdev_to_trip(str
>   	if (result)
>   		goto remove_trip_file;
>   
> -	mutex_lock(&cdev->lock);
> -	list_for_each_entry(instance, &td->thermal_instances, trip_node)
> -		if (instance->cdev == cdev) {
> -			result = -EEXIST;
> -			break;
> -		}
> -	if (!result) {
> -		list_add_tail(&dev->trip_node, &td->thermal_instances);
> -		list_add_tail(&dev->cdev_node, &cdev->thermal_instances);
> -	}
> -	mutex_unlock(&cdev->lock);
> +	result = thermal_instance_add(dev, cdev, td);
> +	if (result)
> +		goto remove_weight_file;
>   
> -	if (!result) {
> -		thermal_governor_update_tz(tz, THERMAL_TZ_BIND_CDEV);
> -		return 0;
> -	}
> +	thermal_governor_update_tz(tz, THERMAL_TZ_BIND_CDEV);
> +
> +	return 0;
>   
> +remove_weight_file:
>   	device_remove_file(&tz->device, &dev->weight_attr);
>   remove_trip_file:
>   	device_remove_file(&tz->device, &dev->attr);
> 
> 
> 


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

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ