All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCHv4 0/1] of-thermal API change
@ 2014-11-18 14:39 Eduardo Valentin
  2014-11-18 14:39   ` [lm-sensors] " Eduardo Valentin
  0 siblings, 1 reply; 20+ messages in thread
From: Eduardo Valentin @ 2014-11-18 14:39 UTC (permalink / raw)
  To: Linux PM
  Cc: Caesar Wang, Wei Ni, Lukasz Majewski, Mikko Perttunen, Eduardo Valentin

Hello guys,

I am proposing this change in the of-thermal API to sensors. The only
single change is how we represent the callbacks between sensor drivers
and of-thermal.

Essentially, instead of passing callbacks as parameters of the registration
function, now of-thermal users will pass an ops. It is a simple way of
growing the callback API smoothly. 

There are already proposals to grow this API. Thus I would like to change
this before we start to introduce new callbacks here.

I changed the existing of-thermal users to adapt accordingly.

Let me know if you have objections.

BR,

Eduardo Valentin (1):
  thermal: of: improve of-thermal sensor registration API

 drivers/hwmon/lm75.c                               |  9 +++--
 drivers/hwmon/ntc_thermistor.c                     |  6 +++-
 drivers/hwmon/tmp102.c                             |  6 +++-
 drivers/thermal/of-thermal.c                       | 40 ++++++++++------------
 drivers/thermal/tegra_soctherm.c                   |  7 ++--
 drivers/thermal/ti-soc-thermal/ti-thermal-common.c |  8 +++--
 include/linux/thermal.h                            | 24 +++++++++----
 7 files changed, 63 insertions(+), 37 deletions(-)

-- 
2.1.3


^ permalink raw reply	[flat|nested] 20+ messages in thread

* [PATCHv4 1/1] thermal: of: improve of-thermal sensor registration API
  2014-11-18 14:39 [PATCHv4 0/1] of-thermal API change Eduardo Valentin
@ 2014-11-18 14:39   ` Eduardo Valentin
  0 siblings, 0 replies; 20+ messages in thread
From: Eduardo Valentin @ 2014-11-18 14:39 UTC (permalink / raw)
  To: Linux PM
  Cc: Caesar Wang, Wei Ni, Lukasz Majewski, Mikko Perttunen,
	Eduardo Valentin, Alexandre Courbot, devicetree, Grant Likely,
	Guenter Roeck, Jean Delvare, linux-kernel, linux-tegra,
	lm-sensors, Rob Herring, Stephen Warren, Thierry Reding,
	Zhang Rui

Different drivers request API extensions in of-thermal. For this reason,
additional callbacks are required to fit the new drivers needs.

The current API implementation expects the registering sensor driver
to provide a get_temp and get_trend callbacks as function parameters.
As the amount of callbacks is growing, this patch changes the existing
implementation to use a .ops field to hold all the of thermal callbacks
to sensor drivers.

This patch also changes the existing of-thermal users to fit the new
API design. No functional change is introduced in this patch.

Cc: Alexandre Courbot <gnurou@gmail.com>
Cc: devicetree@vger.kernel.org
Cc: Grant Likely <grant.likely@linaro.org>
Cc: Guenter Roeck <linux@roeck-us.net>
Cc: Jean Delvare <jdelvare@suse.de>
Cc: linux-kernel@vger.kernel.org
Cc: linux-pm@vger.kernel.org
Cc: linux-tegra@vger.kernel.org
Cc: lm-sensors@lm-sensors.org
Cc: Rob Herring <robh+dt@kernel.org>
Cc: Stephen Warren <swarren@wwwdotorg.org>
Cc: Thierry Reding <thierry.reding@gmail.com>
Cc: Zhang Rui <rui.zhang@intel.com>
Reviewed-by: Lukasz Majewski <l.majewski@samsung.com>
Signed-off-by: Eduardo Valentin <edubezval@gmail.com>
---
 drivers/hwmon/lm75.c                               |  9 +++--
 drivers/hwmon/ntc_thermistor.c                     |  6 +++-
 drivers/hwmon/tmp102.c                             |  6 +++-
 drivers/thermal/of-thermal.c                       | 40 ++++++++++------------
 drivers/thermal/tegra_soctherm.c                   |  7 ++--
 drivers/thermal/ti-soc-thermal/ti-thermal-common.c |  8 +++--
 include/linux/thermal.h                            | 24 +++++++++----
 7 files changed, 63 insertions(+), 37 deletions(-)
---
Difference from V3:
  - Keep the same behavior regarding callback checks.
    Change in behavior may be sent in a separate patch.
Difference from V2:
  - Fix wrong assignment in tegra driver.
Difference from V1:
  - Fix error handling when .get_trend is not provided.

diff --git a/drivers/hwmon/lm75.c b/drivers/hwmon/lm75.c
index d16dbb3..e7c8bf9 100644
--- a/drivers/hwmon/lm75.c
+++ b/drivers/hwmon/lm75.c
@@ -176,6 +176,10 @@ static struct attribute *lm75_attrs[] = {
 };
 ATTRIBUTE_GROUPS(lm75);
 
+static const struct thermal_zone_of_device_ops lm75_of_thermal_ops = {
+	.get_temp = lm75_read_temp,
+};
+
 /*-----------------------------------------------------------------------*/
 
 /* device probe and removal */
@@ -291,10 +295,9 @@ lm75_probe(struct i2c_client *client, const struct i2c_device_id *id)
 	if (IS_ERR(data->hwmon_dev))
 		return PTR_ERR(data->hwmon_dev);
 
-	data->tz = thermal_zone_of_sensor_register(data->hwmon_dev,
-						   0,
+	data->tz = thermal_zone_of_sensor_register(data->hwmon_dev, 0,
 						   data->hwmon_dev,
-						   lm75_read_temp, NULL);
+						   &lm75_of_thermal_ops);
 	if (IS_ERR(data->tz))
 		data->tz = NULL;
 
diff --git a/drivers/hwmon/ntc_thermistor.c b/drivers/hwmon/ntc_thermistor.c
index 4ff89b2..bca8521c8 100644
--- a/drivers/hwmon/ntc_thermistor.c
+++ b/drivers/hwmon/ntc_thermistor.c
@@ -486,6 +486,10 @@ static const struct attribute_group ntc_attr_group = {
 	.attrs = ntc_attributes,
 };
 
+static const struct thermal_zone_of_device_ops ntc_of_thermal_ops = {
+	.get_temp = ntc_read_temp,
+};
+
 static int ntc_thermistor_probe(struct platform_device *pdev)
 {
 	const struct of_device_id *of_id =
@@ -579,7 +583,7 @@ static int ntc_thermistor_probe(struct platform_device *pdev)
 								pdev_id->name);
 
 	data->tz = thermal_zone_of_sensor_register(data->dev, 0, data->dev,
-						ntc_read_temp, NULL);
+						   &ntc_of_thermal_ops);
 	if (IS_ERR(data->tz)) {
 		dev_dbg(&pdev->dev, "Failed to register to thermal fw.\n");
 		data->tz = NULL;
diff --git a/drivers/hwmon/tmp102.c b/drivers/hwmon/tmp102.c
index 5171995..ba9f478 100644
--- a/drivers/hwmon/tmp102.c
+++ b/drivers/hwmon/tmp102.c
@@ -158,6 +158,10 @@ ATTRIBUTE_GROUPS(tmp102);
 #define TMP102_CONFIG  (TMP102_CONF_TM | TMP102_CONF_EM | TMP102_CONF_CR1)
 #define TMP102_CONFIG_RD_ONLY (TMP102_CONF_R0 | TMP102_CONF_R1 | TMP102_CONF_AL)
 
+static const struct thermal_zone_of_device_ops tmp102_of_thermal_ops = {
+	.get_temp = tmp102_read_temp,
+};
+
 static int tmp102_probe(struct i2c_client *client,
 				  const struct i2c_device_id *id)
 {
@@ -215,7 +219,7 @@ static int tmp102_probe(struct i2c_client *client,
 	}
 	tmp102->hwmon_dev = hwmon_dev;
 	tmp102->tz = thermal_zone_of_sensor_register(hwmon_dev, 0, hwmon_dev,
-						     tmp102_read_temp, NULL);
+						     &tmp102_of_thermal_ops);
 	if (IS_ERR(tmp102->tz))
 		tmp102->tz = NULL;
 
diff --git a/drivers/thermal/of-thermal.c b/drivers/thermal/of-thermal.c
index f8eb625..e87ccdb 100644
--- a/drivers/thermal/of-thermal.c
+++ b/drivers/thermal/of-thermal.c
@@ -30,6 +30,7 @@
 #include <linux/err.h>
 #include <linux/export.h>
 #include <linux/string.h>
+#include <linux/thermal.h>
 
 #include "thermal_core.h"
 
@@ -77,8 +78,7 @@ struct __thermal_bind_params {
  * @num_tbps: number of thermal bind params
  * @tbps: an array of thermal bind params (0..num_tbps - 1)
  * @sensor_data: sensor private data used while reading temperature and trend
- * @get_temp: sensor callback to read temperature
- * @get_trend: sensor callback to read temperature trend
+ * @ops: set of callbacks to handle the thermal zone based on DT
  */
 
 struct __thermal_zone {
@@ -96,8 +96,7 @@ struct __thermal_zone {
 
 	/* sensor interface */
 	void *sensor_data;
-	int (*get_temp)(void *, long *);
-	int (*get_trend)(void *, long *);
+	const struct thermal_zone_of_device_ops *ops;
 };
 
 /***   DT thermal zone device callbacks   ***/
@@ -107,10 +106,10 @@ static int of_thermal_get_temp(struct thermal_zone_device *tz,
 {
 	struct __thermal_zone *data = tz->devdata;
 
-	if (!data->get_temp)
+	if (!data->ops->get_temp)
 		return -EINVAL;
 
-	return data->get_temp(data->sensor_data, temp);
+	return data->ops->get_temp(data->sensor_data, temp);
 }
 
 static int of_thermal_get_trend(struct thermal_zone_device *tz, int trip,
@@ -120,10 +119,10 @@ static int of_thermal_get_trend(struct thermal_zone_device *tz, int trip,
 	long dev_trend;
 	int r;
 
-	if (!data->get_trend)
+	if (!data->ops->get_trend)
 		return -EINVAL;
 
-	r = data->get_trend(data->sensor_data, &dev_trend);
+	r = data->ops->get_trend(data->sensor_data, &dev_trend);
 	if (r)
 		return r;
 
@@ -324,8 +323,7 @@ static struct thermal_zone_device_ops of_thermal_ops = {
 static struct thermal_zone_device *
 thermal_zone_of_add_sensor(struct device_node *zone,
 			   struct device_node *sensor, void *data,
-			   int (*get_temp)(void *, long *),
-			   int (*get_trend)(void *, long *))
+			   const struct thermal_zone_of_device_ops *ops)
 {
 	struct thermal_zone_device *tzd;
 	struct __thermal_zone *tz;
@@ -336,9 +334,11 @@ thermal_zone_of_add_sensor(struct device_node *zone,
 
 	tz = tzd->devdata;
 
+	if (!ops)
+		return ERR_PTR(-EINVAL);
+
 	mutex_lock(&tzd->lock);
-	tz->get_temp = get_temp;
-	tz->get_trend = get_trend;
+	tz->ops = ops;
 	tz->sensor_data = data;
 
 	tzd->ops->get_temp = of_thermal_get_temp;
@@ -356,8 +356,8 @@ thermal_zone_of_add_sensor(struct device_node *zone,
  *             than one sensors
  * @data: a private pointer (owned by the caller) that will be passed
  *        back, when a temperature reading is needed.
- * @get_temp: a pointer to a function that reads the sensor temperature.
- * @get_trend: a pointer to a function that reads the sensor temperature trend.
+ * @ops: struct thermal_zone_of_device *. Must contain at least .get_trend and
+ *       .get_temp.
  *
  * This function will search the list of thermal zones described in device
  * tree and look for the zone that refer to the sensor device pointed by
@@ -382,9 +382,8 @@ thermal_zone_of_add_sensor(struct device_node *zone,
  * check the return value with help of IS_ERR() helper.
  */
 struct thermal_zone_device *
-thermal_zone_of_sensor_register(struct device *dev, int sensor_id,
-				void *data, int (*get_temp)(void *, long *),
-				int (*get_trend)(void *, long *))
+thermal_zone_of_sensor_register(struct device *dev, int sensor_id, void *data,
+				const struct thermal_zone_of_device_ops *ops)
 {
 	struct device_node *np, *child, *sensor_np;
 
@@ -424,9 +423,7 @@ thermal_zone_of_sensor_register(struct device *dev, int sensor_id,
 		if (sensor_specs.np == sensor_np && id == sensor_id) {
 			of_node_put(np);
 			return thermal_zone_of_add_sensor(child, sensor_np,
-							  data,
-							  get_temp,
-							  get_trend);
+							  data, ops);
 		}
 	}
 	of_node_put(np);
@@ -468,8 +465,7 @@ void thermal_zone_of_sensor_unregister(struct device *dev,
 	tzd->ops->get_temp = NULL;
 	tzd->ops->get_trend = NULL;
 
-	tz->get_temp = NULL;
-	tz->get_trend = NULL;
+	tz->ops = NULL;
 	tz->sensor_data = NULL;
 	mutex_unlock(&tzd->lock);
 }
diff --git a/drivers/thermal/tegra_soctherm.c b/drivers/thermal/tegra_soctherm.c
index 70f7e9e..9197fc0 100644
--- a/drivers/thermal/tegra_soctherm.c
+++ b/drivers/thermal/tegra_soctherm.c
@@ -317,6 +317,10 @@ static int tegra_thermctl_get_temp(void *data, long *out_temp)
 	return 0;
 }
 
+static const struct thermal_zone_of_device_ops tegra_of_thermal_ops = {
+	.get_temp = tegra_thermctl_get_temp,
+};
+
 static const struct of_device_id tegra_soctherm_of_match[] = {
 	{ .compatible = "nvidia,tegra124-soctherm" },
 	{ },
@@ -416,8 +420,7 @@ static int tegra_soctherm_probe(struct platform_device *pdev)
 		zone->shift = t124_thermctl_temp_zones[i].shift;
 
 		tz = thermal_zone_of_sensor_register(&pdev->dev, i, zone,
-						     tegra_thermctl_get_temp,
-						     NULL);
+						     &tegra_of_thermal_ops);
 		if (IS_ERR(tz)) {
 			err = PTR_ERR(tz);
 			dev_err(&pdev->dev, "failed to register sensor: %d\n",
diff --git a/drivers/thermal/ti-soc-thermal/ti-thermal-common.c b/drivers/thermal/ti-soc-thermal/ti-thermal-common.c
index 9eec26d..5fd0386 100644
--- a/drivers/thermal/ti-soc-thermal/ti-thermal-common.c
+++ b/drivers/thermal/ti-soc-thermal/ti-thermal-common.c
@@ -286,6 +286,11 @@ static int ti_thermal_get_crit_temp(struct thermal_zone_device *thermal,
 	return ti_thermal_get_trip_temp(thermal, OMAP_TRIP_NUMBER - 1, temp);
 }
 
+static const struct thermal_zone_of_device_ops ti_of_thermal_ops = {
+	.get_temp = __ti_thermal_get_temp,
+	.get_trend = __ti_thermal_get_trend,
+};
+
 static struct thermal_zone_device_ops ti_thermal_ops = {
 	.get_temp = ti_thermal_get_temp,
 	.get_trend = ti_thermal_get_trend,
@@ -333,8 +338,7 @@ int ti_thermal_expose_sensor(struct ti_bandgap *bgp, int id,
 
 	/* in case this is specified by DT */
 	data->ti_thermal = thermal_zone_of_sensor_register(bgp->dev, id,
-					data, __ti_thermal_get_temp,
-					__ti_thermal_get_trend);
+					data, &ti_of_thermal_ops);
 	if (IS_ERR(data->ti_thermal)) {
 		/* Create thermal zone */
 		data->ti_thermal = thermal_zone_device_register(domain,
diff --git a/include/linux/thermal.h b/include/linux/thermal.h
index ef90838..b565964 100644
--- a/include/linux/thermal.h
+++ b/include/linux/thermal.h
@@ -289,19 +289,31 @@ struct thermal_genl_event {
 	enum events event;
 };
 
+/**
+ * struct thermal_zone_of_device_ops - scallbacks for handling DT based zones
+ *
+ * Mandatory:
+ * @get_temp: a pointer to a function that reads the sensor temperature.
+ *
+ * Optional:
+ * @get_trend: a pointer to a function that reads the sensor temperature trend.
+ */
+struct thermal_zone_of_device_ops {
+	int (*get_temp)(void *, long *);
+	int (*get_trend)(void *, long *);
+};
+
 /* Function declarations */
 #ifdef CONFIG_THERMAL_OF
 struct thermal_zone_device *
-thermal_zone_of_sensor_register(struct device *dev, int id,
-				void *data, int (*get_temp)(void *, long *),
-				int (*get_trend)(void *, long *));
+thermal_zone_of_sensor_register(struct device *dev, int id, void *data,
+				const struct thermal_zone_of_device_ops *);
 void thermal_zone_of_sensor_unregister(struct device *dev,
 				       struct thermal_zone_device *tz);
 #else
 static inline struct thermal_zone_device *
-thermal_zone_of_sensor_register(struct device *dev, int id,
-				void *data, int (*get_temp)(void *, long *),
-				int (*get_trend)(void *, long *))
+thermal_zone_of_sensor_register(struct device *dev, int id, void *data,
+				const struct thermal_zone_of_device_ops *)
 {
 	return NULL;
 }
-- 
2.1.3

^ permalink raw reply related	[flat|nested] 20+ messages in thread

* [lm-sensors] [PATCHv4 1/1] thermal: of: improve of-thermal sensor registration API
@ 2014-11-18 14:39   ` Eduardo Valentin
  0 siblings, 0 replies; 20+ messages in thread
From: Eduardo Valentin @ 2014-11-18 14:39 UTC (permalink / raw)
  To: Linux PM
  Cc: Caesar Wang, Wei Ni, Lukasz Majewski, Mikko Perttunen,
	Eduardo Valentin, Alexandre Courbot, devicetree, Grant Likely,
	Guenter Roeck, Jean Delvare, linux-kernel, linux-tegra,
	lm-sensors, Rob Herring, Stephen Warren, Thierry Reding,
	Zhang Rui

Different drivers request API extensions in of-thermal. For this reason,
additional callbacks are required to fit the new drivers needs.

The current API implementation expects the registering sensor driver
to provide a get_temp and get_trend callbacks as function parameters.
As the amount of callbacks is growing, this patch changes the existing
implementation to use a .ops field to hold all the of thermal callbacks
to sensor drivers.

This patch also changes the existing of-thermal users to fit the new
API design. No functional change is introduced in this patch.

Cc: Alexandre Courbot <gnurou@gmail.com>
Cc: devicetree@vger.kernel.org
Cc: Grant Likely <grant.likely@linaro.org>
Cc: Guenter Roeck <linux@roeck-us.net>
Cc: Jean Delvare <jdelvare@suse.de>
Cc: linux-kernel@vger.kernel.org
Cc: linux-pm@vger.kernel.org
Cc: linux-tegra@vger.kernel.org
Cc: lm-sensors@lm-sensors.org
Cc: Rob Herring <robh+dt@kernel.org>
Cc: Stephen Warren <swarren@wwwdotorg.org>
Cc: Thierry Reding <thierry.reding@gmail.com>
Cc: Zhang Rui <rui.zhang@intel.com>
Reviewed-by: Lukasz Majewski <l.majewski@samsung.com>
Signed-off-by: Eduardo Valentin <edubezval@gmail.com>
---
 drivers/hwmon/lm75.c                               |  9 +++--
 drivers/hwmon/ntc_thermistor.c                     |  6 +++-
 drivers/hwmon/tmp102.c                             |  6 +++-
 drivers/thermal/of-thermal.c                       | 40 ++++++++++------------
 drivers/thermal/tegra_soctherm.c                   |  7 ++--
 drivers/thermal/ti-soc-thermal/ti-thermal-common.c |  8 +++--
 include/linux/thermal.h                            | 24 +++++++++----
 7 files changed, 63 insertions(+), 37 deletions(-)
---
Difference from V3:
  - Keep the same behavior regarding callback checks.
    Change in behavior may be sent in a separate patch.
Difference from V2:
  - Fix wrong assignment in tegra driver.
Difference from V1:
  - Fix error handling when .get_trend is not provided.

diff --git a/drivers/hwmon/lm75.c b/drivers/hwmon/lm75.c
index d16dbb3..e7c8bf9 100644
--- a/drivers/hwmon/lm75.c
+++ b/drivers/hwmon/lm75.c
@@ -176,6 +176,10 @@ static struct attribute *lm75_attrs[] = {
 };
 ATTRIBUTE_GROUPS(lm75);
 
+static const struct thermal_zone_of_device_ops lm75_of_thermal_ops = {
+	.get_temp = lm75_read_temp,
+};
+
 /*-----------------------------------------------------------------------*/
 
 /* device probe and removal */
@@ -291,10 +295,9 @@ lm75_probe(struct i2c_client *client, const struct i2c_device_id *id)
 	if (IS_ERR(data->hwmon_dev))
 		return PTR_ERR(data->hwmon_dev);
 
-	data->tz = thermal_zone_of_sensor_register(data->hwmon_dev,
-						   0,
+	data->tz = thermal_zone_of_sensor_register(data->hwmon_dev, 0,
 						   data->hwmon_dev,
-						   lm75_read_temp, NULL);
+						   &lm75_of_thermal_ops);
 	if (IS_ERR(data->tz))
 		data->tz = NULL;
 
diff --git a/drivers/hwmon/ntc_thermistor.c b/drivers/hwmon/ntc_thermistor.c
index 4ff89b2..bca8521c8 100644
--- a/drivers/hwmon/ntc_thermistor.c
+++ b/drivers/hwmon/ntc_thermistor.c
@@ -486,6 +486,10 @@ static const struct attribute_group ntc_attr_group = {
 	.attrs = ntc_attributes,
 };
 
+static const struct thermal_zone_of_device_ops ntc_of_thermal_ops = {
+	.get_temp = ntc_read_temp,
+};
+
 static int ntc_thermistor_probe(struct platform_device *pdev)
 {
 	const struct of_device_id *of_id @@ -579,7 +583,7 @@ static int ntc_thermistor_probe(struct platform_device *pdev)
 								pdev_id->name);
 
 	data->tz = thermal_zone_of_sensor_register(data->dev, 0, data->dev,
-						ntc_read_temp, NULL);
+						   &ntc_of_thermal_ops);
 	if (IS_ERR(data->tz)) {
 		dev_dbg(&pdev->dev, "Failed to register to thermal fw.\n");
 		data->tz = NULL;
diff --git a/drivers/hwmon/tmp102.c b/drivers/hwmon/tmp102.c
index 5171995..ba9f478 100644
--- a/drivers/hwmon/tmp102.c
+++ b/drivers/hwmon/tmp102.c
@@ -158,6 +158,10 @@ ATTRIBUTE_GROUPS(tmp102);
 #define TMP102_CONFIG  (TMP102_CONF_TM | TMP102_CONF_EM | TMP102_CONF_CR1)
 #define TMP102_CONFIG_RD_ONLY (TMP102_CONF_R0 | TMP102_CONF_R1 | TMP102_CONF_AL)
 
+static const struct thermal_zone_of_device_ops tmp102_of_thermal_ops = {
+	.get_temp = tmp102_read_temp,
+};
+
 static int tmp102_probe(struct i2c_client *client,
 				  const struct i2c_device_id *id)
 {
@@ -215,7 +219,7 @@ static int tmp102_probe(struct i2c_client *client,
 	}
 	tmp102->hwmon_dev = hwmon_dev;
 	tmp102->tz = thermal_zone_of_sensor_register(hwmon_dev, 0, hwmon_dev,
-						     tmp102_read_temp, NULL);
+						     &tmp102_of_thermal_ops);
 	if (IS_ERR(tmp102->tz))
 		tmp102->tz = NULL;
 
diff --git a/drivers/thermal/of-thermal.c b/drivers/thermal/of-thermal.c
index f8eb625..e87ccdb 100644
--- a/drivers/thermal/of-thermal.c
+++ b/drivers/thermal/of-thermal.c
@@ -30,6 +30,7 @@
 #include <linux/err.h>
 #include <linux/export.h>
 #include <linux/string.h>
+#include <linux/thermal.h>
 
 #include "thermal_core.h"
 
@@ -77,8 +78,7 @@ struct __thermal_bind_params {
  * @num_tbps: number of thermal bind params
  * @tbps: an array of thermal bind params (0..num_tbps - 1)
  * @sensor_data: sensor private data used while reading temperature and trend
- * @get_temp: sensor callback to read temperature
- * @get_trend: sensor callback to read temperature trend
+ * @ops: set of callbacks to handle the thermal zone based on DT
  */
 
 struct __thermal_zone {
@@ -96,8 +96,7 @@ struct __thermal_zone {
 
 	/* sensor interface */
 	void *sensor_data;
-	int (*get_temp)(void *, long *);
-	int (*get_trend)(void *, long *);
+	const struct thermal_zone_of_device_ops *ops;
 };
 
 /***   DT thermal zone device callbacks   ***/
@@ -107,10 +106,10 @@ static int of_thermal_get_temp(struct thermal_zone_device *tz,
 {
 	struct __thermal_zone *data = tz->devdata;
 
-	if (!data->get_temp)
+	if (!data->ops->get_temp)
 		return -EINVAL;
 
-	return data->get_temp(data->sensor_data, temp);
+	return data->ops->get_temp(data->sensor_data, temp);
 }
 
 static int of_thermal_get_trend(struct thermal_zone_device *tz, int trip,
@@ -120,10 +119,10 @@ static int of_thermal_get_trend(struct thermal_zone_device *tz, int trip,
 	long dev_trend;
 	int r;
 
-	if (!data->get_trend)
+	if (!data->ops->get_trend)
 		return -EINVAL;
 
-	r = data->get_trend(data->sensor_data, &dev_trend);
+	r = data->ops->get_trend(data->sensor_data, &dev_trend);
 	if (r)
 		return r;
 
@@ -324,8 +323,7 @@ static struct thermal_zone_device_ops of_thermal_ops = {
 static struct thermal_zone_device *
 thermal_zone_of_add_sensor(struct device_node *zone,
 			   struct device_node *sensor, void *data,
-			   int (*get_temp)(void *, long *),
-			   int (*get_trend)(void *, long *))
+			   const struct thermal_zone_of_device_ops *ops)
 {
 	struct thermal_zone_device *tzd;
 	struct __thermal_zone *tz;
@@ -336,9 +334,11 @@ thermal_zone_of_add_sensor(struct device_node *zone,
 
 	tz = tzd->devdata;
 
+	if (!ops)
+		return ERR_PTR(-EINVAL);
+
 	mutex_lock(&tzd->lock);
-	tz->get_temp = get_temp;
-	tz->get_trend = get_trend;
+	tz->ops = ops;
 	tz->sensor_data = data;
 
 	tzd->ops->get_temp = of_thermal_get_temp;
@@ -356,8 +356,8 @@ thermal_zone_of_add_sensor(struct device_node *zone,
  *             than one sensors
  * @data: a private pointer (owned by the caller) that will be passed
  *        back, when a temperature reading is needed.
- * @get_temp: a pointer to a function that reads the sensor temperature.
- * @get_trend: a pointer to a function that reads the sensor temperature trend.
+ * @ops: struct thermal_zone_of_device *. Must contain at least .get_trend and
+ *       .get_temp.
  *
  * This function will search the list of thermal zones described in device
  * tree and look for the zone that refer to the sensor device pointed by
@@ -382,9 +382,8 @@ thermal_zone_of_add_sensor(struct device_node *zone,
  * check the return value with help of IS_ERR() helper.
  */
 struct thermal_zone_device *
-thermal_zone_of_sensor_register(struct device *dev, int sensor_id,
-				void *data, int (*get_temp)(void *, long *),
-				int (*get_trend)(void *, long *))
+thermal_zone_of_sensor_register(struct device *dev, int sensor_id, void *data,
+				const struct thermal_zone_of_device_ops *ops)
 {
 	struct device_node *np, *child, *sensor_np;
 
@@ -424,9 +423,7 @@ thermal_zone_of_sensor_register(struct device *dev, int sensor_id,
 		if (sensor_specs.np = sensor_np && id = sensor_id) {
 			of_node_put(np);
 			return thermal_zone_of_add_sensor(child, sensor_np,
-							  data,
-							  get_temp,
-							  get_trend);
+							  data, ops);
 		}
 	}
 	of_node_put(np);
@@ -468,8 +465,7 @@ void thermal_zone_of_sensor_unregister(struct device *dev,
 	tzd->ops->get_temp = NULL;
 	tzd->ops->get_trend = NULL;
 
-	tz->get_temp = NULL;
-	tz->get_trend = NULL;
+	tz->ops = NULL;
 	tz->sensor_data = NULL;
 	mutex_unlock(&tzd->lock);
 }
diff --git a/drivers/thermal/tegra_soctherm.c b/drivers/thermal/tegra_soctherm.c
index 70f7e9e..9197fc0 100644
--- a/drivers/thermal/tegra_soctherm.c
+++ b/drivers/thermal/tegra_soctherm.c
@@ -317,6 +317,10 @@ static int tegra_thermctl_get_temp(void *data, long *out_temp)
 	return 0;
 }
 
+static const struct thermal_zone_of_device_ops tegra_of_thermal_ops = {
+	.get_temp = tegra_thermctl_get_temp,
+};
+
 static const struct of_device_id tegra_soctherm_of_match[] = {
 	{ .compatible = "nvidia,tegra124-soctherm" },
 	{ },
@@ -416,8 +420,7 @@ static int tegra_soctherm_probe(struct platform_device *pdev)
 		zone->shift = t124_thermctl_temp_zones[i].shift;
 
 		tz = thermal_zone_of_sensor_register(&pdev->dev, i, zone,
-						     tegra_thermctl_get_temp,
-						     NULL);
+						     &tegra_of_thermal_ops);
 		if (IS_ERR(tz)) {
 			err = PTR_ERR(tz);
 			dev_err(&pdev->dev, "failed to register sensor: %d\n",
diff --git a/drivers/thermal/ti-soc-thermal/ti-thermal-common.c b/drivers/thermal/ti-soc-thermal/ti-thermal-common.c
index 9eec26d..5fd0386 100644
--- a/drivers/thermal/ti-soc-thermal/ti-thermal-common.c
+++ b/drivers/thermal/ti-soc-thermal/ti-thermal-common.c
@@ -286,6 +286,11 @@ static int ti_thermal_get_crit_temp(struct thermal_zone_device *thermal,
 	return ti_thermal_get_trip_temp(thermal, OMAP_TRIP_NUMBER - 1, temp);
 }
 
+static const struct thermal_zone_of_device_ops ti_of_thermal_ops = {
+	.get_temp = __ti_thermal_get_temp,
+	.get_trend = __ti_thermal_get_trend,
+};
+
 static struct thermal_zone_device_ops ti_thermal_ops = {
 	.get_temp = ti_thermal_get_temp,
 	.get_trend = ti_thermal_get_trend,
@@ -333,8 +338,7 @@ int ti_thermal_expose_sensor(struct ti_bandgap *bgp, int id,
 
 	/* in case this is specified by DT */
 	data->ti_thermal = thermal_zone_of_sensor_register(bgp->dev, id,
-					data, __ti_thermal_get_temp,
-					__ti_thermal_get_trend);
+					data, &ti_of_thermal_ops);
 	if (IS_ERR(data->ti_thermal)) {
 		/* Create thermal zone */
 		data->ti_thermal = thermal_zone_device_register(domain,
diff --git a/include/linux/thermal.h b/include/linux/thermal.h
index ef90838..b565964 100644
--- a/include/linux/thermal.h
+++ b/include/linux/thermal.h
@@ -289,19 +289,31 @@ struct thermal_genl_event {
 	enum events event;
 };
 
+/**
+ * struct thermal_zone_of_device_ops - scallbacks for handling DT based zones
+ *
+ * Mandatory:
+ * @get_temp: a pointer to a function that reads the sensor temperature.
+ *
+ * Optional:
+ * @get_trend: a pointer to a function that reads the sensor temperature trend.
+ */
+struct thermal_zone_of_device_ops {
+	int (*get_temp)(void *, long *);
+	int (*get_trend)(void *, long *);
+};
+
 /* Function declarations */
 #ifdef CONFIG_THERMAL_OF
 struct thermal_zone_device *
-thermal_zone_of_sensor_register(struct device *dev, int id,
-				void *data, int (*get_temp)(void *, long *),
-				int (*get_trend)(void *, long *));
+thermal_zone_of_sensor_register(struct device *dev, int id, void *data,
+				const struct thermal_zone_of_device_ops *);
 void thermal_zone_of_sensor_unregister(struct device *dev,
 				       struct thermal_zone_device *tz);
 #else
 static inline struct thermal_zone_device *
-thermal_zone_of_sensor_register(struct device *dev, int id,
-				void *data, int (*get_temp)(void *, long *),
-				int (*get_trend)(void *, long *))
+thermal_zone_of_sensor_register(struct device *dev, int id, void *data,
+				const struct thermal_zone_of_device_ops *)
 {
 	return NULL;
 }
-- 
2.1.3


_______________________________________________
lm-sensors mailing list
lm-sensors@lm-sensors.org
http://lists.lm-sensors.org/mailman/listinfo/lm-sensors

^ permalink raw reply related	[flat|nested] 20+ messages in thread

* Re: [PATCHv4 1/1] thermal: of: improve of-thermal sensor registration API
  2014-11-18 14:39   ` [lm-sensors] " Eduardo Valentin
@ 2014-11-19  8:06     ` Alexandre Courbot
  -1 siblings, 0 replies; 20+ messages in thread
From: Alexandre Courbot @ 2014-11-19  8:06 UTC (permalink / raw)
  To: Eduardo Valentin
  Cc: Linux PM, Caesar Wang, Wei Ni, Lukasz Majewski, Mikko Perttunen,
	devicetree, Grant Likely, Guenter Roeck, Jean Delvare,
	Linux Kernel Mailing List, linux-tegra, lm-sensors, Rob Herring,
	Stephen Warren, Thierry Reding, Zhang Rui

On Tue, Nov 18, 2014 at 11:39 PM, Eduardo Valentin <edubezval@gmail.com> wrote:
> Different drivers request API extensions in of-thermal. For this reason,
> additional callbacks are required to fit the new drivers needs.
>
> The current API implementation expects the registering sensor driver
> to provide a get_temp and get_trend callbacks as function parameters.
> As the amount of callbacks is growing, this patch changes the existing
> implementation to use a .ops field to hold all the of thermal callbacks
> to sensor drivers.
>
> This patch also changes the existing of-thermal users to fit the new
> API design. No functional change is introduced in this patch.

A good idea even if no ops were to be added!

Reviewed-by: Alexandre Courbot <acourbot@nvidia.com>

^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: [lm-sensors] [PATCHv4 1/1] thermal: of: improve of-thermal sensor registration API
@ 2014-11-19  8:06     ` Alexandre Courbot
  0 siblings, 0 replies; 20+ messages in thread
From: Alexandre Courbot @ 2014-11-19  8:06 UTC (permalink / raw)
  To: Eduardo Valentin
  Cc: Linux PM, Caesar Wang, Wei Ni, Lukasz Majewski, Mikko Perttunen,
	devicetree, Grant Likely, Guenter Roeck, Jean Delvare,
	Linux Kernel Mailing List, linux-tegra, lm-sensors, Rob Herring,
	Stephen Warren, Thierry Reding, Zhang Rui

On Tue, Nov 18, 2014 at 11:39 PM, Eduardo Valentin <edubezval@gmail.com> wrote:
> Different drivers request API extensions in of-thermal. For this reason,
> additional callbacks are required to fit the new drivers needs.
>
> The current API implementation expects the registering sensor driver
> to provide a get_temp and get_trend callbacks as function parameters.
> As the amount of callbacks is growing, this patch changes the existing
> implementation to use a .ops field to hold all the of thermal callbacks
> to sensor drivers.
>
> This patch also changes the existing of-thermal users to fit the new
> API design. No functional change is introduced in this patch.

A good idea even if no ops were to be added!

Reviewed-by: Alexandre Courbot <acourbot@nvidia.com>

_______________________________________________
lm-sensors mailing list
lm-sensors@lm-sensors.org
http://lists.lm-sensors.org/mailman/listinfo/lm-sensors

^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: [PATCHv4 1/1] thermal: of: improve of-thermal sensor registration API
  2014-11-18 14:39   ` [lm-sensors] " Eduardo Valentin
  (?)
@ 2014-11-19  8:21       ` Lukasz Majewski
  -1 siblings, 0 replies; 20+ messages in thread
From: Lukasz Majewski @ 2014-11-19  8:21 UTC (permalink / raw)
  To: Eduardo Valentin
  Cc: Linux PM, Caesar Wang, Wei Ni, Mikko Perttunen,
	Alexandre Courbot, devicetree-u79uwXL29TY76Z2rM5mHXA,
	Grant Likely, Guenter Roeck, Jean Delvare,
	linux-kernel-u79uwXL29TY76Z2rM5mHXA,
	linux-tegra-u79uwXL29TY76Z2rM5mHXA,
	lm-sensors-GZX6beZjE8VD60Wz+7aTrA, Rob Herring, Stephen Warren,
	Thierry Reding, Zhang Rui

Hi Eduardo,

> Different drivers request API extensions in of-thermal. For this
> reason, additional callbacks are required to fit the new drivers
> needs.
> 
> The current API implementation expects the registering sensor driver
> to provide a get_temp and get_trend callbacks as function parameters.
> As the amount of callbacks is growing, this patch changes the existing
> implementation to use a .ops field to hold all the of thermal
> callbacks to sensor drivers.
> 
> This patch also changes the existing of-thermal users to fit the new
> API design. No functional change is introduced in this patch.
> 
> Cc: Alexandre Courbot <gnurou-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
> Cc: devicetree-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
> Cc: Grant Likely <grant.likely-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org>
> Cc: Guenter Roeck <linux-0h96xk9xTtrk1uMJSBkQmQ@public.gmane.org>
> Cc: Jean Delvare <jdelvare-l3A5Bk7waGM@public.gmane.org>
> Cc: linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
> Cc: linux-pm-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
> Cc: linux-tegra-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
> Cc: lm-sensors-GZX6beZjE8VD60Wz+7aTrA@public.gmane.org
> Cc: Rob Herring <robh+dt-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org>
> Cc: Stephen Warren <swarren-3lzwWm7+Weoh9ZMKESR00Q@public.gmane.org>
> Cc: Thierry Reding <thierry.reding-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
> Cc: Zhang Rui <rui.zhang-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>
> Reviewed-by: Lukasz Majewski <l.majewski-Sze3O3UU22JBDgjK7y7TUQ@public.gmane.org>
> Signed-off-by: Eduardo Valentin <edubezval-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
> ---
>  drivers/hwmon/lm75.c                               |  9 +++--
>  drivers/hwmon/ntc_thermistor.c                     |  6 +++-
>  drivers/hwmon/tmp102.c                             |  6 +++-
>  drivers/thermal/of-thermal.c                       | 40
> ++++++++++------------
> drivers/thermal/tegra_soctherm.c                   |  7 ++--
> drivers/thermal/ti-soc-thermal/ti-thermal-common.c |  8 +++--
> include/linux/thermal.h                            | 24 +++++++++----
> 7 files changed, 63 insertions(+), 37 deletions(-) ---
> Difference from V3:
>   - Keep the same behavior regarding callback checks.
>     Change in behavior may be sent in a separate patch.
> Difference from V2:
>   - Fix wrong assignment in tegra driver.
> Difference from V1:
>   - Fix error handling when .get_trend is not provided.
> 
> diff --git a/drivers/hwmon/lm75.c b/drivers/hwmon/lm75.c
> index d16dbb3..e7c8bf9 100644
> --- a/drivers/hwmon/lm75.c
> +++ b/drivers/hwmon/lm75.c
> @@ -176,6 +176,10 @@ static struct attribute *lm75_attrs[] = {
>  };
>  ATTRIBUTE_GROUPS(lm75);
>  
> +static const struct thermal_zone_of_device_ops lm75_of_thermal_ops =
> {
> +	.get_temp = lm75_read_temp,
> +};
> +
>  /*-----------------------------------------------------------------------*/
>  
>  /* device probe and removal */
> @@ -291,10 +295,9 @@ lm75_probe(struct i2c_client *client, const
> struct i2c_device_id *id) if (IS_ERR(data->hwmon_dev))
>  		return PTR_ERR(data->hwmon_dev);
>  
> -	data->tz = thermal_zone_of_sensor_register(data->hwmon_dev,
> -						   0,
> +	data->tz = thermal_zone_of_sensor_register(data->hwmon_dev,
> 0, data->hwmon_dev,
> -						   lm75_read_temp,
> NULL);
> +
> &lm75_of_thermal_ops); if (IS_ERR(data->tz))
>  		data->tz = NULL;
>  
> diff --git a/drivers/hwmon/ntc_thermistor.c
> b/drivers/hwmon/ntc_thermistor.c index 4ff89b2..bca8521c8 100644
> --- a/drivers/hwmon/ntc_thermistor.c
> +++ b/drivers/hwmon/ntc_thermistor.c
> @@ -486,6 +486,10 @@ static const struct attribute_group
> ntc_attr_group = { .attrs = ntc_attributes,
>  };
>  
> +static const struct thermal_zone_of_device_ops ntc_of_thermal_ops = {
> +	.get_temp = ntc_read_temp,
> +};
> +
>  static int ntc_thermistor_probe(struct platform_device *pdev)
>  {
>  	const struct of_device_id *of_id =
> @@ -579,7 +583,7 @@ static int ntc_thermistor_probe(struct
> platform_device *pdev) pdev_id->name);
>  
>  	data->tz = thermal_zone_of_sensor_register(data->dev, 0,
> data->dev,
> -						ntc_read_temp, NULL);
> +
> &ntc_of_thermal_ops); if (IS_ERR(data->tz)) {
>  		dev_dbg(&pdev->dev, "Failed to register to thermal
> fw.\n"); data->tz = NULL;
> diff --git a/drivers/hwmon/tmp102.c b/drivers/hwmon/tmp102.c
> index 5171995..ba9f478 100644
> --- a/drivers/hwmon/tmp102.c
> +++ b/drivers/hwmon/tmp102.c
> @@ -158,6 +158,10 @@ ATTRIBUTE_GROUPS(tmp102);
>  #define TMP102_CONFIG  (TMP102_CONF_TM | TMP102_CONF_EM |
> TMP102_CONF_CR1) #define TMP102_CONFIG_RD_ONLY (TMP102_CONF_R0 |
> TMP102_CONF_R1 | TMP102_CONF_AL) 
> +static const struct thermal_zone_of_device_ops tmp102_of_thermal_ops
> = {
> +	.get_temp = tmp102_read_temp,
> +};
> +
>  static int tmp102_probe(struct i2c_client *client,
>  				  const struct i2c_device_id *id)
>  {
> @@ -215,7 +219,7 @@ static int tmp102_probe(struct i2c_client *client,
>  	}
>  	tmp102->hwmon_dev = hwmon_dev;
>  	tmp102->tz = thermal_zone_of_sensor_register(hwmon_dev, 0,
> hwmon_dev,
> -
> tmp102_read_temp, NULL);
> +
> &tmp102_of_thermal_ops); if (IS_ERR(tmp102->tz))
>  		tmp102->tz = NULL;
>  
> diff --git a/drivers/thermal/of-thermal.c
> b/drivers/thermal/of-thermal.c index f8eb625..e87ccdb 100644
> --- a/drivers/thermal/of-thermal.c
> +++ b/drivers/thermal/of-thermal.c
> @@ -30,6 +30,7 @@
>  #include <linux/err.h>
>  #include <linux/export.h>
>  #include <linux/string.h>
> +#include <linux/thermal.h>
>  
>  #include "thermal_core.h"
>  
> @@ -77,8 +78,7 @@ struct __thermal_bind_params {
>   * @num_tbps: number of thermal bind params
>   * @tbps: an array of thermal bind params (0..num_tbps - 1)
>   * @sensor_data: sensor private data used while reading temperature
> and trend
> - * @get_temp: sensor callback to read temperature
> - * @get_trend: sensor callback to read temperature trend
> + * @ops: set of callbacks to handle the thermal zone based on DT
>   */
>  
>  struct __thermal_zone {
> @@ -96,8 +96,7 @@ struct __thermal_zone {
>  
>  	/* sensor interface */
>  	void *sensor_data;
> -	int (*get_temp)(void *, long *);
> -	int (*get_trend)(void *, long *);
> +	const struct thermal_zone_of_device_ops *ops;
>  };
>  
>  /***   DT thermal zone device callbacks   ***/
> @@ -107,10 +106,10 @@ static int of_thermal_get_temp(struct
> thermal_zone_device *tz, {
>  	struct __thermal_zone *data = tz->devdata;
>  
> -	if (!data->get_temp)
> +	if (!data->ops->get_temp)
>  		return -EINVAL;
>  
> -	return data->get_temp(data->sensor_data, temp);
> +	return data->ops->get_temp(data->sensor_data, temp);
>  }
>  
>  static int of_thermal_get_trend(struct thermal_zone_device *tz, int
> trip, @@ -120,10 +119,10 @@ static int of_thermal_get_trend(struct
> thermal_zone_device *tz, int trip, long dev_trend;
>  	int r;
>  
> -	if (!data->get_trend)
> +	if (!data->ops->get_trend)
>  		return -EINVAL;
>  
> -	r = data->get_trend(data->sensor_data, &dev_trend);
> +	r = data->ops->get_trend(data->sensor_data, &dev_trend);
>  	if (r)
>  		return r;
>  
> @@ -324,8 +323,7 @@ static struct thermal_zone_device_ops
> of_thermal_ops = { static struct thermal_zone_device *
>  thermal_zone_of_add_sensor(struct device_node *zone,
>  			   struct device_node *sensor, void *data,
> -			   int (*get_temp)(void *, long *),
> -			   int (*get_trend)(void *, long *))
> +			   const struct thermal_zone_of_device_ops
> *ops) {
>  	struct thermal_zone_device *tzd;
>  	struct __thermal_zone *tz;
> @@ -336,9 +334,11 @@ thermal_zone_of_add_sensor(struct device_node
> *zone, 
>  	tz = tzd->devdata;
>  
> +	if (!ops)
> +		return ERR_PTR(-EINVAL);
> +
>  	mutex_lock(&tzd->lock);
> -	tz->get_temp = get_temp;
> -	tz->get_trend = get_trend;
> +	tz->ops = ops;
>  	tz->sensor_data = data;
>  
>  	tzd->ops->get_temp = of_thermal_get_temp;
> @@ -356,8 +356,8 @@ thermal_zone_of_add_sensor(struct device_node
> *zone,
>   *             than one sensors
>   * @data: a private pointer (owned by the caller) that will be passed
>   *        back, when a temperature reading is needed.
> - * @get_temp: a pointer to a function that reads the sensor
> temperature.
> - * @get_trend: a pointer to a function that reads the sensor
> temperature trend.
> + * @ops: struct thermal_zone_of_device *. Must contain at
> least .get_trend and
> + *       .get_temp.
>   *
>   * This function will search the list of thermal zones described in
> device
>   * tree and look for the zone that refer to the sensor device
> pointed by @@ -382,9 +382,8 @@ thermal_zone_of_add_sensor(struct
> device_node *zone,
>   * check the return value with help of IS_ERR() helper.
>   */
>  struct thermal_zone_device *
> -thermal_zone_of_sensor_register(struct device *dev, int sensor_id,
> -				void *data, int (*get_temp)(void *,
> long *),
> -				int (*get_trend)(void *, long *))
> +thermal_zone_of_sensor_register(struct device *dev, int sensor_id,
> void *data,
> +				const struct
> thermal_zone_of_device_ops *ops) {
>  	struct device_node *np, *child, *sensor_np;
>  
> @@ -424,9 +423,7 @@ thermal_zone_of_sensor_register(struct device
> *dev, int sensor_id, if (sensor_specs.np == sensor_np && id ==
> sensor_id) { of_node_put(np);
>  			return thermal_zone_of_add_sensor(child,
> sensor_np,
> -							  data,
> -							  get_temp,
> -							  get_trend);
> +							  data, ops);
>  		}
>  	}
>  	of_node_put(np);
> @@ -468,8 +465,7 @@ void thermal_zone_of_sensor_unregister(struct
> device *dev, tzd->ops->get_temp = NULL;
>  	tzd->ops->get_trend = NULL;
>  
> -	tz->get_temp = NULL;
> -	tz->get_trend = NULL;
> +	tz->ops = NULL;
>  	tz->sensor_data = NULL;
>  	mutex_unlock(&tzd->lock);
>  }
> diff --git a/drivers/thermal/tegra_soctherm.c
> b/drivers/thermal/tegra_soctherm.c index 70f7e9e..9197fc0 100644
> --- a/drivers/thermal/tegra_soctherm.c
> +++ b/drivers/thermal/tegra_soctherm.c
> @@ -317,6 +317,10 @@ static int tegra_thermctl_get_temp(void *data,
> long *out_temp) return 0;
>  }
>  
> +static const struct thermal_zone_of_device_ops tegra_of_thermal_ops
> = {
> +	.get_temp = tegra_thermctl_get_temp,
> +};
> +
>  static const struct of_device_id tegra_soctherm_of_match[] = {
>  	{ .compatible = "nvidia,tegra124-soctherm" },
>  	{ },
> @@ -416,8 +420,7 @@ static int tegra_soctherm_probe(struct
> platform_device *pdev) zone->shift =
> t124_thermctl_temp_zones[i].shift; 
>  		tz = thermal_zone_of_sensor_register(&pdev->dev, i,
> zone,
> -
> tegra_thermctl_get_temp,
> -						     NULL);
> +
> &tegra_of_thermal_ops); if (IS_ERR(tz)) {
>  			err = PTR_ERR(tz);
>  			dev_err(&pdev->dev, "failed to register
> sensor: %d\n", diff --git
> a/drivers/thermal/ti-soc-thermal/ti-thermal-common.c
> b/drivers/thermal/ti-soc-thermal/ti-thermal-common.c index
> 9eec26d..5fd0386 100644 ---
> a/drivers/thermal/ti-soc-thermal/ti-thermal-common.c +++
> b/drivers/thermal/ti-soc-thermal/ti-thermal-common.c @@ -286,6
> +286,11 @@ static int ti_thermal_get_crit_temp(struct
> thermal_zone_device *thermal, return
> ti_thermal_get_trip_temp(thermal, OMAP_TRIP_NUMBER - 1, temp); }
> +static const struct thermal_zone_of_device_ops ti_of_thermal_ops = {
> +	.get_temp = __ti_thermal_get_temp,
> +	.get_trend = __ti_thermal_get_trend,
> +};
> +
>  static struct thermal_zone_device_ops ti_thermal_ops = {
>  	.get_temp = ti_thermal_get_temp,
>  	.get_trend = ti_thermal_get_trend,
> @@ -333,8 +338,7 @@ int ti_thermal_expose_sensor(struct ti_bandgap
> *bgp, int id, 
>  	/* in case this is specified by DT */
>  	data->ti_thermal = thermal_zone_of_sensor_register(bgp->dev,
> id,
> -					data, __ti_thermal_get_temp,
> -					__ti_thermal_get_trend);
> +					data, &ti_of_thermal_ops);
>  	if (IS_ERR(data->ti_thermal)) {
>  		/* Create thermal zone */
>  		data->ti_thermal =
> thermal_zone_device_register(domain, diff --git
> a/include/linux/thermal.h b/include/linux/thermal.h index
> ef90838..b565964 100644 --- a/include/linux/thermal.h
> +++ b/include/linux/thermal.h
> @@ -289,19 +289,31 @@ struct thermal_genl_event {
>  	enum events event;
>  };
>  
> +/**
> + * struct thermal_zone_of_device_ops - scallbacks for handling DT
> based zones
> + *
> + * Mandatory:
> + * @get_temp: a pointer to a function that reads the sensor
> temperature.
> + *
> + * Optional:
> + * @get_trend: a pointer to a function that reads the sensor
> temperature trend.
> + */
> +struct thermal_zone_of_device_ops {
> +	int (*get_temp)(void *, long *);
> +	int (*get_trend)(void *, long *);
> +};
> +
>  /* Function declarations */
>  #ifdef CONFIG_THERMAL_OF
>  struct thermal_zone_device *
> -thermal_zone_of_sensor_register(struct device *dev, int id,
> -				void *data, int (*get_temp)(void *,
> long *),
> -				int (*get_trend)(void *, long *));
> +thermal_zone_of_sensor_register(struct device *dev, int id, void
> *data,
> +				const struct
> thermal_zone_of_device_ops *); void
> thermal_zone_of_sensor_unregister(struct device *dev, struct
> thermal_zone_device *tz); #else
>  static inline struct thermal_zone_device *
> -thermal_zone_of_sensor_register(struct device *dev, int id,
> -				void *data, int (*get_temp)(void *,
> long *),
> -				int (*get_trend)(void *, long *))
> +thermal_zone_of_sensor_register(struct device *dev, int id, void
> *data,
> +				const struct
> thermal_zone_of_device_ops *) {
>  	return NULL;
>  }

On which branch should I apply this patch?

I've tried to apply this patch on top of newest linux-soc-thermal/next:
git://git.kernel.org/pub/scm/linux/kernel/git/evalenti/linux-soc-thermal.git
branch: next
SHA1:4027494124fd88e5d51127eebba315de5d8d57c8

Unfortunately, it conflicts with:
"thermal: fix multiple disbalanced device node counters"
c2aad93c Vladimir Zapolskiy


-- 
Best regards,

Lukasz Majewski

Samsung R&D Institute Poland (SRPOL) | Linux Platform Group

^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: [PATCHv4 1/1] thermal: of: improve of-thermal sensor registration API
@ 2014-11-19  8:21       ` Lukasz Majewski
  0 siblings, 0 replies; 20+ messages in thread
From: Lukasz Majewski @ 2014-11-19  8:21 UTC (permalink / raw)
  To: Eduardo Valentin
  Cc: Linux PM, Caesar Wang, Wei Ni, Mikko Perttunen,
	Alexandre Courbot, devicetree, Grant Likely, Guenter Roeck,
	Jean Delvare, linux-kernel, linux-tegra, lm-sensors, Rob Herring,
	Stephen Warren, Thierry Reding, Zhang Rui

Hi Eduardo,

> Different drivers request API extensions in of-thermal. For this
> reason, additional callbacks are required to fit the new drivers
> needs.
> 
> The current API implementation expects the registering sensor driver
> to provide a get_temp and get_trend callbacks as function parameters.
> As the amount of callbacks is growing, this patch changes the existing
> implementation to use a .ops field to hold all the of thermal
> callbacks to sensor drivers.
> 
> This patch also changes the existing of-thermal users to fit the new
> API design. No functional change is introduced in this patch.
> 
> Cc: Alexandre Courbot <gnurou@gmail.com>
> Cc: devicetree@vger.kernel.org
> Cc: Grant Likely <grant.likely@linaro.org>
> Cc: Guenter Roeck <linux@roeck-us.net>
> Cc: Jean Delvare <jdelvare@suse.de>
> Cc: linux-kernel@vger.kernel.org
> Cc: linux-pm@vger.kernel.org
> Cc: linux-tegra@vger.kernel.org
> Cc: lm-sensors@lm-sensors.org
> Cc: Rob Herring <robh+dt@kernel.org>
> Cc: Stephen Warren <swarren@wwwdotorg.org>
> Cc: Thierry Reding <thierry.reding@gmail.com>
> Cc: Zhang Rui <rui.zhang@intel.com>
> Reviewed-by: Lukasz Majewski <l.majewski@samsung.com>
> Signed-off-by: Eduardo Valentin <edubezval@gmail.com>
> ---
>  drivers/hwmon/lm75.c                               |  9 +++--
>  drivers/hwmon/ntc_thermistor.c                     |  6 +++-
>  drivers/hwmon/tmp102.c                             |  6 +++-
>  drivers/thermal/of-thermal.c                       | 40
> ++++++++++------------
> drivers/thermal/tegra_soctherm.c                   |  7 ++--
> drivers/thermal/ti-soc-thermal/ti-thermal-common.c |  8 +++--
> include/linux/thermal.h                            | 24 +++++++++----
> 7 files changed, 63 insertions(+), 37 deletions(-) ---
> Difference from V3:
>   - Keep the same behavior regarding callback checks.
>     Change in behavior may be sent in a separate patch.
> Difference from V2:
>   - Fix wrong assignment in tegra driver.
> Difference from V1:
>   - Fix error handling when .get_trend is not provided.
> 
> diff --git a/drivers/hwmon/lm75.c b/drivers/hwmon/lm75.c
> index d16dbb3..e7c8bf9 100644
> --- a/drivers/hwmon/lm75.c
> +++ b/drivers/hwmon/lm75.c
> @@ -176,6 +176,10 @@ static struct attribute *lm75_attrs[] = {
>  };
>  ATTRIBUTE_GROUPS(lm75);
>  
> +static const struct thermal_zone_of_device_ops lm75_of_thermal_ops =
> {
> +	.get_temp = lm75_read_temp,
> +};
> +
>  /*-----------------------------------------------------------------------*/
>  
>  /* device probe and removal */
> @@ -291,10 +295,9 @@ lm75_probe(struct i2c_client *client, const
> struct i2c_device_id *id) if (IS_ERR(data->hwmon_dev))
>  		return PTR_ERR(data->hwmon_dev);
>  
> -	data->tz = thermal_zone_of_sensor_register(data->hwmon_dev,
> -						   0,
> +	data->tz = thermal_zone_of_sensor_register(data->hwmon_dev,
> 0, data->hwmon_dev,
> -						   lm75_read_temp,
> NULL);
> +
> &lm75_of_thermal_ops); if (IS_ERR(data->tz))
>  		data->tz = NULL;
>  
> diff --git a/drivers/hwmon/ntc_thermistor.c
> b/drivers/hwmon/ntc_thermistor.c index 4ff89b2..bca8521c8 100644
> --- a/drivers/hwmon/ntc_thermistor.c
> +++ b/drivers/hwmon/ntc_thermistor.c
> @@ -486,6 +486,10 @@ static const struct attribute_group
> ntc_attr_group = { .attrs = ntc_attributes,
>  };
>  
> +static const struct thermal_zone_of_device_ops ntc_of_thermal_ops = {
> +	.get_temp = ntc_read_temp,
> +};
> +
>  static int ntc_thermistor_probe(struct platform_device *pdev)
>  {
>  	const struct of_device_id *of_id =
> @@ -579,7 +583,7 @@ static int ntc_thermistor_probe(struct
> platform_device *pdev) pdev_id->name);
>  
>  	data->tz = thermal_zone_of_sensor_register(data->dev, 0,
> data->dev,
> -						ntc_read_temp, NULL);
> +
> &ntc_of_thermal_ops); if (IS_ERR(data->tz)) {
>  		dev_dbg(&pdev->dev, "Failed to register to thermal
> fw.\n"); data->tz = NULL;
> diff --git a/drivers/hwmon/tmp102.c b/drivers/hwmon/tmp102.c
> index 5171995..ba9f478 100644
> --- a/drivers/hwmon/tmp102.c
> +++ b/drivers/hwmon/tmp102.c
> @@ -158,6 +158,10 @@ ATTRIBUTE_GROUPS(tmp102);
>  #define TMP102_CONFIG  (TMP102_CONF_TM | TMP102_CONF_EM |
> TMP102_CONF_CR1) #define TMP102_CONFIG_RD_ONLY (TMP102_CONF_R0 |
> TMP102_CONF_R1 | TMP102_CONF_AL) 
> +static const struct thermal_zone_of_device_ops tmp102_of_thermal_ops
> = {
> +	.get_temp = tmp102_read_temp,
> +};
> +
>  static int tmp102_probe(struct i2c_client *client,
>  				  const struct i2c_device_id *id)
>  {
> @@ -215,7 +219,7 @@ static int tmp102_probe(struct i2c_client *client,
>  	}
>  	tmp102->hwmon_dev = hwmon_dev;
>  	tmp102->tz = thermal_zone_of_sensor_register(hwmon_dev, 0,
> hwmon_dev,
> -
> tmp102_read_temp, NULL);
> +
> &tmp102_of_thermal_ops); if (IS_ERR(tmp102->tz))
>  		tmp102->tz = NULL;
>  
> diff --git a/drivers/thermal/of-thermal.c
> b/drivers/thermal/of-thermal.c index f8eb625..e87ccdb 100644
> --- a/drivers/thermal/of-thermal.c
> +++ b/drivers/thermal/of-thermal.c
> @@ -30,6 +30,7 @@
>  #include <linux/err.h>
>  #include <linux/export.h>
>  #include <linux/string.h>
> +#include <linux/thermal.h>
>  
>  #include "thermal_core.h"
>  
> @@ -77,8 +78,7 @@ struct __thermal_bind_params {
>   * @num_tbps: number of thermal bind params
>   * @tbps: an array of thermal bind params (0..num_tbps - 1)
>   * @sensor_data: sensor private data used while reading temperature
> and trend
> - * @get_temp: sensor callback to read temperature
> - * @get_trend: sensor callback to read temperature trend
> + * @ops: set of callbacks to handle the thermal zone based on DT
>   */
>  
>  struct __thermal_zone {
> @@ -96,8 +96,7 @@ struct __thermal_zone {
>  
>  	/* sensor interface */
>  	void *sensor_data;
> -	int (*get_temp)(void *, long *);
> -	int (*get_trend)(void *, long *);
> +	const struct thermal_zone_of_device_ops *ops;
>  };
>  
>  /***   DT thermal zone device callbacks   ***/
> @@ -107,10 +106,10 @@ static int of_thermal_get_temp(struct
> thermal_zone_device *tz, {
>  	struct __thermal_zone *data = tz->devdata;
>  
> -	if (!data->get_temp)
> +	if (!data->ops->get_temp)
>  		return -EINVAL;
>  
> -	return data->get_temp(data->sensor_data, temp);
> +	return data->ops->get_temp(data->sensor_data, temp);
>  }
>  
>  static int of_thermal_get_trend(struct thermal_zone_device *tz, int
> trip, @@ -120,10 +119,10 @@ static int of_thermal_get_trend(struct
> thermal_zone_device *tz, int trip, long dev_trend;
>  	int r;
>  
> -	if (!data->get_trend)
> +	if (!data->ops->get_trend)
>  		return -EINVAL;
>  
> -	r = data->get_trend(data->sensor_data, &dev_trend);
> +	r = data->ops->get_trend(data->sensor_data, &dev_trend);
>  	if (r)
>  		return r;
>  
> @@ -324,8 +323,7 @@ static struct thermal_zone_device_ops
> of_thermal_ops = { static struct thermal_zone_device *
>  thermal_zone_of_add_sensor(struct device_node *zone,
>  			   struct device_node *sensor, void *data,
> -			   int (*get_temp)(void *, long *),
> -			   int (*get_trend)(void *, long *))
> +			   const struct thermal_zone_of_device_ops
> *ops) {
>  	struct thermal_zone_device *tzd;
>  	struct __thermal_zone *tz;
> @@ -336,9 +334,11 @@ thermal_zone_of_add_sensor(struct device_node
> *zone, 
>  	tz = tzd->devdata;
>  
> +	if (!ops)
> +		return ERR_PTR(-EINVAL);
> +
>  	mutex_lock(&tzd->lock);
> -	tz->get_temp = get_temp;
> -	tz->get_trend = get_trend;
> +	tz->ops = ops;
>  	tz->sensor_data = data;
>  
>  	tzd->ops->get_temp = of_thermal_get_temp;
> @@ -356,8 +356,8 @@ thermal_zone_of_add_sensor(struct device_node
> *zone,
>   *             than one sensors
>   * @data: a private pointer (owned by the caller) that will be passed
>   *        back, when a temperature reading is needed.
> - * @get_temp: a pointer to a function that reads the sensor
> temperature.
> - * @get_trend: a pointer to a function that reads the sensor
> temperature trend.
> + * @ops: struct thermal_zone_of_device *. Must contain at
> least .get_trend and
> + *       .get_temp.
>   *
>   * This function will search the list of thermal zones described in
> device
>   * tree and look for the zone that refer to the sensor device
> pointed by @@ -382,9 +382,8 @@ thermal_zone_of_add_sensor(struct
> device_node *zone,
>   * check the return value with help of IS_ERR() helper.
>   */
>  struct thermal_zone_device *
> -thermal_zone_of_sensor_register(struct device *dev, int sensor_id,
> -				void *data, int (*get_temp)(void *,
> long *),
> -				int (*get_trend)(void *, long *))
> +thermal_zone_of_sensor_register(struct device *dev, int sensor_id,
> void *data,
> +				const struct
> thermal_zone_of_device_ops *ops) {
>  	struct device_node *np, *child, *sensor_np;
>  
> @@ -424,9 +423,7 @@ thermal_zone_of_sensor_register(struct device
> *dev, int sensor_id, if (sensor_specs.np == sensor_np && id ==
> sensor_id) { of_node_put(np);
>  			return thermal_zone_of_add_sensor(child,
> sensor_np,
> -							  data,
> -							  get_temp,
> -							  get_trend);
> +							  data, ops);
>  		}
>  	}
>  	of_node_put(np);
> @@ -468,8 +465,7 @@ void thermal_zone_of_sensor_unregister(struct
> device *dev, tzd->ops->get_temp = NULL;
>  	tzd->ops->get_trend = NULL;
>  
> -	tz->get_temp = NULL;
> -	tz->get_trend = NULL;
> +	tz->ops = NULL;
>  	tz->sensor_data = NULL;
>  	mutex_unlock(&tzd->lock);
>  }
> diff --git a/drivers/thermal/tegra_soctherm.c
> b/drivers/thermal/tegra_soctherm.c index 70f7e9e..9197fc0 100644
> --- a/drivers/thermal/tegra_soctherm.c
> +++ b/drivers/thermal/tegra_soctherm.c
> @@ -317,6 +317,10 @@ static int tegra_thermctl_get_temp(void *data,
> long *out_temp) return 0;
>  }
>  
> +static const struct thermal_zone_of_device_ops tegra_of_thermal_ops
> = {
> +	.get_temp = tegra_thermctl_get_temp,
> +};
> +
>  static const struct of_device_id tegra_soctherm_of_match[] = {
>  	{ .compatible = "nvidia,tegra124-soctherm" },
>  	{ },
> @@ -416,8 +420,7 @@ static int tegra_soctherm_probe(struct
> platform_device *pdev) zone->shift =
> t124_thermctl_temp_zones[i].shift; 
>  		tz = thermal_zone_of_sensor_register(&pdev->dev, i,
> zone,
> -
> tegra_thermctl_get_temp,
> -						     NULL);
> +
> &tegra_of_thermal_ops); if (IS_ERR(tz)) {
>  			err = PTR_ERR(tz);
>  			dev_err(&pdev->dev, "failed to register
> sensor: %d\n", diff --git
> a/drivers/thermal/ti-soc-thermal/ti-thermal-common.c
> b/drivers/thermal/ti-soc-thermal/ti-thermal-common.c index
> 9eec26d..5fd0386 100644 ---
> a/drivers/thermal/ti-soc-thermal/ti-thermal-common.c +++
> b/drivers/thermal/ti-soc-thermal/ti-thermal-common.c @@ -286,6
> +286,11 @@ static int ti_thermal_get_crit_temp(struct
> thermal_zone_device *thermal, return
> ti_thermal_get_trip_temp(thermal, OMAP_TRIP_NUMBER - 1, temp); }
> +static const struct thermal_zone_of_device_ops ti_of_thermal_ops = {
> +	.get_temp = __ti_thermal_get_temp,
> +	.get_trend = __ti_thermal_get_trend,
> +};
> +
>  static struct thermal_zone_device_ops ti_thermal_ops = {
>  	.get_temp = ti_thermal_get_temp,
>  	.get_trend = ti_thermal_get_trend,
> @@ -333,8 +338,7 @@ int ti_thermal_expose_sensor(struct ti_bandgap
> *bgp, int id, 
>  	/* in case this is specified by DT */
>  	data->ti_thermal = thermal_zone_of_sensor_register(bgp->dev,
> id,
> -					data, __ti_thermal_get_temp,
> -					__ti_thermal_get_trend);
> +					data, &ti_of_thermal_ops);
>  	if (IS_ERR(data->ti_thermal)) {
>  		/* Create thermal zone */
>  		data->ti_thermal =
> thermal_zone_device_register(domain, diff --git
> a/include/linux/thermal.h b/include/linux/thermal.h index
> ef90838..b565964 100644 --- a/include/linux/thermal.h
> +++ b/include/linux/thermal.h
> @@ -289,19 +289,31 @@ struct thermal_genl_event {
>  	enum events event;
>  };
>  
> +/**
> + * struct thermal_zone_of_device_ops - scallbacks for handling DT
> based zones
> + *
> + * Mandatory:
> + * @get_temp: a pointer to a function that reads the sensor
> temperature.
> + *
> + * Optional:
> + * @get_trend: a pointer to a function that reads the sensor
> temperature trend.
> + */
> +struct thermal_zone_of_device_ops {
> +	int (*get_temp)(void *, long *);
> +	int (*get_trend)(void *, long *);
> +};
> +
>  /* Function declarations */
>  #ifdef CONFIG_THERMAL_OF
>  struct thermal_zone_device *
> -thermal_zone_of_sensor_register(struct device *dev, int id,
> -				void *data, int (*get_temp)(void *,
> long *),
> -				int (*get_trend)(void *, long *));
> +thermal_zone_of_sensor_register(struct device *dev, int id, void
> *data,
> +				const struct
> thermal_zone_of_device_ops *); void
> thermal_zone_of_sensor_unregister(struct device *dev, struct
> thermal_zone_device *tz); #else
>  static inline struct thermal_zone_device *
> -thermal_zone_of_sensor_register(struct device *dev, int id,
> -				void *data, int (*get_temp)(void *,
> long *),
> -				int (*get_trend)(void *, long *))
> +thermal_zone_of_sensor_register(struct device *dev, int id, void
> *data,
> +				const struct
> thermal_zone_of_device_ops *) {
>  	return NULL;
>  }

On which branch should I apply this patch?

I've tried to apply this patch on top of newest linux-soc-thermal/next:
git://git.kernel.org/pub/scm/linux/kernel/git/evalenti/linux-soc-thermal.git
branch: next
SHA1:4027494124fd88e5d51127eebba315de5d8d57c8

Unfortunately, it conflicts with:
"thermal: fix multiple disbalanced device node counters"
c2aad93c Vladimir Zapolskiy


-- 
Best regards,

Lukasz Majewski

Samsung R&D Institute Poland (SRPOL) | Linux Platform Group

^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: [lm-sensors] [PATCHv4 1/1] thermal: of: improve of-thermal sensor registration API
@ 2014-11-19  8:21       ` Lukasz Majewski
  0 siblings, 0 replies; 20+ messages in thread
From: Lukasz Majewski @ 2014-11-19  8:21 UTC (permalink / raw)
  To: Eduardo Valentin
  Cc: Linux PM, Caesar Wang, Wei Ni, Mikko Perttunen,
	Alexandre Courbot, devicetree-u79uwXL29TY76Z2rM5mHXA,
	Grant Likely, Guenter Roeck, Jean Delvare,
	linux-kernel-u79uwXL29TY76Z2rM5mHXA,
	linux-tegra-u79uwXL29TY76Z2rM5mHXA,
	lm-sensors-GZX6beZjE8VD60Wz+7aTrA, Rob Herring, Stephen Warren,
	Thierry Reding, Zhang Rui

Hi Eduardo,

> Different drivers request API extensions in of-thermal. For this
> reason, additional callbacks are required to fit the new drivers
> needs.
> 
> The current API implementation expects the registering sensor driver
> to provide a get_temp and get_trend callbacks as function parameters.
> As the amount of callbacks is growing, this patch changes the existing
> implementation to use a .ops field to hold all the of thermal
> callbacks to sensor drivers.
> 
> This patch also changes the existing of-thermal users to fit the new
> API design. No functional change is introduced in this patch.
> 
> Cc: Alexandre Courbot <gnurou@gmail.com>
> Cc: devicetree@vger.kernel.org
> Cc: Grant Likely <grant.likely@linaro.org>
> Cc: Guenter Roeck <linux@roeck-us.net>
> Cc: Jean Delvare <jdelvare@suse.de>
> Cc: linux-kernel@vger.kernel.org
> Cc: linux-pm@vger.kernel.org
> Cc: linux-tegra@vger.kernel.org
> Cc: lm-sensors@lm-sensors.org
> Cc: Rob Herring <robh+dt@kernel.org>
> Cc: Stephen Warren <swarren@wwwdotorg.org>
> Cc: Thierry Reding <thierry.reding@gmail.com>
> Cc: Zhang Rui <rui.zhang@intel.com>
> Reviewed-by: Lukasz Majewski <l.majewski@samsung.com>
> Signed-off-by: Eduardo Valentin <edubezval@gmail.com>
> ---
>  drivers/hwmon/lm75.c                               |  9 +++--
>  drivers/hwmon/ntc_thermistor.c                     |  6 +++-
>  drivers/hwmon/tmp102.c                             |  6 +++-
>  drivers/thermal/of-thermal.c                       | 40
> ++++++++++------------
> drivers/thermal/tegra_soctherm.c                   |  7 ++--
> drivers/thermal/ti-soc-thermal/ti-thermal-common.c |  8 +++--
> include/linux/thermal.h                            | 24 +++++++++----
> 7 files changed, 63 insertions(+), 37 deletions(-) ---
> Difference from V3:
>   - Keep the same behavior regarding callback checks.
>     Change in behavior may be sent in a separate patch.
> Difference from V2:
>   - Fix wrong assignment in tegra driver.
> Difference from V1:
>   - Fix error handling when .get_trend is not provided.
> 
> diff --git a/drivers/hwmon/lm75.c b/drivers/hwmon/lm75.c
> index d16dbb3..e7c8bf9 100644
> --- a/drivers/hwmon/lm75.c
> +++ b/drivers/hwmon/lm75.c
> @@ -176,6 +176,10 @@ static struct attribute *lm75_attrs[] = {
>  };
>  ATTRIBUTE_GROUPS(lm75);
>  
> +static const struct thermal_zone_of_device_ops lm75_of_thermal_ops > {
> +	.get_temp = lm75_read_temp,
> +};
> +
>  /*-----------------------------------------------------------------------*/
>  
>  /* device probe and removal */
> @@ -291,10 +295,9 @@ lm75_probe(struct i2c_client *client, const
> struct i2c_device_id *id) if (IS_ERR(data->hwmon_dev))
>  		return PTR_ERR(data->hwmon_dev);
>  
> -	data->tz = thermal_zone_of_sensor_register(data->hwmon_dev,
> -						   0,
> +	data->tz = thermal_zone_of_sensor_register(data->hwmon_dev,
> 0, data->hwmon_dev,
> -						   lm75_read_temp,
> NULL);
> +
> &lm75_of_thermal_ops); if (IS_ERR(data->tz))
>  		data->tz = NULL;
>  
> diff --git a/drivers/hwmon/ntc_thermistor.c
> b/drivers/hwmon/ntc_thermistor.c index 4ff89b2..bca8521c8 100644
> --- a/drivers/hwmon/ntc_thermistor.c
> +++ b/drivers/hwmon/ntc_thermistor.c
> @@ -486,6 +486,10 @@ static const struct attribute_group
> ntc_attr_group = { .attrs = ntc_attributes,
>  };
>  
> +static const struct thermal_zone_of_device_ops ntc_of_thermal_ops = {
> +	.get_temp = ntc_read_temp,
> +};
> +
>  static int ntc_thermistor_probe(struct platform_device *pdev)
>  {
>  	const struct of_device_id *of_id > @@ -579,7 +583,7 @@ static int ntc_thermistor_probe(struct
> platform_device *pdev) pdev_id->name);
>  
>  	data->tz = thermal_zone_of_sensor_register(data->dev, 0,
> data->dev,
> -						ntc_read_temp, NULL);
> +
> &ntc_of_thermal_ops); if (IS_ERR(data->tz)) {
>  		dev_dbg(&pdev->dev, "Failed to register to thermal
> fw.\n"); data->tz = NULL;
> diff --git a/drivers/hwmon/tmp102.c b/drivers/hwmon/tmp102.c
> index 5171995..ba9f478 100644
> --- a/drivers/hwmon/tmp102.c
> +++ b/drivers/hwmon/tmp102.c
> @@ -158,6 +158,10 @@ ATTRIBUTE_GROUPS(tmp102);
>  #define TMP102_CONFIG  (TMP102_CONF_TM | TMP102_CONF_EM |
> TMP102_CONF_CR1) #define TMP102_CONFIG_RD_ONLY (TMP102_CONF_R0 |
> TMP102_CONF_R1 | TMP102_CONF_AL) 
> +static const struct thermal_zone_of_device_ops tmp102_of_thermal_ops
> = {
> +	.get_temp = tmp102_read_temp,
> +};
> +
>  static int tmp102_probe(struct i2c_client *client,
>  				  const struct i2c_device_id *id)
>  {
> @@ -215,7 +219,7 @@ static int tmp102_probe(struct i2c_client *client,
>  	}
>  	tmp102->hwmon_dev = hwmon_dev;
>  	tmp102->tz = thermal_zone_of_sensor_register(hwmon_dev, 0,
> hwmon_dev,
> -
> tmp102_read_temp, NULL);
> +
> &tmp102_of_thermal_ops); if (IS_ERR(tmp102->tz))
>  		tmp102->tz = NULL;
>  
> diff --git a/drivers/thermal/of-thermal.c
> b/drivers/thermal/of-thermal.c index f8eb625..e87ccdb 100644
> --- a/drivers/thermal/of-thermal.c
> +++ b/drivers/thermal/of-thermal.c
> @@ -30,6 +30,7 @@
>  #include <linux/err.h>
>  #include <linux/export.h>
>  #include <linux/string.h>
> +#include <linux/thermal.h>
>  
>  #include "thermal_core.h"
>  
> @@ -77,8 +78,7 @@ struct __thermal_bind_params {
>   * @num_tbps: number of thermal bind params
>   * @tbps: an array of thermal bind params (0..num_tbps - 1)
>   * @sensor_data: sensor private data used while reading temperature
> and trend
> - * @get_temp: sensor callback to read temperature
> - * @get_trend: sensor callback to read temperature trend
> + * @ops: set of callbacks to handle the thermal zone based on DT
>   */
>  
>  struct __thermal_zone {
> @@ -96,8 +96,7 @@ struct __thermal_zone {
>  
>  	/* sensor interface */
>  	void *sensor_data;
> -	int (*get_temp)(void *, long *);
> -	int (*get_trend)(void *, long *);
> +	const struct thermal_zone_of_device_ops *ops;
>  };
>  
>  /***   DT thermal zone device callbacks   ***/
> @@ -107,10 +106,10 @@ static int of_thermal_get_temp(struct
> thermal_zone_device *tz, {
>  	struct __thermal_zone *data = tz->devdata;
>  
> -	if (!data->get_temp)
> +	if (!data->ops->get_temp)
>  		return -EINVAL;
>  
> -	return data->get_temp(data->sensor_data, temp);
> +	return data->ops->get_temp(data->sensor_data, temp);
>  }
>  
>  static int of_thermal_get_trend(struct thermal_zone_device *tz, int
> trip, @@ -120,10 +119,10 @@ static int of_thermal_get_trend(struct
> thermal_zone_device *tz, int trip, long dev_trend;
>  	int r;
>  
> -	if (!data->get_trend)
> +	if (!data->ops->get_trend)
>  		return -EINVAL;
>  
> -	r = data->get_trend(data->sensor_data, &dev_trend);
> +	r = data->ops->get_trend(data->sensor_data, &dev_trend);
>  	if (r)
>  		return r;
>  
> @@ -324,8 +323,7 @@ static struct thermal_zone_device_ops
> of_thermal_ops = { static struct thermal_zone_device *
>  thermal_zone_of_add_sensor(struct device_node *zone,
>  			   struct device_node *sensor, void *data,
> -			   int (*get_temp)(void *, long *),
> -			   int (*get_trend)(void *, long *))
> +			   const struct thermal_zone_of_device_ops
> *ops) {
>  	struct thermal_zone_device *tzd;
>  	struct __thermal_zone *tz;
> @@ -336,9 +334,11 @@ thermal_zone_of_add_sensor(struct device_node
> *zone, 
>  	tz = tzd->devdata;
>  
> +	if (!ops)
> +		return ERR_PTR(-EINVAL);
> +
>  	mutex_lock(&tzd->lock);
> -	tz->get_temp = get_temp;
> -	tz->get_trend = get_trend;
> +	tz->ops = ops;
>  	tz->sensor_data = data;
>  
>  	tzd->ops->get_temp = of_thermal_get_temp;
> @@ -356,8 +356,8 @@ thermal_zone_of_add_sensor(struct device_node
> *zone,
>   *             than one sensors
>   * @data: a private pointer (owned by the caller) that will be passed
>   *        back, when a temperature reading is needed.
> - * @get_temp: a pointer to a function that reads the sensor
> temperature.
> - * @get_trend: a pointer to a function that reads the sensor
> temperature trend.
> + * @ops: struct thermal_zone_of_device *. Must contain at
> least .get_trend and
> + *       .get_temp.
>   *
>   * This function will search the list of thermal zones described in
> device
>   * tree and look for the zone that refer to the sensor device
> pointed by @@ -382,9 +382,8 @@ thermal_zone_of_add_sensor(struct
> device_node *zone,
>   * check the return value with help of IS_ERR() helper.
>   */
>  struct thermal_zone_device *
> -thermal_zone_of_sensor_register(struct device *dev, int sensor_id,
> -				void *data, int (*get_temp)(void *,
> long *),
> -				int (*get_trend)(void *, long *))
> +thermal_zone_of_sensor_register(struct device *dev, int sensor_id,
> void *data,
> +				const struct
> thermal_zone_of_device_ops *ops) {
>  	struct device_node *np, *child, *sensor_np;
>  
> @@ -424,9 +423,7 @@ thermal_zone_of_sensor_register(struct device
> *dev, int sensor_id, if (sensor_specs.np = sensor_np && id =
> sensor_id) { of_node_put(np);
>  			return thermal_zone_of_add_sensor(child,
> sensor_np,
> -							  data,
> -							  get_temp,
> -							  get_trend);
> +							  data, ops);
>  		}
>  	}
>  	of_node_put(np);
> @@ -468,8 +465,7 @@ void thermal_zone_of_sensor_unregister(struct
> device *dev, tzd->ops->get_temp = NULL;
>  	tzd->ops->get_trend = NULL;
>  
> -	tz->get_temp = NULL;
> -	tz->get_trend = NULL;
> +	tz->ops = NULL;
>  	tz->sensor_data = NULL;
>  	mutex_unlock(&tzd->lock);
>  }
> diff --git a/drivers/thermal/tegra_soctherm.c
> b/drivers/thermal/tegra_soctherm.c index 70f7e9e..9197fc0 100644
> --- a/drivers/thermal/tegra_soctherm.c
> +++ b/drivers/thermal/tegra_soctherm.c
> @@ -317,6 +317,10 @@ static int tegra_thermctl_get_temp(void *data,
> long *out_temp) return 0;
>  }
>  
> +static const struct thermal_zone_of_device_ops tegra_of_thermal_ops
> = {
> +	.get_temp = tegra_thermctl_get_temp,
> +};
> +
>  static const struct of_device_id tegra_soctherm_of_match[] = {
>  	{ .compatible = "nvidia,tegra124-soctherm" },
>  	{ },
> @@ -416,8 +420,7 @@ static int tegra_soctherm_probe(struct
> platform_device *pdev) zone->shift > t124_thermctl_temp_zones[i].shift; 
>  		tz = thermal_zone_of_sensor_register(&pdev->dev, i,
> zone,
> -
> tegra_thermctl_get_temp,
> -						     NULL);
> +
> &tegra_of_thermal_ops); if (IS_ERR(tz)) {
>  			err = PTR_ERR(tz);
>  			dev_err(&pdev->dev, "failed to register
> sensor: %d\n", diff --git
> a/drivers/thermal/ti-soc-thermal/ti-thermal-common.c
> b/drivers/thermal/ti-soc-thermal/ti-thermal-common.c index
> 9eec26d..5fd0386 100644 ---
> a/drivers/thermal/ti-soc-thermal/ti-thermal-common.c +++
> b/drivers/thermal/ti-soc-thermal/ti-thermal-common.c @@ -286,6
> +286,11 @@ static int ti_thermal_get_crit_temp(struct
> thermal_zone_device *thermal, return
> ti_thermal_get_trip_temp(thermal, OMAP_TRIP_NUMBER - 1, temp); }
> +static const struct thermal_zone_of_device_ops ti_of_thermal_ops = {
> +	.get_temp = __ti_thermal_get_temp,
> +	.get_trend = __ti_thermal_get_trend,
> +};
> +
>  static struct thermal_zone_device_ops ti_thermal_ops = {
>  	.get_temp = ti_thermal_get_temp,
>  	.get_trend = ti_thermal_get_trend,
> @@ -333,8 +338,7 @@ int ti_thermal_expose_sensor(struct ti_bandgap
> *bgp, int id, 
>  	/* in case this is specified by DT */
>  	data->ti_thermal = thermal_zone_of_sensor_register(bgp->dev,
> id,
> -					data, __ti_thermal_get_temp,
> -					__ti_thermal_get_trend);
> +					data, &ti_of_thermal_ops);
>  	if (IS_ERR(data->ti_thermal)) {
>  		/* Create thermal zone */
>  		data->ti_thermal > thermal_zone_device_register(domain, diff --git
> a/include/linux/thermal.h b/include/linux/thermal.h index
> ef90838..b565964 100644 --- a/include/linux/thermal.h
> +++ b/include/linux/thermal.h
> @@ -289,19 +289,31 @@ struct thermal_genl_event {
>  	enum events event;
>  };
>  
> +/**
> + * struct thermal_zone_of_device_ops - scallbacks for handling DT
> based zones
> + *
> + * Mandatory:
> + * @get_temp: a pointer to a function that reads the sensor
> temperature.
> + *
> + * Optional:
> + * @get_trend: a pointer to a function that reads the sensor
> temperature trend.
> + */
> +struct thermal_zone_of_device_ops {
> +	int (*get_temp)(void *, long *);
> +	int (*get_trend)(void *, long *);
> +};
> +
>  /* Function declarations */
>  #ifdef CONFIG_THERMAL_OF
>  struct thermal_zone_device *
> -thermal_zone_of_sensor_register(struct device *dev, int id,
> -				void *data, int (*get_temp)(void *,
> long *),
> -				int (*get_trend)(void *, long *));
> +thermal_zone_of_sensor_register(struct device *dev, int id, void
> *data,
> +				const struct
> thermal_zone_of_device_ops *); void
> thermal_zone_of_sensor_unregister(struct device *dev, struct
> thermal_zone_device *tz); #else
>  static inline struct thermal_zone_device *
> -thermal_zone_of_sensor_register(struct device *dev, int id,
> -				void *data, int (*get_temp)(void *,
> long *),
> -				int (*get_trend)(void *, long *))
> +thermal_zone_of_sensor_register(struct device *dev, int id, void
> *data,
> +				const struct
> thermal_zone_of_device_ops *) {
>  	return NULL;
>  }

On which branch should I apply this patch?

I've tried to apply this patch on top of newest linux-soc-thermal/next:
git://git.kernel.org/pub/scm/linux/kernel/git/evalenti/linux-soc-thermal.git
branch: next
SHA1:4027494124fd88e5d51127eebba315de5d8d57c8

Unfortunately, it conflicts with:
"thermal: fix multiple disbalanced device node counters"
c2aad93c Vladimir Zapolskiy


-- 
Best regards,

Lukasz Majewski

Samsung R&D Institute Poland (SRPOL) | Linux Platform Group

_______________________________________________
lm-sensors mailing list
lm-sensors@lm-sensors.org
http://lists.lm-sensors.org/mailman/listinfo/lm-sensors

^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: [PATCHv4 1/1] thermal: of: improve of-thermal sensor registration API
  2014-11-19  8:21       ` Lukasz Majewski
  (?)
@ 2014-11-19 12:03         ` Eduardo Valentin
  -1 siblings, 0 replies; 20+ messages in thread
From: Eduardo Valentin @ 2014-11-19 12:03 UTC (permalink / raw)
  To: Lukasz Majewski
  Cc: Linux PM, Caesar Wang, Wei Ni, Mikko Perttunen,
	Alexandre Courbot, devicetree-u79uwXL29TY76Z2rM5mHXA,
	Grant Likely, Guenter Roeck, Jean Delvare,
	linux-kernel-u79uwXL29TY76Z2rM5mHXA,
	linux-tegra-u79uwXL29TY76Z2rM5mHXA,
	lm-sensors-GZX6beZjE8VD60Wz+7aTrA, Rob Herring, Stephen Warren,
	Thierry Reding, Zhang Rui

[-- Attachment #1: Type: text/plain, Size: 1082 bytes --]


Hey Lukasz,

On Wed, Nov 19, 2014 at 09:21:39AM +0100, Lukasz Majewski wrote:
> Hi Eduardo,
> 

<big cut> 

> >  }
> 
> On which branch should I apply this patch?
> 

This is based in my -linus branch. That means I will send this for the
next major window, not rc. The branch -fixes of thermal-soc include
patches for rc windows.

> I've tried to apply this patch on top of newest linux-soc-thermal/next:
> git://git.kernel.org/pub/scm/linux/kernel/git/evalenti/linux-soc-thermal.git
> branch: next
> SHA1:4027494124fd88e5d51127eebba315de5d8d57c8
> 
> Unfortunately, it conflicts with:
> "thermal: fix multiple disbalanced device node counters"
> c2aad93c Vladimir Zapolskiy

The -next branch is intended to contain patches for linux-next testing.
I include the content of -linus and -fixes together to be tested in
linux-next.

However, as this patch has not been merged yet into -linus, I haven't
rebuilt my -next branch.

> 
> 
> -- 
> Best regards,
> 
> Lukasz Majewski
> 
> Samsung R&D Institute Poland (SRPOL) | Linux Platform Group

[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 473 bytes --]

^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: [PATCHv4 1/1] thermal: of: improve of-thermal sensor registration API
@ 2014-11-19 12:03         ` Eduardo Valentin
  0 siblings, 0 replies; 20+ messages in thread
From: Eduardo Valentin @ 2014-11-19 12:03 UTC (permalink / raw)
  To: Lukasz Majewski
  Cc: Linux PM, Caesar Wang, Wei Ni, Mikko Perttunen,
	Alexandre Courbot, devicetree, Grant Likely, Guenter Roeck,
	Jean Delvare, linux-kernel, linux-tegra, lm-sensors, Rob Herring,
	Stephen Warren, Thierry Reding, Zhang Rui

[-- Attachment #1: Type: text/plain, Size: 1082 bytes --]


Hey Lukasz,

On Wed, Nov 19, 2014 at 09:21:39AM +0100, Lukasz Majewski wrote:
> Hi Eduardo,
> 

<big cut> 

> >  }
> 
> On which branch should I apply this patch?
> 

This is based in my -linus branch. That means I will send this for the
next major window, not rc. The branch -fixes of thermal-soc include
patches for rc windows.

> I've tried to apply this patch on top of newest linux-soc-thermal/next:
> git://git.kernel.org/pub/scm/linux/kernel/git/evalenti/linux-soc-thermal.git
> branch: next
> SHA1:4027494124fd88e5d51127eebba315de5d8d57c8
> 
> Unfortunately, it conflicts with:
> "thermal: fix multiple disbalanced device node counters"
> c2aad93c Vladimir Zapolskiy

The -next branch is intended to contain patches for linux-next testing.
I include the content of -linus and -fixes together to be tested in
linux-next.

However, as this patch has not been merged yet into -linus, I haven't
rebuilt my -next branch.

> 
> 
> -- 
> Best regards,
> 
> Lukasz Majewski
> 
> Samsung R&D Institute Poland (SRPOL) | Linux Platform Group

[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 473 bytes --]

^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: [lm-sensors] [PATCHv4 1/1] thermal: of: improve of-thermal sensor registration API
@ 2014-11-19 12:03         ` Eduardo Valentin
  0 siblings, 0 replies; 20+ messages in thread
From: Eduardo Valentin @ 2014-11-19 12:03 UTC (permalink / raw)
  To: Lukasz Majewski
  Cc: Linux PM, Caesar Wang, Wei Ni, Mikko Perttunen,
	Alexandre Courbot, devicetree-u79uwXL29TY76Z2rM5mHXA,
	Grant Likely, Guenter Roeck, Jean Delvare,
	linux-kernel-u79uwXL29TY76Z2rM5mHXA,
	linux-tegra-u79uwXL29TY76Z2rM5mHXA,
	lm-sensors-GZX6beZjE8VD60Wz+7aTrA, Rob Herring, Stephen Warren,
	Thierry Reding, Zhang Rui


[-- Attachment #1.1: Type: text/plain, Size: 1082 bytes --]


Hey Lukasz,

On Wed, Nov 19, 2014 at 09:21:39AM +0100, Lukasz Majewski wrote:
> Hi Eduardo,
> 

<big cut> 

> >  }
> 
> On which branch should I apply this patch?
> 

This is based in my -linus branch. That means I will send this for the
next major window, not rc. The branch -fixes of thermal-soc include
patches for rc windows.

> I've tried to apply this patch on top of newest linux-soc-thermal/next:
> git://git.kernel.org/pub/scm/linux/kernel/git/evalenti/linux-soc-thermal.git
> branch: next
> SHA1:4027494124fd88e5d51127eebba315de5d8d57c8
> 
> Unfortunately, it conflicts with:
> "thermal: fix multiple disbalanced device node counters"
> c2aad93c Vladimir Zapolskiy

The -next branch is intended to contain patches for linux-next testing.
I include the content of -linus and -fixes together to be tested in
linux-next.

However, as this patch has not been merged yet into -linus, I haven't
rebuilt my -next branch.

> 
> 
> -- 
> Best regards,
> 
> Lukasz Majewski
> 
> Samsung R&D Institute Poland (SRPOL) | Linux Platform Group

[-- Attachment #1.2: Digital signature --]
[-- Type: application/pgp-signature, Size: 473 bytes --]

[-- Attachment #2: Type: text/plain, Size: 153 bytes --]

_______________________________________________
lm-sensors mailing list
lm-sensors@lm-sensors.org
http://lists.lm-sensors.org/mailman/listinfo/lm-sensors

^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: [PATCHv4 1/1] thermal: of: improve of-thermal sensor registration API
  2014-11-18 14:39   ` [lm-sensors] " Eduardo Valentin
@ 2014-11-19 15:41     ` Mikko Perttunen
  -1 siblings, 0 replies; 20+ messages in thread
From: Mikko Perttunen @ 2014-11-19 15:41 UTC (permalink / raw)
  To: Eduardo Valentin, Linux PM
  Cc: Caesar Wang, Wei Ni, Lukasz Majewski, Alexandre Courbot,
	devicetree, Grant Likely, Guenter Roeck, Jean Delvare,
	linux-kernel, linux-tegra, lm-sensors, Rob Herring,
	Stephen Warren, Thierry Reding, Zhang Rui

On 11/18/2014 04:39 PM, Eduardo Valentin wrote:
> Different drivers request API extensions in of-thermal. For this reason,
> additional callbacks are required to fit the new drivers needs.
>
> The current API implementation expects the registering sensor driver
> to provide a get_temp and get_trend callbacks as function parameters.
> As the amount of callbacks is growing, this patch changes the existing
> implementation to use a .ops field to hold all the of thermal callbacks
> to sensor drivers.
>
> This patch also changes the existing of-thermal users to fit the new
> API design. No functional change is introduced in this patch.
>
> Cc: Alexandre Courbot <gnurou@gmail.com>
> Cc: devicetree@vger.kernel.org
> Cc: Grant Likely <grant.likely@linaro.org>
> Cc: Guenter Roeck <linux@roeck-us.net>
> Cc: Jean Delvare <jdelvare@suse.de>
> Cc: linux-kernel@vger.kernel.org
> Cc: linux-pm@vger.kernel.org
> Cc: linux-tegra@vger.kernel.org
> Cc: lm-sensors@lm-sensors.org
> Cc: Rob Herring <robh+dt@kernel.org>
> Cc: Stephen Warren <swarren@wwwdotorg.org>
> Cc: Thierry Reding <thierry.reding@gmail.com>
> Cc: Zhang Rui <rui.zhang@intel.com>
> Reviewed-by: Lukasz Majewski <l.majewski@samsung.com>
> Signed-off-by: Eduardo Valentin <edubezval@gmail.com>
> ---
>   drivers/hwmon/lm75.c                               |  9 +++--
>   drivers/hwmon/ntc_thermistor.c                     |  6 +++-
>   drivers/hwmon/tmp102.c                             |  6 +++-
>   drivers/thermal/of-thermal.c                       | 40 ++++++++++------------
>   drivers/thermal/tegra_soctherm.c                   |  7 ++--
>   drivers/thermal/ti-soc-thermal/ti-thermal-common.c |  8 +++--
>   include/linux/thermal.h                            | 24 +++++++++----
>   7 files changed, 63 insertions(+), 37 deletions(-)
> ---
> Difference from V3:
>    - Keep the same behavior regarding callback checks.
>      Change in behavior may be sent in a separate patch.
> Difference from V2:
>    - Fix wrong assignment in tegra driver.
> Difference from V1:
>    - Fix error handling when .get_trend is not provided.
>
> @@ -356,8 +356,8 @@ thermal_zone_of_add_sensor(struct device_node *zone,
>    *             than one sensors
>    * @data: a private pointer (owned by the caller) that will be passed
>    *        back, when a temperature reading is needed.
> - * @get_temp: a pointer to a function that reads the sensor temperature.
> - * @get_trend: a pointer to a function that reads the sensor temperature trend.
> + * @ops: struct thermal_zone_of_device *. Must contain at least .get_trend and
> + *       .get_temp.

This comment seems to be incorrect, as .get_trend is optional.

>    *
>    * This function will search the list of thermal zones described in device
>    * tree and look for the zone that refer to the sensor device pointed by

With that minor one fixed,

Tested-by: Mikko Perttunen <mikko.perttunen@kapsi.fi>
Reviewed-by: Mikko Perttunen <mikko.perttunen@kapsi.fi>

Cheers,
Mikko

^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: [lm-sensors] [PATCHv4 1/1] thermal: of: improve of-thermal sensor registration API
@ 2014-11-19 15:41     ` Mikko Perttunen
  0 siblings, 0 replies; 20+ messages in thread
From: Mikko Perttunen @ 2014-11-19 15:41 UTC (permalink / raw)
  To: Eduardo Valentin, Linux PM
  Cc: Caesar Wang, Wei Ni, Lukasz Majewski, Alexandre Courbot,
	devicetree, Grant Likely, Guenter Roeck, Jean Delvare,
	linux-kernel, linux-tegra, lm-sensors, Rob Herring,
	Stephen Warren, Thierry Reding, Zhang Rui

On 11/18/2014 04:39 PM, Eduardo Valentin wrote:
> Different drivers request API extensions in of-thermal. For this reason,
> additional callbacks are required to fit the new drivers needs.
>
> The current API implementation expects the registering sensor driver
> to provide a get_temp and get_trend callbacks as function parameters.
> As the amount of callbacks is growing, this patch changes the existing
> implementation to use a .ops field to hold all the of thermal callbacks
> to sensor drivers.
>
> This patch also changes the existing of-thermal users to fit the new
> API design. No functional change is introduced in this patch.
>
> Cc: Alexandre Courbot <gnurou@gmail.com>
> Cc: devicetree@vger.kernel.org
> Cc: Grant Likely <grant.likely@linaro.org>
> Cc: Guenter Roeck <linux@roeck-us.net>
> Cc: Jean Delvare <jdelvare@suse.de>
> Cc: linux-kernel@vger.kernel.org
> Cc: linux-pm@vger.kernel.org
> Cc: linux-tegra@vger.kernel.org
> Cc: lm-sensors@lm-sensors.org
> Cc: Rob Herring <robh+dt@kernel.org>
> Cc: Stephen Warren <swarren@wwwdotorg.org>
> Cc: Thierry Reding <thierry.reding@gmail.com>
> Cc: Zhang Rui <rui.zhang@intel.com>
> Reviewed-by: Lukasz Majewski <l.majewski@samsung.com>
> Signed-off-by: Eduardo Valentin <edubezval@gmail.com>
> ---
>   drivers/hwmon/lm75.c                               |  9 +++--
>   drivers/hwmon/ntc_thermistor.c                     |  6 +++-
>   drivers/hwmon/tmp102.c                             |  6 +++-
>   drivers/thermal/of-thermal.c                       | 40 ++++++++++------------
>   drivers/thermal/tegra_soctherm.c                   |  7 ++--
>   drivers/thermal/ti-soc-thermal/ti-thermal-common.c |  8 +++--
>   include/linux/thermal.h                            | 24 +++++++++----
>   7 files changed, 63 insertions(+), 37 deletions(-)
> ---
> Difference from V3:
>    - Keep the same behavior regarding callback checks.
>      Change in behavior may be sent in a separate patch.
> Difference from V2:
>    - Fix wrong assignment in tegra driver.
> Difference from V1:
>    - Fix error handling when .get_trend is not provided.
>
> @@ -356,8 +356,8 @@ thermal_zone_of_add_sensor(struct device_node *zone,
>    *             than one sensors
>    * @data: a private pointer (owned by the caller) that will be passed
>    *        back, when a temperature reading is needed.
> - * @get_temp: a pointer to a function that reads the sensor temperature.
> - * @get_trend: a pointer to a function that reads the sensor temperature trend.
> + * @ops: struct thermal_zone_of_device *. Must contain at least .get_trend and
> + *       .get_temp.

This comment seems to be incorrect, as .get_trend is optional.

>    *
>    * This function will search the list of thermal zones described in device
>    * tree and look for the zone that refer to the sensor device pointed by

With that minor one fixed,

Tested-by: Mikko Perttunen <mikko.perttunen@kapsi.fi>
Reviewed-by: Mikko Perttunen <mikko.perttunen@kapsi.fi>

Cheers,
Mikko

_______________________________________________
lm-sensors mailing list
lm-sensors@lm-sensors.org
http://lists.lm-sensors.org/mailman/listinfo/lm-sensors

^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: [PATCHv4 1/1] thermal: of: improve of-thermal sensor registration API
  2014-11-19 15:41     ` [lm-sensors] " Mikko Perttunen
@ 2014-11-19 15:43       ` Mikko Perttunen
  -1 siblings, 0 replies; 20+ messages in thread
From: Mikko Perttunen @ 2014-11-19 15:43 UTC (permalink / raw)
  To: Eduardo Valentin, Linux PM
  Cc: Caesar Wang, Wei Ni, Lukasz Majewski, Alexandre Courbot,
	devicetree, Grant Likely, Guenter Roeck, Jean Delvare,
	linux-kernel, linux-tegra, lm-sensors, Rob Herring,
	Stephen Warren, Thierry Reding, Zhang Rui

On 11/19/2014 05:41 PM, Mikko Perttunen wrote:
> On 11/18/2014 04:39 PM, Eduardo Valentin wrote:
>> Different drivers request API extensions in of-thermal. For this reason,
>> additional callbacks are required to fit the new drivers needs.
>>
>> The current API implementation expects the registering sensor driver
>> to provide a get_temp and get_trend callbacks as function parameters.
>> As the amount of callbacks is growing, this patch changes the existing
>> implementation to use a .ops field to hold all the of thermal callbacks
>> to sensor drivers.
>>
>> This patch also changes the existing of-thermal users to fit the new
>> API design. No functional change is introduced in this patch.
>>
>> Cc: Alexandre Courbot <gnurou@gmail.com>
>> Cc: devicetree@vger.kernel.org
>> Cc: Grant Likely <grant.likely@linaro.org>
>> Cc: Guenter Roeck <linux@roeck-us.net>
>> Cc: Jean Delvare <jdelvare@suse.de>
>> Cc: linux-kernel@vger.kernel.org
>> Cc: linux-pm@vger.kernel.org
>> Cc: linux-tegra@vger.kernel.org
>> Cc: lm-sensors@lm-sensors.org
>> Cc: Rob Herring <robh+dt@kernel.org>
>> Cc: Stephen Warren <swarren@wwwdotorg.org>
>> Cc: Thierry Reding <thierry.reding@gmail.com>
>> Cc: Zhang Rui <rui.zhang@intel.com>
>> Reviewed-by: Lukasz Majewski <l.majewski@samsung.com>
>> Signed-off-by: Eduardo Valentin <edubezval@gmail.com>
>> ---
>>   drivers/hwmon/lm75.c                               |  9 +++--
>>   drivers/hwmon/ntc_thermistor.c                     |  6 +++-
>>   drivers/hwmon/tmp102.c                             |  6 +++-
>>   drivers/thermal/of-thermal.c                       | 40
>> ++++++++++------------
>>   drivers/thermal/tegra_soctherm.c                   |  7 ++--
>>   drivers/thermal/ti-soc-thermal/ti-thermal-common.c |  8 +++--
>>   include/linux/thermal.h                            | 24 +++++++++----
>>   7 files changed, 63 insertions(+), 37 deletions(-)
>> ---
>> Difference from V3:
>>    - Keep the same behavior regarding callback checks.
>>      Change in behavior may be sent in a separate patch.
>> Difference from V2:
>>    - Fix wrong assignment in tegra driver.
>> Difference from V1:
>>    - Fix error handling when .get_trend is not provided.
>>
>> @@ -356,8 +356,8 @@ thermal_zone_of_add_sensor(struct device_node *zone,
>>    *             than one sensors
>>    * @data: a private pointer (owned by the caller) that will be passed
>>    *        back, when a temperature reading is needed.
>> - * @get_temp: a pointer to a function that reads the sensor temperature.
>> - * @get_trend: a pointer to a function that reads the sensor
>> temperature trend.
>> + * @ops: struct thermal_zone_of_device *. Must contain at least
>> .get_trend and
>> + *       .get_temp.
>
> This comment seems to be incorrect, as .get_trend is optional.

Also, the parameter is of type struct thermal_zone_of_device_ops *, not 
just thermal_zone_of_device.

>
>>    *
>>    * This function will search the list of thermal zones described in
>> device
>>    * tree and look for the zone that refer to the sensor device
>> pointed by
>
> With that minor one fixed,
>
> Tested-by: Mikko Perttunen <mikko.perttunen@kapsi.fi>
> Reviewed-by: Mikko Perttunen <mikko.perttunen@kapsi.fi>
>
> Cheers,
> Mikko
> --
> To unsubscribe from this list: send the line "unsubscribe linux-tegra" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: [lm-sensors] [PATCHv4 1/1] thermal: of: improve of-thermal sensor registration API
@ 2014-11-19 15:43       ` Mikko Perttunen
  0 siblings, 0 replies; 20+ messages in thread
From: Mikko Perttunen @ 2014-11-19 15:43 UTC (permalink / raw)
  To: Eduardo Valentin, Linux PM
  Cc: Caesar Wang, Wei Ni, Lukasz Majewski, Alexandre Courbot,
	devicetree, Grant Likely, Guenter Roeck, Jean Delvare,
	linux-kernel, linux-tegra, lm-sensors, Rob Herring,
	Stephen Warren, Thierry Reding, Zhang Rui

On 11/19/2014 05:41 PM, Mikko Perttunen wrote:
> On 11/18/2014 04:39 PM, Eduardo Valentin wrote:
>> Different drivers request API extensions in of-thermal. For this reason,
>> additional callbacks are required to fit the new drivers needs.
>>
>> The current API implementation expects the registering sensor driver
>> to provide a get_temp and get_trend callbacks as function parameters.
>> As the amount of callbacks is growing, this patch changes the existing
>> implementation to use a .ops field to hold all the of thermal callbacks
>> to sensor drivers.
>>
>> This patch also changes the existing of-thermal users to fit the new
>> API design. No functional change is introduced in this patch.
>>
>> Cc: Alexandre Courbot <gnurou@gmail.com>
>> Cc: devicetree@vger.kernel.org
>> Cc: Grant Likely <grant.likely@linaro.org>
>> Cc: Guenter Roeck <linux@roeck-us.net>
>> Cc: Jean Delvare <jdelvare@suse.de>
>> Cc: linux-kernel@vger.kernel.org
>> Cc: linux-pm@vger.kernel.org
>> Cc: linux-tegra@vger.kernel.org
>> Cc: lm-sensors@lm-sensors.org
>> Cc: Rob Herring <robh+dt@kernel.org>
>> Cc: Stephen Warren <swarren@wwwdotorg.org>
>> Cc: Thierry Reding <thierry.reding@gmail.com>
>> Cc: Zhang Rui <rui.zhang@intel.com>
>> Reviewed-by: Lukasz Majewski <l.majewski@samsung.com>
>> Signed-off-by: Eduardo Valentin <edubezval@gmail.com>
>> ---
>>   drivers/hwmon/lm75.c                               |  9 +++--
>>   drivers/hwmon/ntc_thermistor.c                     |  6 +++-
>>   drivers/hwmon/tmp102.c                             |  6 +++-
>>   drivers/thermal/of-thermal.c                       | 40
>> ++++++++++------------
>>   drivers/thermal/tegra_soctherm.c                   |  7 ++--
>>   drivers/thermal/ti-soc-thermal/ti-thermal-common.c |  8 +++--
>>   include/linux/thermal.h                            | 24 +++++++++----
>>   7 files changed, 63 insertions(+), 37 deletions(-)
>> ---
>> Difference from V3:
>>    - Keep the same behavior regarding callback checks.
>>      Change in behavior may be sent in a separate patch.
>> Difference from V2:
>>    - Fix wrong assignment in tegra driver.
>> Difference from V1:
>>    - Fix error handling when .get_trend is not provided.
>>
>> @@ -356,8 +356,8 @@ thermal_zone_of_add_sensor(struct device_node *zone,
>>    *             than one sensors
>>    * @data: a private pointer (owned by the caller) that will be passed
>>    *        back, when a temperature reading is needed.
>> - * @get_temp: a pointer to a function that reads the sensor temperature.
>> - * @get_trend: a pointer to a function that reads the sensor
>> temperature trend.
>> + * @ops: struct thermal_zone_of_device *. Must contain at least
>> .get_trend and
>> + *       .get_temp.
>
> This comment seems to be incorrect, as .get_trend is optional.

Also, the parameter is of type struct thermal_zone_of_device_ops *, not 
just thermal_zone_of_device.

>
>>    *
>>    * This function will search the list of thermal zones described in
>> device
>>    * tree and look for the zone that refer to the sensor device
>> pointed by
>
> With that minor one fixed,
>
> Tested-by: Mikko Perttunen <mikko.perttunen@kapsi.fi>
> Reviewed-by: Mikko Perttunen <mikko.perttunen@kapsi.fi>
>
> Cheers,
> Mikko
> --
> To unsubscribe from this list: send the line "unsubscribe linux-tegra" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html


_______________________________________________
lm-sensors mailing list
lm-sensors@lm-sensors.org
http://lists.lm-sensors.org/mailman/listinfo/lm-sensors

^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: [PATCHv4 1/1] thermal: of: improve of-thermal sensor registration API
  2014-11-19 15:43       ` [lm-sensors] " Mikko Perttunen
@ 2014-11-20 13:49         ` Eduardo Valentin
  -1 siblings, 0 replies; 20+ messages in thread
From: Eduardo Valentin @ 2014-11-20 13:49 UTC (permalink / raw)
  To: Mikko Perttunen
  Cc: Linux PM, Caesar Wang, Wei Ni, Lukasz Majewski,
	Alexandre Courbot, devicetree, Grant Likely, Guenter Roeck,
	Jean Delvare, linux-kernel, linux-tegra, lm-sensors, Rob Herring,
	Stephen Warren, Thierry Reding, Zhang Rui

[-- Attachment #1: Type: text/plain, Size: 3851 bytes --]

Mikko,

On Wed, Nov 19, 2014 at 05:43:20PM +0200, Mikko Perttunen wrote:
> On 11/19/2014 05:41 PM, Mikko Perttunen wrote:
> > On 11/18/2014 04:39 PM, Eduardo Valentin wrote:
> >> Different drivers request API extensions in of-thermal. For this reason,
> >> additional callbacks are required to fit the new drivers needs.
> >>
> >> The current API implementation expects the registering sensor driver
> >> to provide a get_temp and get_trend callbacks as function parameters.
> >> As the amount of callbacks is growing, this patch changes the existing
> >> implementation to use a .ops field to hold all the of thermal callbacks
> >> to sensor drivers.
> >>
> >> This patch also changes the existing of-thermal users to fit the new
> >> API design. No functional change is introduced in this patch.
> >>
> >> Cc: Alexandre Courbot <gnurou@gmail.com>
> >> Cc: devicetree@vger.kernel.org
> >> Cc: Grant Likely <grant.likely@linaro.org>
> >> Cc: Guenter Roeck <linux@roeck-us.net>
> >> Cc: Jean Delvare <jdelvare@suse.de>
> >> Cc: linux-kernel@vger.kernel.org
> >> Cc: linux-pm@vger.kernel.org
> >> Cc: linux-tegra@vger.kernel.org
> >> Cc: lm-sensors@lm-sensors.org
> >> Cc: Rob Herring <robh+dt@kernel.org>
> >> Cc: Stephen Warren <swarren@wwwdotorg.org>
> >> Cc: Thierry Reding <thierry.reding@gmail.com>
> >> Cc: Zhang Rui <rui.zhang@intel.com>
> >> Reviewed-by: Lukasz Majewski <l.majewski@samsung.com>
> >> Signed-off-by: Eduardo Valentin <edubezval@gmail.com>
> >> ---
> >>   drivers/hwmon/lm75.c                               |  9 +++--
> >>   drivers/hwmon/ntc_thermistor.c                     |  6 +++-
> >>   drivers/hwmon/tmp102.c                             |  6 +++-
> >>   drivers/thermal/of-thermal.c                       | 40
> >> ++++++++++------------
> >>   drivers/thermal/tegra_soctherm.c                   |  7 ++--
> >>   drivers/thermal/ti-soc-thermal/ti-thermal-common.c |  8 +++--
> >>   include/linux/thermal.h                            | 24 +++++++++----
> >>   7 files changed, 63 insertions(+), 37 deletions(-)
> >> ---
> >> Difference from V3:
> >>    - Keep the same behavior regarding callback checks.
> >>      Change in behavior may be sent in a separate patch.
> >> Difference from V2:
> >>    - Fix wrong assignment in tegra driver.
> >> Difference from V1:
> >>    - Fix error handling when .get_trend is not provided.
> >>
> >> @@ -356,8 +356,8 @@ thermal_zone_of_add_sensor(struct device_node *zone,
> >>    *             than one sensors
> >>    * @data: a private pointer (owned by the caller) that will be passed
> >>    *        back, when a temperature reading is needed.
> >> - * @get_temp: a pointer to a function that reads the sensor temperature.
> >> - * @get_trend: a pointer to a function that reads the sensor
> >> temperature trend.
> >> + * @ops: struct thermal_zone_of_device *. Must contain at least
> >> .get_trend and
> >> + *       .get_temp.
> >
> > This comment seems to be incorrect, as .get_trend is optional.
> 
> Also, the parameter is of type struct thermal_zone_of_device_ops *, not 
> just thermal_zone_of_device.
> 
> >
> >>    *
> >>    * This function will search the list of thermal zones described in
> >> device
> >>    * tree and look for the zone that refer to the sensor device
> >> pointed by
> >
> > With that minor one fixed,
> >
> > Tested-by: Mikko Perttunen <mikko.perttunen@kapsi.fi>
> > Reviewed-by: Mikko Perttunen <mikko.perttunen@kapsi.fi>

All the comments fixed now. Thanks for reviewing and testing.

> >
> > Cheers,
> > Mikko
> > --
> > To unsubscribe from this list: send the line "unsubscribe linux-tegra" in
> > the body of a message to majordomo@vger.kernel.org
> > More majordomo info at  http://vger.kernel.org/majordomo-info.html
> 

Cheers,

Eduardo Valentin

[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 473 bytes --]

^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: [lm-sensors] [PATCHv4 1/1] thermal: of: improve of-thermal sensor registration API
@ 2014-11-20 13:49         ` Eduardo Valentin
  0 siblings, 0 replies; 20+ messages in thread
From: Eduardo Valentin @ 2014-11-20 13:49 UTC (permalink / raw)
  To: Mikko Perttunen
  Cc: Linux PM, Caesar Wang, Wei Ni, Lukasz Majewski,
	Alexandre Courbot, devicetree, Grant Likely, Guenter Roeck,
	Jean Delvare, linux-kernel, linux-tegra, lm-sensors, Rob Herring,
	Stephen Warren, Thierry Reding, Zhang Rui


[-- Attachment #1.1: Type: text/plain, Size: 3851 bytes --]

Mikko,

On Wed, Nov 19, 2014 at 05:43:20PM +0200, Mikko Perttunen wrote:
> On 11/19/2014 05:41 PM, Mikko Perttunen wrote:
> > On 11/18/2014 04:39 PM, Eduardo Valentin wrote:
> >> Different drivers request API extensions in of-thermal. For this reason,
> >> additional callbacks are required to fit the new drivers needs.
> >>
> >> The current API implementation expects the registering sensor driver
> >> to provide a get_temp and get_trend callbacks as function parameters.
> >> As the amount of callbacks is growing, this patch changes the existing
> >> implementation to use a .ops field to hold all the of thermal callbacks
> >> to sensor drivers.
> >>
> >> This patch also changes the existing of-thermal users to fit the new
> >> API design. No functional change is introduced in this patch.
> >>
> >> Cc: Alexandre Courbot <gnurou@gmail.com>
> >> Cc: devicetree@vger.kernel.org
> >> Cc: Grant Likely <grant.likely@linaro.org>
> >> Cc: Guenter Roeck <linux@roeck-us.net>
> >> Cc: Jean Delvare <jdelvare@suse.de>
> >> Cc: linux-kernel@vger.kernel.org
> >> Cc: linux-pm@vger.kernel.org
> >> Cc: linux-tegra@vger.kernel.org
> >> Cc: lm-sensors@lm-sensors.org
> >> Cc: Rob Herring <robh+dt@kernel.org>
> >> Cc: Stephen Warren <swarren@wwwdotorg.org>
> >> Cc: Thierry Reding <thierry.reding@gmail.com>
> >> Cc: Zhang Rui <rui.zhang@intel.com>
> >> Reviewed-by: Lukasz Majewski <l.majewski@samsung.com>
> >> Signed-off-by: Eduardo Valentin <edubezval@gmail.com>
> >> ---
> >>   drivers/hwmon/lm75.c                               |  9 +++--
> >>   drivers/hwmon/ntc_thermistor.c                     |  6 +++-
> >>   drivers/hwmon/tmp102.c                             |  6 +++-
> >>   drivers/thermal/of-thermal.c                       | 40
> >> ++++++++++------------
> >>   drivers/thermal/tegra_soctherm.c                   |  7 ++--
> >>   drivers/thermal/ti-soc-thermal/ti-thermal-common.c |  8 +++--
> >>   include/linux/thermal.h                            | 24 +++++++++----
> >>   7 files changed, 63 insertions(+), 37 deletions(-)
> >> ---
> >> Difference from V3:
> >>    - Keep the same behavior regarding callback checks.
> >>      Change in behavior may be sent in a separate patch.
> >> Difference from V2:
> >>    - Fix wrong assignment in tegra driver.
> >> Difference from V1:
> >>    - Fix error handling when .get_trend is not provided.
> >>
> >> @@ -356,8 +356,8 @@ thermal_zone_of_add_sensor(struct device_node *zone,
> >>    *             than one sensors
> >>    * @data: a private pointer (owned by the caller) that will be passed
> >>    *        back, when a temperature reading is needed.
> >> - * @get_temp: a pointer to a function that reads the sensor temperature.
> >> - * @get_trend: a pointer to a function that reads the sensor
> >> temperature trend.
> >> + * @ops: struct thermal_zone_of_device *. Must contain at least
> >> .get_trend and
> >> + *       .get_temp.
> >
> > This comment seems to be incorrect, as .get_trend is optional.
> 
> Also, the parameter is of type struct thermal_zone_of_device_ops *, not 
> just thermal_zone_of_device.
> 
> >
> >>    *
> >>    * This function will search the list of thermal zones described in
> >> device
> >>    * tree and look for the zone that refer to the sensor device
> >> pointed by
> >
> > With that minor one fixed,
> >
> > Tested-by: Mikko Perttunen <mikko.perttunen@kapsi.fi>
> > Reviewed-by: Mikko Perttunen <mikko.perttunen@kapsi.fi>

All the comments fixed now. Thanks for reviewing and testing.

> >
> > Cheers,
> > Mikko
> > --
> > To unsubscribe from this list: send the line "unsubscribe linux-tegra" in
> > the body of a message to majordomo@vger.kernel.org
> > More majordomo info at  http://vger.kernel.org/majordomo-info.html
> 

Cheers,

Eduardo Valentin

[-- Attachment #1.2: Digital signature --]
[-- Type: application/pgp-signature, Size: 473 bytes --]

[-- Attachment #2: Type: text/plain, Size: 153 bytes --]

_______________________________________________
lm-sensors mailing list
lm-sensors@lm-sensors.org
http://lists.lm-sensors.org/mailman/listinfo/lm-sensors

^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: [PATCHv4 1/1] thermal: of: improve of-thermal sensor registration API
  2014-11-19  8:06     ` [lm-sensors] " Alexandre Courbot
  (?)
@ 2014-11-20 13:52         ` Eduardo Valentin
  -1 siblings, 0 replies; 20+ messages in thread
From: Eduardo Valentin @ 2014-11-20 13:52 UTC (permalink / raw)
  To: Alexandre Courbot
  Cc: Linux PM, Caesar Wang, Wei Ni, Lukasz Majewski, Mikko Perttunen,
	devicetree-u79uwXL29TY76Z2rM5mHXA, Grant Likely, Guenter Roeck,
	Jean Delvare, Linux Kernel Mailing List,
	linux-tegra-u79uwXL29TY76Z2rM5mHXA,
	lm-sensors-GZX6beZjE8VD60Wz+7aTrA, Rob Herring, Stephen Warren,
	Thierry Reding, Zhang Rui

[-- Attachment #1: Type: text/plain, Size: 1005 bytes --]

Alexander,

On Wed, Nov 19, 2014 at 05:06:24PM +0900, Alexandre Courbot wrote:
> On Tue, Nov 18, 2014 at 11:39 PM, Eduardo Valentin <edubezval-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:
> > Different drivers request API extensions in of-thermal. For this reason,
> > additional callbacks are required to fit the new drivers needs.
> >
> > The current API implementation expects the registering sensor driver
> > to provide a get_temp and get_trend callbacks as function parameters.
> > As the amount of callbacks is growing, this patch changes the existing
> > implementation to use a .ops field to hold all the of thermal callbacks
> > to sensor drivers.
> >
> > This patch also changes the existing of-thermal users to fit the new
> > API design. No functional change is introduced in this patch.
> 
> A good idea even if no ops were to be added!
> 
> Reviewed-by: Alexandre Courbot <acourbot-DDmLM1+adcrQT0dZR+AlfA@public.gmane.org>

Thanks for reviewing.

Eduardo Valentin

[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 473 bytes --]

^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: [PATCHv4 1/1] thermal: of: improve of-thermal sensor registration API
@ 2014-11-20 13:52         ` Eduardo Valentin
  0 siblings, 0 replies; 20+ messages in thread
From: Eduardo Valentin @ 2014-11-20 13:52 UTC (permalink / raw)
  To: Alexandre Courbot
  Cc: Linux PM, Caesar Wang, Wei Ni, Lukasz Majewski, Mikko Perttunen,
	devicetree, Grant Likely, Guenter Roeck, Jean Delvare,
	Linux Kernel Mailing List, linux-tegra, lm-sensors, Rob Herring,
	Stephen Warren, Thierry Reding, Zhang Rui

[-- Attachment #1: Type: text/plain, Size: 946 bytes --]

Alexander,

On Wed, Nov 19, 2014 at 05:06:24PM +0900, Alexandre Courbot wrote:
> On Tue, Nov 18, 2014 at 11:39 PM, Eduardo Valentin <edubezval@gmail.com> wrote:
> > Different drivers request API extensions in of-thermal. For this reason,
> > additional callbacks are required to fit the new drivers needs.
> >
> > The current API implementation expects the registering sensor driver
> > to provide a get_temp and get_trend callbacks as function parameters.
> > As the amount of callbacks is growing, this patch changes the existing
> > implementation to use a .ops field to hold all the of thermal callbacks
> > to sensor drivers.
> >
> > This patch also changes the existing of-thermal users to fit the new
> > API design. No functional change is introduced in this patch.
> 
> A good idea even if no ops were to be added!
> 
> Reviewed-by: Alexandre Courbot <acourbot@nvidia.com>

Thanks for reviewing.

Eduardo Valentin

[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 473 bytes --]

^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: [lm-sensors] [PATCHv4 1/1] thermal: of: improve of-thermal sensor registration API
@ 2014-11-20 13:52         ` Eduardo Valentin
  0 siblings, 0 replies; 20+ messages in thread
From: Eduardo Valentin @ 2014-11-20 13:52 UTC (permalink / raw)
  To: Alexandre Courbot
  Cc: Linux PM, Caesar Wang, Wei Ni, Lukasz Majewski, Mikko Perttunen,
	devicetree-u79uwXL29TY76Z2rM5mHXA, Grant Likely, Guenter Roeck,
	Jean Delvare, Linux Kernel Mailing List,
	linux-tegra-u79uwXL29TY76Z2rM5mHXA,
	lm-sensors-GZX6beZjE8VD60Wz+7aTrA, Rob Herring, Stephen Warren,
	Thierry Reding, Zhang Rui


[-- Attachment #1.1: Type: text/plain, Size: 946 bytes --]

Alexander,

On Wed, Nov 19, 2014 at 05:06:24PM +0900, Alexandre Courbot wrote:
> On Tue, Nov 18, 2014 at 11:39 PM, Eduardo Valentin <edubezval@gmail.com> wrote:
> > Different drivers request API extensions in of-thermal. For this reason,
> > additional callbacks are required to fit the new drivers needs.
> >
> > The current API implementation expects the registering sensor driver
> > to provide a get_temp and get_trend callbacks as function parameters.
> > As the amount of callbacks is growing, this patch changes the existing
> > implementation to use a .ops field to hold all the of thermal callbacks
> > to sensor drivers.
> >
> > This patch also changes the existing of-thermal users to fit the new
> > API design. No functional change is introduced in this patch.
> 
> A good idea even if no ops were to be added!
> 
> Reviewed-by: Alexandre Courbot <acourbot@nvidia.com>

Thanks for reviewing.

Eduardo Valentin

[-- Attachment #1.2: Digital signature --]
[-- Type: application/pgp-signature, Size: 473 bytes --]

[-- Attachment #2: Type: text/plain, Size: 153 bytes --]

_______________________________________________
lm-sensors mailing list
lm-sensors@lm-sensors.org
http://lists.lm-sensors.org/mailman/listinfo/lm-sensors

^ permalink raw reply	[flat|nested] 20+ messages in thread

end of thread, other threads:[~2014-11-20 13:52 UTC | newest]

Thread overview: 20+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-11-18 14:39 [PATCHv4 0/1] of-thermal API change Eduardo Valentin
2014-11-18 14:39 ` [PATCHv4 1/1] thermal: of: improve of-thermal sensor registration API Eduardo Valentin
2014-11-18 14:39   ` [lm-sensors] " Eduardo Valentin
2014-11-19  8:06   ` Alexandre Courbot
2014-11-19  8:06     ` [lm-sensors] " Alexandre Courbot
     [not found]     ` <CAAVeFu+aUdpV_hj50TAZDO_5JgRmPH2RtJuP7Qozx4RNEzO-6A-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2014-11-20 13:52       ` Eduardo Valentin
2014-11-20 13:52         ` [lm-sensors] " Eduardo Valentin
2014-11-20 13:52         ` Eduardo Valentin
     [not found]   ` <1416321575-18348-2-git-send-email-edubezval-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2014-11-19  8:21     ` Lukasz Majewski
2014-11-19  8:21       ` [lm-sensors] " Lukasz Majewski
2014-11-19  8:21       ` Lukasz Majewski
2014-11-19 12:03       ` Eduardo Valentin
2014-11-19 12:03         ` [lm-sensors] " Eduardo Valentin
2014-11-19 12:03         ` Eduardo Valentin
2014-11-19 15:41   ` Mikko Perttunen
2014-11-19 15:41     ` [lm-sensors] " Mikko Perttunen
2014-11-19 15:43     ` Mikko Perttunen
2014-11-19 15:43       ` [lm-sensors] " Mikko Perttunen
2014-11-20 13:49       ` Eduardo Valentin
2014-11-20 13:49         ` [lm-sensors] " Eduardo Valentin

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.