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:   Fri, 23 Sep 2022 22:22:17 +0800
From:   Zhang Rui <rui.zhang@...el.com>
To:     Daniel Lezcano <daniel.lezcano@...aro.org>, rafael@...nel.org
Cc:     linux-kernel@...r.kernel.org, linux-pm@...r.kernel.org,
        Amit Kucheria <amitk@...nel.org>
Subject: Re: [PATCH v4 04/30] thermal/core: Add a generic
 thermal_zone_get_crit_temp() function

On Wed, 2022-09-21 at 11:42 +0200, Daniel Lezcano wrote:
> The thermal zone ops defines a callback to retrieve the critical
> temperature. As the trip handling is being reworked, all the trip
> points will be the same whatever the driver and consequently finding
> the critical trip temperature will be just a loop to search for a
> critical trip point type.
> 
> Provide such a generic function, so we encapsulate the ops
> get_crit_temp() which can be removed when all the backend drivers are
> using the generic trip points handling.
> 
> Signed-off-by: Daniel Lezcano <daniel.lezcano@...aro.org>

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

thanks,
rui

> ---
>  drivers/thermal/thermal_core.c | 27 +++++++++++++++++++++++++++
>  include/linux/thermal.h        |  2 ++
>  2 files changed, 29 insertions(+)
> 
> diff --git a/drivers/thermal/thermal_core.c
> b/drivers/thermal/thermal_core.c
> index fa0f89a24b68..2495c174a226 100644
> --- a/drivers/thermal/thermal_core.c
> +++ b/drivers/thermal/thermal_core.c
> @@ -1144,6 +1144,33 @@ int thermal_zone_get_num_trips(struct
> thermal_zone_device *tz)
>  }
>  EXPORT_SYMBOL_GPL(thermal_zone_get_num_trips);
>  
> +int thermal_zone_get_crit_temp(struct thermal_zone_device *tz, int
> *temp)
> +{
> +	int i, ret = 0;
> +
> +	if (tz->ops->get_crit_temp)
> +		return tz->ops->get_crit_temp(tz, temp);
> +	
> +	if (!tz->trips)
> +		return -EINVAL;
> +
> +	mutex_lock(&tz->lock);
> +
> +	for (i = 0; i < tz->num_trips; i++) {
> +		if (tz->trips[i].type == THERMAL_TRIP_CRITICAL) {
> +			*temp = tz->trips[i].temperature;
> +			goto out;
> +		}
> +	}
> +
> +	ret = -EINVAL;
> +out:
> +	mutex_unlock(&tz->lock);
> +
> +	return ret;
> +}
> +EXPORT_SYMBOL_GPL(thermal_zone_get_crit_temp);
> +
>  static int __thermal_zone_get_trip(struct thermal_zone_device *tz,
> int trip_id,
>  				   struct thermal_trip *trip)
>  {
> diff --git a/include/linux/thermal.h b/include/linux/thermal.h
> index 5350a437f245..66373f872237 100644
> --- a/include/linux/thermal.h
> +++ b/include/linux/thermal.h
> @@ -343,6 +343,8 @@ int thermal_zone_set_trip(struct
> thermal_zone_device *tz, int trip_id,
>  
>  int thermal_zone_get_num_trips(struct thermal_zone_device *tz);
>  
> +int thermal_zone_get_crit_temp(struct thermal_zone_device *tz, int
> *temp);
> +
>  #ifdef CONFIG_THERMAL
>  struct thermal_zone_device *thermal_zone_device_register(const char
> *, int, int,
>  		void *, struct thermal_zone_device_ops *,

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ