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: <73f967b1d112a02fd3e48f999f713355da052d9a.camel@intel.com>
Date:   Tue, 14 Mar 2023 02:03:13 +0000
From:   "Zhang, Rui" <rui.zhang@...el.com>
To:     "linux-pm@...r.kernel.org" <linux-pm@...r.kernel.org>,
        "rjw@...ysocki.net" <rjw@...ysocki.net>
CC:     "srinivas.pandruvada@...ux.intel.com" 
        <srinivas.pandruvada@...ux.intel.com>,
        "viresh.kumar@...aro.org" <viresh.kumar@...aro.org>,
        "Wang, Quanxian" <quanxian.wang@...el.com>,
        "linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>,
        "daniel.lezcano@...aro.org" <daniel.lezcano@...aro.org>,
        "linux-acpi@...r.kernel.org" <linux-acpi@...r.kernel.org>
Subject: Re: [PATCH v2 2/4] thermal: core: Introduce
 thermal_cooling_device_present()

On Mon, 2023-03-13 at 15:28 +0100, Rafael J. Wysocki wrote:
> From: Rafael J. Wysocki <rafael.j.wysocki@...el.com>
> 
> Introduce a helper function, thermal_cooling_device_present(), for
> checking if the given cooling device is in the list of registered
> cooling devices to avoid some code duplication in a subsequent
> patch.
> 
> No expected functional impact.
> 
> Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@...el.com>

Tested-by: Zhang Rui <rui.zhang@...el.com>
Reviewed-by: Zhang Rui <rui.zhang@...el.com>

thanks,
rui

> ---
> 
> v1 -> v2: No changes
> 
> ---
>  drivers/thermal/thermal_core.c |   21 +++++++++++++++------
>  1 file changed, 15 insertions(+), 6 deletions(-)
> 
> Index: linux-pm/drivers/thermal/thermal_core.c
> ===================================================================
> --- linux-pm.orig/drivers/thermal/thermal_core.c
> +++ linux-pm/drivers/thermal/thermal_core.c
> @@ -1045,6 +1045,18 @@ devm_thermal_of_cooling_device_register(
>  }
>  EXPORT_SYMBOL_GPL(devm_thermal_of_cooling_device_register);
>  
> +static bool thermal_cooling_device_present(struct
> thermal_cooling_device *cdev)
> +{
> +	struct thermal_cooling_device *pos = NULL;
> +
> +	list_for_each_entry(pos, &thermal_cdev_list, node) {
> +		if (pos == cdev)
> +			return true;
> +	}
> +
> +	return false;
> +}
> +
>  static void __unbind(struct thermal_zone_device *tz, int mask,
>  		     struct thermal_cooling_device *cdev)
>  {
> @@ -1067,20 +1079,17 @@ void thermal_cooling_device_unregister(s
>  	int i;
>  	const struct thermal_zone_params *tzp;
>  	struct thermal_zone_device *tz;
> -	struct thermal_cooling_device *pos = NULL;
>  
>  	if (!cdev)
>  		return;
>  
>  	mutex_lock(&thermal_list_lock);
> -	list_for_each_entry(pos, &thermal_cdev_list, node)
> -		if (pos == cdev)
> -			break;
> -	if (pos != cdev) {
> -		/* thermal cooling device not found */
> +
> +	if (!thermal_cooling_device_present(cdev)) {
>  		mutex_unlock(&thermal_list_lock);
>  		return;
>  	}
> +
>  	list_del(&cdev->node);
>  
>  	/* Unbind all thermal zones associated with 'this' cdev */
> 
> 
> 

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ