linux-renesas-soc.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Marek Vasut <marek.vasut@gmail.com>
To: linux-pm@vger.kernel.org
Cc: linux-renesas-soc@vger.kernel.org,
	Marek Vasut <marek.vasut+renesas@gmail.com>,
	Daniel Lezcano <daniel.lezcano@linaro.org>,
	Eduardo Valentin <edubezval@gmail.com>,
	Wolfram Sang <wsa+renesas@sang-engineering.com>,
	Zhang Rui <rui.zhang@intel.com>
Subject: [PATCH 1/6] thermal: split thermal_zone_of_sensor_register{,_param}()
Date: Wed, 12 Dec 2018 02:49:22 +0100	[thread overview]
Message-ID: <20181212014927.25840-2-marek.vasut+renesas@gmail.com> (raw)
In-Reply-To: <20181212014927.25840-1-marek.vasut+renesas@gmail.com>

Introduce new thermal_zone_of_sensor_register_params() function, which
allows passing struct thermal_zone_params into it and convert original
thermal_zone_of_sensor_register() to call it with params set to NULL.

Signed-off-by: Marek Vasut <marek.vasut+renesas@gmail.com>
Cc: Daniel Lezcano <daniel.lezcano@linaro.org>
Cc: Eduardo Valentin <edubezval@gmail.com>
Cc: Wolfram Sang <wsa+renesas@sang-engineering.com>
Cc: Zhang Rui <rui.zhang@intel.com>
Cc: linux-renesas-soc@vger.kernel.org
To: linux-pm@vger.kernel.org
---
 drivers/thermal/of-thermal.c | 50 +++++++++++++++++++++++++++++++++---
 include/linux/thermal.h      | 12 +++++++++
 2 files changed, 59 insertions(+), 3 deletions(-)

diff --git a/drivers/thermal/of-thermal.c b/drivers/thermal/of-thermal.c
index 4bfdb4a1e47d..eb0ef7a21035 100644
--- a/drivers/thermal/of-thermal.c
+++ b/drivers/thermal/of-thermal.c
@@ -446,7 +446,8 @@ thermal_zone_of_add_sensor(struct device_node *zone,
 }
 
 /**
- * thermal_zone_of_sensor_register - registers a sensor to a DT thermal zone
+ * thermal_zone_of_sensor_register_params - registers a sensor to a DT thermal
+ *					zone with thermal zone parameters
  * @dev: a valid struct device pointer of a sensor device. Must contain
  *       a valid .of_node, for the sensor node.
  * @sensor_id: a sensor identifier, in case the sensor IP has more
@@ -454,6 +455,7 @@ thermal_zone_of_add_sensor(struct device_node *zone,
  * @data: a private pointer (owned by the caller) that will be passed
  *        back, when a temperature reading is needed.
  * @ops: struct thermal_zone_of_device_ops *. Must contain at least .get_temp.
+ * @tzp: thermal zone platform parameters
  *
  * 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
@@ -478,8 +480,9 @@ 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,
-				const struct thermal_zone_of_device_ops *ops)
+thermal_zone_of_sensor_register_params(struct device *dev, int sensor_id,
+	void *data, const struct thermal_zone_of_device_ops *ops,
+	struct thermal_zone_params *tzp)
 {
 	struct device_node *np, *child, *sensor_np;
 	struct thermal_zone_device *tzd = ERR_PTR(-ENODEV);
@@ -533,6 +536,47 @@ thermal_zone_of_sensor_register(struct device *dev, int sensor_id, void *data,
 
 	return tzd;
 }
+
+/**
+ * thermal_zone_of_sensor_register - registers a sensor to a DT thermal zone
+ * @dev: a valid struct device pointer of a sensor device. Must contain
+ *       a valid .of_node, for the sensor node.
+ * @sensor_id: a sensor identifier, in case the sensor IP has more
+ *             than one sensors
+ * @data: a private pointer (owned by the caller) that will be passed
+ *        back, when a temperature reading is needed.
+ * @ops: struct thermal_zone_of_device_ops *. Must contain at least .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
+ * @dev->of_node as temperature providers. For the zone pointing to the
+ * sensor node, the sensor will be added to the DT thermal zone device.
+ *
+ * The thermal zone temperature is provided by the @get_temp function
+ * pointer. When called, it will have the private pointer @data back.
+ *
+ * The thermal zone temperature trend is provided by the @get_trend function
+ * pointer. When called, it will have the private pointer @data back.
+ *
+ * TODO:
+ * 01 - This function must enqueue the new sensor instead of using
+ * it as the only source of temperature values.
+ *
+ * 02 - There must be a way to match the sensor with all thermal zones
+ * that refer to it.
+ *
+ * Return: On success returns a valid struct thermal_zone_device,
+ * otherwise, it returns a corresponding ERR_PTR(). Caller must
+ * 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,
+				const struct thermal_zone_of_device_ops *ops)
+{
+	return thermal_zone_of_sensor_register_params(dev, sensor_id, data,
+						      ops, NULL);
+}
 EXPORT_SYMBOL_GPL(thermal_zone_of_sensor_register);
 
 /**
diff --git a/include/linux/thermal.h b/include/linux/thermal.h
index 5f4705f46c2f..922034eae74b 100644
--- a/include/linux/thermal.h
+++ b/include/linux/thermal.h
@@ -378,6 +378,10 @@ struct thermal_trip {
 struct thermal_zone_device *
 thermal_zone_of_sensor_register(struct device *dev, int id, void *data,
 				const struct thermal_zone_of_device_ops *ops);
+struct thermal_zone_device *
+thermal_zone_of_sensor_register_params(struct device *dev, int id, void *data,
+			const struct thermal_zone_of_device_ops *ops,
+			struct thermal_zone_params *tzp);
 void thermal_zone_of_sensor_unregister(struct device *dev,
 				       struct thermal_zone_device *tz);
 struct thermal_zone_device *devm_thermal_zone_of_sensor_register(
@@ -393,6 +397,14 @@ thermal_zone_of_sensor_register(struct device *dev, int id, void *data,
 	return ERR_PTR(-ENODEV);
 }
 
+static inline struct thermal_zone_device *
+thermal_zone_of_sensor_register_params(struct device *dev, int id, void *data,
+			const struct thermal_zone_of_device_ops *ops,
+			struct thermal_zone_params *tzp)
+{
+	return ERR_PTR(-ENODEV);
+}
+
 static inline
 void thermal_zone_of_sensor_unregister(struct device *dev,
 				       struct thermal_zone_device *tz)
-- 
2.18.0


  reply	other threads:[~2018-12-12  1:49 UTC|newest]

Thread overview: 31+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-12-12  1:49 [PATCH 0/6] thermal: Align devm_thermal_zone_{device,of_sensor}_register Marek Vasut
2018-12-12  1:49 ` Marek Vasut [this message]
2018-12-15 17:23   ` [PATCH 1/6] thermal: split thermal_zone_of_sensor_register{,_param}() Eduardo Valentin
2018-12-15 18:38     ` Marek Vasut
2018-12-15 18:47       ` Geert Uytterhoeven
2018-12-15 18:49         ` Marek Vasut
2018-12-15 18:54           ` Geert Uytterhoeven
2018-12-15 19:07             ` Marek Vasut
2018-12-15 20:00               ` Geert Uytterhoeven
2018-12-15 20:13                 ` Marek Vasut
2018-12-16  8:39                   ` Geert Uytterhoeven
2018-12-16 17:25                     ` Marek Vasut
2018-12-16 17:42                       ` Geert Uytterhoeven
2018-12-16 17:48                         ` Marek Vasut
2018-12-16 20:08                           ` Geert Uytterhoeven
2018-12-16 20:43                             ` Marek Vasut
2018-12-17 13:26                               ` Geert Uytterhoeven
2018-12-17 13:28                                 ` Marek Vasut
2018-12-17 13:36                                   ` Geert Uytterhoeven
2018-12-17 13:41                                     ` Marek Vasut
2018-12-17 14:15                                       ` Geert Uytterhoeven
2018-12-17 15:52                                         ` Marek Vasut
2018-12-12  1:49 ` [PATCH 2/6] thermal: split devm_thermal_zone_of_sensor_register{,_param}() Marek Vasut
2018-12-12  1:49 ` [PATCH 3/6] thermal: Register hwmon in thermal_zone_of_sensor_register_param() Marek Vasut
2018-12-12  1:49 ` [PATCH 4/6] thermal: stm32: Convert to devm_thermal_zone_of_sensor_register_params() Marek Vasut
2018-12-12  1:49 ` [PATCH 5/6] thermal: rcar_thermal: " Marek Vasut
2018-12-12  1:49 ` [PATCH 6/6] thermal: rcar_gen3_thermal: Register hwmon sysfs interface Marek Vasut
2018-12-14  5:28   ` kbuild test robot
2018-12-15  2:02 ` [PATCH 0/6] thermal: Align devm_thermal_zone_{device,of_sensor}_register Eduardo Valentin
2018-12-15  2:08   ` Marek Vasut
2018-12-15 17:23     ` Eduardo Valentin

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20181212014927.25840-2-marek.vasut+renesas@gmail.com \
    --to=marek.vasut@gmail.com \
    --cc=daniel.lezcano@linaro.org \
    --cc=edubezval@gmail.com \
    --cc=linux-pm@vger.kernel.org \
    --cc=linux-renesas-soc@vger.kernel.org \
    --cc=marek.vasut+renesas@gmail.com \
    --cc=rui.zhang@intel.com \
    --cc=wsa+renesas@sang-engineering.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).