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:   Tue, 06 Nov 2018 16:11:51 +0800
From:   Zhang Rui <rui.zhang@...el.com>
To:     Bartlomiej Zolnierkiewicz <b.zolnierkie@...sung.com>,
        Eduardo Valentin <edubezval@...il.com>
Cc:     Amit kucheria <amit.kucheria@...aro.org>,
        Eric Anholt <eric@...olt.net>,
        Stefan Wahren <stefan.wahren@...e.com>,
        Markus Mayer <mmayer@...adcom.com>,
        bcm-kernel-feedback-list@...adcom.com,
        Heiko Stuebner <heiko@...ech.de>,
        Thierry Reding <thierry.reding@...il.com>,
        Jonathan Hunter <jonathanh@...dia.com>,
        Keerthy <j-keerthy@...com>,
        Masahiro Yamada <yamada.masahiro@...ionext.com>,
        Jun Nie <jun.nie@...aro.org>,
        Baoyou Xie <baoyou.xie@...aro.org>,
        Shawn Guo <shawnguo@...nel.org>, linux-pm@...r.kernel.org,
        linux-kernel@...r.kernel.org
Subject: Re: [PATCH v2 01/17] thermal: add thermal_zone_set_mode() helper

On 三, 2018-10-17 at 17:52 +0200, Bartlomiej Zolnierkiewicz wrote:
> In order to remove the code duplication and prepare for further
> changes:
> 
> * Add thermal_zone_set_mode() helper. Then update core code and
>   drivers to use it.
> 
> There should be no functional changes caused by this patch.
> 
> Signed-off-by: Bartlomiej Zolnierkiewicz <b.zolnierkie@...sung.com>
> ---
>  drivers/thermal/hisi_thermal.c     | 14 ++------------
>  drivers/thermal/of-thermal.c       |  3 ++-
>  drivers/thermal/rockchip_thermal.c | 26 +++++++++-----------------
>  drivers/thermal/thermal_helpers.c  | 14 ++++++++++++++
>  drivers/thermal/thermal_sysfs.c    |  8 +++++---
>  include/linux/thermal.h            |  5 +++++
>  6 files changed, 37 insertions(+), 33 deletions(-)
> 
> 
>  
> diff --git a/drivers/thermal/thermal_helpers.c
> b/drivers/thermal/thermal_helpers.c
> index 2ba756a..b18cee2 100644
> --- a/drivers/thermal/thermal_helpers.c
> +++ b/drivers/thermal/thermal_helpers.c
> @@ -224,3 +224,17 @@ int thermal_zone_get_offset(struct
> thermal_zone_device *tz)
>  	return 0;
>  }
>  EXPORT_SYMBOL_GPL(thermal_zone_get_offset);
> +
> +/**
> + * thermal_zone_set_mode() - sets mode of thermal zone device
> + * @tz: a valid pointer to a struct thermal_zone_device
> + * @mode: mode to be set
> + *
> + * Return: On success returns 0, an error code otherwise.
> + */
> +int thermal_zone_set_mode(struct thermal_zone_device *tz,
> +			  enum thermal_device_mode mode)
> +{
> +	return tz->ops->set_mode(tz, mode);

better to check tz->ops->set_mode first.

thanks,
rui
> +}
> +EXPORT_SYMBOL_GPL(thermal_zone_set_mode);
> diff --git a/drivers/thermal/thermal_sysfs.c
> b/drivers/thermal/thermal_sysfs.c
> index 2241cea..2e9e762 100644
> --- a/drivers/thermal/thermal_sysfs.c
> +++ b/drivers/thermal/thermal_sysfs.c
> @@ -69,17 +69,19 @@
>  {
>  	struct thermal_zone_device *tz = to_thermal_zone(dev);
>  	int result;
> +	enum thermal_device_mode mode;
>  
>  	if (!tz->ops->set_mode)
>  		return -EPERM;
>  
>  	if (!strncmp(buf, "enabled", sizeof("enabled") - 1))
> -		result = tz->ops->set_mode(tz,
> THERMAL_DEVICE_ENABLED);
> +		mode = THERMAL_DEVICE_ENABLED;
>  	else if (!strncmp(buf, "disabled", sizeof("disabled") - 1))
> -		result = tz->ops->set_mode(tz,
> THERMAL_DEVICE_DISABLED);
> +		mode = THERMAL_DEVICE_DISABLED;
>  	else
> -		result = -EINVAL;
> +		return -EINVAL;
>  
> +	result = thermal_zone_set_mode(tz, mode);
>  	if (result)
>  		return result;
>  
> diff --git a/include/linux/thermal.h b/include/linux/thermal.h
> index 5f4705f..9d21fd1 100644
> --- a/include/linux/thermal.h
> +++ b/include/linux/thermal.h
> @@ -452,6 +452,8 @@ struct thermal_cooling_device *
>  int thermal_zone_get_temp(struct thermal_zone_device *tz, int
> *temp);
>  int thermal_zone_get_slope(struct thermal_zone_device *tz);
>  int thermal_zone_get_offset(struct thermal_zone_device *tz);
> +int thermal_zone_set_mode(struct thermal_zone_device *tz,
> +			  enum thermal_device_mode mode);
>  
>  int get_tz_trend(struct thermal_zone_device *, int);
>  struct thermal_instance *get_thermal_instance(struct
> thermal_zone_device *,
> @@ -518,6 +520,9 @@ static inline int thermal_zone_get_slope(
>  static inline int thermal_zone_get_offset(
>  		struct thermal_zone_device *tz)
>  { return -ENODEV; }
> +static inline int thermal_zone_set_mode(
> +		struct thermal_zone_device *tz, enum
> thermal_device_mode mode)
> +{ return -ENODEV; }
>  static inline int get_tz_trend(struct thermal_zone_device *tz, int
> trip)
>  { return -ENODEV; }
>  static inline struct thermal_instance *

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ