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: <037c72a28a803e922819179cb0371af555bd6d56.camel@intel.com>
Date: Tue, 20 Aug 2024 07:04:39 +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: "lukasz.luba@....com" <lukasz.luba@....com>,
	"linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>,
	"daniel.lezcano@...aro.org" <daniel.lezcano@...aro.org>
Subject: Re: [PATCH v3 01/14] thermal: core: Fold two functions into their
 respective callers

On Mon, 2024-08-19 at 17:50 +0200, Rafael J. Wysocki wrote:
> From: Rafael J. Wysocki <rafael.j.wysocki@...el.com>
> 
> Fold bind_cdev() into __thermal_cooling_device_register() and
> bind_tz()
> into thermal_zone_device_register_with_trips() to reduce code bloat
> and
> make it somewhat easier to follow the code flow.
> 
> No intentional functional impact.
> 
> Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@...el.com>

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

thanks,
rui
> ---
> 
> v1 -> v3: No changes
> 
> ---
>  drivers/thermal/thermal_core.c |   55 ++++++++++++++----------------
> -----------
>  1 file changed, 19 insertions(+), 36 deletions(-)
> 
> Index: linux-pm/drivers/thermal/thermal_core.c
> ===================================================================
> --- linux-pm.orig/drivers/thermal/thermal_core.c
> +++ linux-pm/drivers/thermal/thermal_core.c
> @@ -991,20 +991,6 @@ void print_bind_err_msg(struct thermal_z
>                 tz->type, cdev->type, ret);
>  }
>  
> -static void bind_cdev(struct thermal_cooling_device *cdev)
> -{
> -       int ret;
> -       struct thermal_zone_device *pos = NULL;
> -
> -       list_for_each_entry(pos, &thermal_tz_list, node) {
> -               if (pos->ops.bind) {
> -                       ret = pos->ops.bind(pos, cdev);
> -                       if (ret)
> -                               print_bind_err_msg(pos, cdev, ret);
> -               }
> -       }
> -}
> -
>  /**
>   * __thermal_cooling_device_register() - register a new thermal
> cooling device
>   * @np:                a pointer to a device tree node.
> @@ -1100,7 +1086,13 @@ __thermal_cooling_device_register(struct
>         list_add(&cdev->node, &thermal_cdev_list);
>  
>         /* Update binding information for 'this' new cdev */
> -       bind_cdev(cdev);
> +       list_for_each_entry(pos, &thermal_tz_list, node) {
> +               if (pos->ops.bind) {
> +                       ret = pos->ops.bind(pos, cdev);
> +                       if (ret)
> +                               print_bind_err_msg(pos, cdev, ret);
> +               }
> +       }
>  
>         list_for_each_entry(pos, &thermal_tz_list, node)
>                 if (atomic_cmpxchg(&pos->need_update, 1, 0))
> @@ -1338,25 +1330,6 @@ void thermal_cooling_device_unregister(s
>  }
>  EXPORT_SYMBOL_GPL(thermal_cooling_device_unregister);
>  
> -static void bind_tz(struct thermal_zone_device *tz)
> -{
> -       int ret;
> -       struct thermal_cooling_device *pos = NULL;
> -
> -       if (!tz->ops.bind)
> -               return;
> -
> -       mutex_lock(&thermal_list_lock);
> -
> -       list_for_each_entry(pos, &thermal_cdev_list, node) {
> -               ret = tz->ops.bind(tz, pos);
> -               if (ret)
> -                       print_bind_err_msg(tz, pos, ret);
> -       }
> -
> -       mutex_unlock(&thermal_list_lock);
> -}
> -
>  static void thermal_set_delay_jiffies(unsigned long *delay_jiffies,
> int delay_ms)
>  {
>         *delay_jiffies = msecs_to_jiffies(delay_ms);
> @@ -1554,13 +1527,23 @@ thermal_zone_device_register_with_trips(
>         }
>  
>         mutex_lock(&thermal_list_lock);
> +
>         mutex_lock(&tz->lock);
>         list_add_tail(&tz->node, &thermal_tz_list);
>         mutex_unlock(&tz->lock);
> -       mutex_unlock(&thermal_list_lock);
>  
>         /* Bind cooling devices for this zone */
> -       bind_tz(tz);
> +       if (tz->ops.bind) {
> +               struct thermal_cooling_device *cdev;
> +
> +               list_for_each_entry(cdev, &thermal_cdev_list, node) {
> +                       result = tz->ops.bind(tz, cdev);
> +                       if (result)
> +                               print_bind_err_msg(tz, cdev, result);
> +               }
> +       }
> +
> +       mutex_unlock(&thermal_list_lock);
>  
>         thermal_zone_device_init(tz);
>         /* Update the new thermal zone and mark it as already
> updated. */
> 
> 
> 

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ