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: <046303cd-54d0-42f0-990d-2d18a9de1f3e@linaro.org>
Date: Tue, 16 Jul 2024 15:07:39 +0200
From: Daniel Lezcano <daniel.lezcano@...aro.org>
To: Raphael Gallais-Pou <rgallaispou@...il.com>,
 "Rafael J. Wysocki" <rafael@...nel.org>, Zhang Rui <rui.zhang@...el.com>,
 Lukasz Luba <lukasz.luba@....com>,
 Maxime Coquelin <mcoquelin.stm32@...il.com>,
 Alexandre Torgue <alexandre.torgue@...s.st.com>,
 Patrice Chotard <patrice.chotard@...s.st.com>, Rob Herring
 <robh@...nel.org>, Krzysztof Kozlowski <krzk+dt@...nel.org>,
 Conor Dooley <conor+dt@...nel.org>
Cc: linux-pm@...r.kernel.org, linux-kernel@...r.kernel.org,
 linux-stm32@...md-mailman.stormreply.com,
 linux-arm-kernel@...ts.infradead.org, devicetree@...r.kernel.org
Subject: Re: [PATCH v3 2/2] thermal: sti: depend on THERMAL_OF subsystem

On 14/07/2024 13:42, Raphael Gallais-Pou wrote:
> Switch to thermal_of_zone to handle thermal-zones. Replace
> thermal_zone_device_register() by devm_thermal_of_zone_register() and
> remove ops st_thermal_get_trip_type, st_thermal_get_trip_temp.
> 
> Signed-off-by: Raphael Gallais-Pou <rgallaispou@...il.com>
> ---
> Changes in v3:
> - Fix unmet dependency when building with ARM64 compiler
>    https://lore.kernel.org/lkml/202406270605.qodaWd4n-lkp@intel.com/
> - Remove no more used polling_delay variable detected by kernel robot
>    https://lore.kernel.org/lkml/202406270530.kN5wIswi-lkp@intel.com/
> Changes in v2:
> - Remove unused struct thermal_trip trip
> ---
>   drivers/thermal/st/Kconfig      |  2 ++
>   drivers/thermal/st/st_thermal.c | 28 ++++++++++------------------
>   2 files changed, 12 insertions(+), 18 deletions(-)
> 
> diff --git a/drivers/thermal/st/Kconfig b/drivers/thermal/st/Kconfig
> index ecbdf4ef00f4..95a634709a99 100644
> --- a/drivers/thermal/st/Kconfig
> +++ b/drivers/thermal/st/Kconfig
> @@ -5,12 +5,14 @@
>   
>   config ST_THERMAL
>   	tristate "Thermal sensors on STMicroelectronics STi series of SoCs"
> +	depends on THERMAL_OF
>   	help
>   	  Support for thermal sensors on STMicroelectronics STi series of SoCs.
>   
>   config ST_THERMAL_MEMMAP
>   	select ST_THERMAL
>   	tristate "STi series memory mapped access based thermal sensors"
> +	depends on THERMAL_OF

Given the changes below it is possible to move this dependency in the 
upper Kconfig AFAICS:

diff --git a/drivers/thermal/Kconfig b/drivers/thermal/Kconfig
index ed16897584b4..b6b916e7e294 100644
--- a/drivers/thermal/Kconfig
+++ b/drivers/thermal/Kconfig
@@ -429,7 +429,7 @@ source "drivers/thermal/samsung/Kconfig"
  endmenu

  menu "STMicroelectronics thermal drivers"
-depends on (ARCH_STI || ARCH_STM32) && OF
+depends on (ARCH_STI || ARCH_STM32) && THERMAL_OF
  source "drivers/thermal/st/Kconfig"
  endmenu

THERMAL_OF depends on OF

>   config STM32_THERMAL
>   	tristate "Thermal framework support on STMicroelectronics STM32 series of SoCs"
> diff --git a/drivers/thermal/st/st_thermal.c b/drivers/thermal/st/st_thermal.c
> index 5f33543a3a54..23597819ce84 100644
> --- a/drivers/thermal/st/st_thermal.c
> +++ b/drivers/thermal/st/st_thermal.c
> @@ -12,6 +12,7 @@
>   #include <linux/of_device.h>
>   
>   #include "st_thermal.h"
> +#include "../thermal_hwmon.h"
>   
>   /* The Thermal Framework expects millidegrees */
>   #define mcelsius(temp)			((temp) * 1000)
> @@ -135,8 +136,6 @@ static struct thermal_zone_device_ops st_tz_ops = {
>   	.get_temp	= st_thermal_get_temp,
>   };
>   
> -static struct thermal_trip trip;
> -
>   int st_thermal_register(struct platform_device *pdev,
>   			const struct of_device_id *st_thermal_of_match)
>   {
> @@ -145,7 +144,6 @@ int st_thermal_register(struct platform_device *pdev,
>   	struct device_node *np = dev->of_node;
>   	const struct of_device_id *match;
>   
> -	int polling_delay;
>   	int ret;
>   
>   	if (!np) {
> @@ -197,29 +195,22 @@ int st_thermal_register(struct platform_device *pdev,
>   	if (ret)
>   		goto sensor_off;
>   
> -	polling_delay = sensor->ops->register_enable_irq ? 0 : 1000;
> -
> -	trip.temperature = sensor->cdata->crit_temp;
> -	trip.type = THERMAL_TRIP_CRITICAL;
> -
>   	sensor->thermal_dev =
> -		thermal_zone_device_register_with_trips(dev_name(dev), &trip, 1, sensor,
> -							&st_tz_ops, NULL, 0, polling_delay);
> +		devm_thermal_of_zone_register(dev, 0, sensor, &st_tz_ops);
>   	if (IS_ERR(sensor->thermal_dev)) {
> -		dev_err(dev, "failed to register thermal zone device\n");
> +		dev_err(dev, "failed to register thermal of zone\n");
>   		ret = PTR_ERR(sensor->thermal_dev);
>   		goto sensor_off;
>   	}
> -	ret = thermal_zone_device_enable(sensor->thermal_dev);
> -	if (ret)
> -		goto tzd_unregister;
>   
>   	platform_set_drvdata(pdev, sensor);
>   
> -	return 0;
> +	/*
> +	 * devm_thermal_of_zone_register() doesn't enable hwmon by default
> +	 * Enable it here
> +	 */
> +	return devm_thermal_add_hwmon_sysfs(dev, sensor->thermal_dev);

Other drivers ignore the return code or just print a message in case it 
is not zero. Otherwise, that makes the thermal driver to fail because of 
hwmon.

> -tzd_unregister:
> -	thermal_zone_device_unregister(sensor->thermal_dev);
>   sensor_off:
>   	st_thermal_sensor_off(sensor);
>   
> @@ -232,7 +223,8 @@ void st_thermal_unregister(struct platform_device *pdev)
>   	struct st_thermal_sensor *sensor = platform_get_drvdata(pdev);
>   
>   	st_thermal_sensor_off(sensor);
> -	thermal_zone_device_unregister(sensor->thermal_dev);
> +	thermal_remove_hwmon_sysfs(sensor->thermal_dev);
> +	devm_thermal_of_zone_unregister(sensor->dev, sensor->thermal_dev);
>   }
>   EXPORT_SYMBOL_GPL(st_thermal_unregister);
>   
> 

-- 
<http://www.linaro.org/> Linaro.org │ Open source software for ARM SoCs

Follow Linaro:  <http://www.facebook.com/pages/Linaro> Facebook |
<http://twitter.com/#!/linaroorg> Twitter |
<http://www.linaro.org/linaro-blog/> Blog
"

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ