diff mbox series

[V2,3/6] thermal: Register hwmon in thermal_zone_of_sensor_register_param()

Message ID 20181215023010.2857-4-marek.vasut+renesas@gmail.com (mailing list archive)
State Superseded
Delegated to: Geert Uytterhoeven
Headers show
Series thermal: Align devm_thermal_zone_{device,of_sensor}_register | expand

Commit Message

Marek Vasut Dec. 15, 2018, 2:30 a.m. UTC
Register hwmon sysfs interface in thermal_zone_of_sensor_register_param()
in case thermal_zone_params->no_hwmon is set to false. This behavior is
the same as thermal_zone_device_register().

Signed-off-by: Marek Vasut <marek.vasut+renesas@gmail.com>
Cc: Daniel Lezcano <daniel.lezcano@linaro.org>
Cc: Eduardo Valentin <edubezval@gmail.com>
Cc: Wolfram Sang <wsa+renesas@sang-engineering.com>
Cc: Zhang Rui <rui.zhang@intel.com>
Cc: linux-renesas-soc@vger.kernel.org
To: linux-pm@vger.kernel.org
---
V2: No change
---
 drivers/thermal/of-thermal.c | 12 +++++++++++-
 1 file changed, 11 insertions(+), 1 deletion(-)

Comments

Simon Horman Dec. 17, 2018, 11:46 a.m. UTC | #1
On Sat, Dec 15, 2018 at 03:30:07AM +0100, Marek Vasut wrote:
> Register hwmon sysfs interface in thermal_zone_of_sensor_register_param()
> in case thermal_zone_params->no_hwmon is set to false. This behavior is
> the same as thermal_zone_device_register().

If it is the same then is there any value in a helper function?

Regardless, this patch looks good to me.

Reviewed-by: Simon Horman <horms+renesas@verge.net.au>

> Signed-off-by: Marek Vasut <marek.vasut+renesas@gmail.com>
> Cc: Daniel Lezcano <daniel.lezcano@linaro.org>
> Cc: Eduardo Valentin <edubezval@gmail.com>
> Cc: Wolfram Sang <wsa+renesas@sang-engineering.com>
> Cc: Zhang Rui <rui.zhang@intel.com>
> Cc: linux-renesas-soc@vger.kernel.org
> To: linux-pm@vger.kernel.org
> ---
> V2: No change
> ---
>  drivers/thermal/of-thermal.c | 12 +++++++++++-
>  1 file changed, 11 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/thermal/of-thermal.c b/drivers/thermal/of-thermal.c
> index e1a303a5698c..5ccff7b678de 100644
> --- a/drivers/thermal/of-thermal.c
> +++ b/drivers/thermal/of-thermal.c
> @@ -15,6 +15,7 @@
>  #include <linux/string.h>
>  
>  #include "thermal_core.h"
> +#include "thermal_hwmon.h"
>  
>  /***   Private data structures to represent thermal device tree data ***/
>  
> @@ -521,8 +522,15 @@ thermal_zone_of_sensor_register_params(struct device *dev, int sensor_id,
>  		if (sensor_specs.np == sensor_np && id == sensor_id) {
>  			tzd = thermal_zone_of_add_sensor(child, sensor_np,
>  							 data, ops);
> -			if (!IS_ERR(tzd))
> +			if (!IS_ERR(tzd)) {
> +				tzd->tzp = tzp;
>  				tzd->ops->set_mode(tzd, THERMAL_DEVICE_ENABLED);
> +				if (!tzp || !tzp->no_hwmon) {
> +					ret = thermal_add_hwmon_sysfs(tzd);
> +					if (ret)
> +						tzd = ERR_PTR(ret);
> +				}
> +			}
>  
>  			of_node_put(sensor_specs.np);
>  			of_node_put(child);
> @@ -605,6 +613,8 @@ void thermal_zone_of_sensor_unregister(struct device *dev,
>  
>  	tz = tzd->devdata;
>  
> +	thermal_remove_hwmon_sysfs(tzd);
> +
>  	/* no __thermal_zone, nothing to be done */
>  	if (!tz)
>  		return;
> -- 
> 2.18.0
>
diff mbox series

Patch

diff --git a/drivers/thermal/of-thermal.c b/drivers/thermal/of-thermal.c
index e1a303a5698c..5ccff7b678de 100644
--- a/drivers/thermal/of-thermal.c
+++ b/drivers/thermal/of-thermal.c
@@ -15,6 +15,7 @@ 
 #include <linux/string.h>
 
 #include "thermal_core.h"
+#include "thermal_hwmon.h"
 
 /***   Private data structures to represent thermal device tree data ***/
 
@@ -521,8 +522,15 @@  thermal_zone_of_sensor_register_params(struct device *dev, int sensor_id,
 		if (sensor_specs.np == sensor_np && id == sensor_id) {
 			tzd = thermal_zone_of_add_sensor(child, sensor_np,
 							 data, ops);
-			if (!IS_ERR(tzd))
+			if (!IS_ERR(tzd)) {
+				tzd->tzp = tzp;
 				tzd->ops->set_mode(tzd, THERMAL_DEVICE_ENABLED);
+				if (!tzp || !tzp->no_hwmon) {
+					ret = thermal_add_hwmon_sysfs(tzd);
+					if (ret)
+						tzd = ERR_PTR(ret);
+				}
+			}
 
 			of_node_put(sensor_specs.np);
 			of_node_put(child);
@@ -605,6 +613,8 @@  void thermal_zone_of_sensor_unregister(struct device *dev,
 
 	tz = tzd->devdata;
 
+	thermal_remove_hwmon_sysfs(tzd);
+
 	/* no __thermal_zone, nothing to be done */
 	if (!tz)
 		return;