All of lore.kernel.org
 help / color / mirror / Atom feed
From: Thara Gopinath <thara.gopinath@linaro.org>
To: edubezval@gmail.com, rui.zhang@intel.com, ulf.hansson@linaro.org,
	daniel.lezcano@linaro.org, bjorn.andersson@linaro.org,
	agross@kernel.org
Cc: amit.kucheria@verdurent.com, mark.rutland@arm.com,
	rjw@rjwysocki.net, linux-pm@vger.kernel.org,
	devicetree@vger.kernel.org, linux-arm-msm@vger.kernel.org,
	linux-kernel@vger.kernel.org
Subject: [PATCH v3 3/7] thermal: core: Add late init hook to cooling device ops
Date: Wed, 16 Oct 2019 15:37:17 -0400	[thread overview]
Message-ID: <1571254641-13626-4-git-send-email-thara.gopinath@linaro.org> (raw)
In-Reply-To: <1571254641-13626-1-git-send-email-thara.gopinath@linaro.org>

Add a hook in thermal_cooling_device_ops to be called after
the cooling device has been initialized and registered
but before binding it to a thermal zone.

In this patch series it is used to hook up a power domain
to the device pointer of cooling device.

It can be used for any other relevant late initializations
of a cooling device as well.

Signed-off-by: Thara Gopinath <thara.gopinath@linaro.org>
---
 drivers/thermal/thermal_core.c | 13 +++++++++++++
 include/linux/thermal.h        |  1 +
 2 files changed, 14 insertions(+)

diff --git a/drivers/thermal/thermal_core.c b/drivers/thermal/thermal_core.c
index 886e8fa..c2ecb73 100644
--- a/drivers/thermal/thermal_core.c
+++ b/drivers/thermal/thermal_core.c
@@ -994,6 +994,19 @@ __thermal_cooling_device_register(struct device_node *np,
 	list_add(&cdev->node, &thermal_cdev_list);
 	mutex_unlock(&thermal_list_lock);
 
+	/* Call into cdev late initialization if defined */
+	if (cdev->ops->late_init) {
+		result = cdev->ops->late_init(cdev);
+		if (result) {
+			ida_simple_remove(&thermal_cdev_ida, cdev->id);
+			put_device(&cdev->device);
+			mutex_lock(&thermal_list_lock);
+			list_del(&cdev->node);
+			mutex_unlock(&thermal_list_lock);
+			return ERR_PTR(result);
+		}
+	}
+
 	/* Update binding information for 'this' new cdev */
 	bind_cdev(cdev);
 
diff --git a/include/linux/thermal.h b/include/linux/thermal.h
index e45659c..e94b3de 100644
--- a/include/linux/thermal.h
+++ b/include/linux/thermal.h
@@ -125,6 +125,7 @@ struct thermal_cooling_device_ops {
 			   struct thermal_zone_device *, unsigned long, u32 *);
 	int (*power2state)(struct thermal_cooling_device *,
 			   struct thermal_zone_device *, u32, unsigned long *);
+	int (*late_init)(struct thermal_cooling_device *);
 };
 
 struct thermal_cooling_device {
-- 
2.1.4


  parent reply	other threads:[~2019-10-16 19:37 UTC|newest]

Thread overview: 26+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-10-16 19:37 [PATCH v3 0/7]Introduce Power domain based warming device driver Thara Gopinath
2019-10-16 19:37 ` [PATCH v3 1/7] PM/Domains: Add support for retrieving genpd performance states information Thara Gopinath
2019-10-17  8:49   ` Ulf Hansson
2019-10-17 16:11     ` Thara Gopinath
2019-10-16 19:37 ` [PATCH v3 2/7] soc: qcom: rpmhpd: Introduce function to retrieve power domain performance state count Thara Gopinath
2019-10-16 19:37 ` Thara Gopinath [this message]
2019-12-03 17:04   ` [PATCH v3 3/7] thermal: core: Add late init hook to cooling device ops Amit Kucheria
2019-12-03 17:09     ` Thara Gopinath
2019-12-03 17:11     ` Amit Kucheria
2019-10-16 19:37 ` [PATCH v3 4/7] thermal: Add generic power domain warming device driver Thara Gopinath
2019-10-17  8:47   ` Ulf Hansson
2019-10-17 15:46     ` Thara Gopinath
2019-10-16 19:37 ` [PATCH v3 5/7] soc: qcom: Extend RPMh power controller driver to register warming devices Thara Gopinath
2019-10-16 19:37 ` [PATCH v3 6/7] dt-bindings: soc: qcom: Extend RPMh power controller binding to describe thermal warming device Thara Gopinath
2019-10-17  9:04   ` Ulf Hansson
2019-10-17 15:28     ` Thara Gopinath
2019-10-17 15:43       ` Ulf Hansson
2019-10-17 16:10         ` Thara Gopinath
2019-10-29  1:36           ` Rob Herring
2019-10-29 10:06             ` Ulf Hansson
2019-10-29 20:16               ` Rob Herring
2019-10-30  9:27                 ` Ulf Hansson
2019-10-30 14:27                 ` Thara Gopinath
2019-10-16 19:37 ` [PATCH v3 7/7] arm64: dts: qcom: Add mx power domain as " Thara Gopinath
2019-10-29  1:31   ` Rob Herring
2019-10-30 14:23     ` Thara Gopinath

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=1571254641-13626-4-git-send-email-thara.gopinath@linaro.org \
    --to=thara.gopinath@linaro.org \
    --cc=agross@kernel.org \
    --cc=amit.kucheria@verdurent.com \
    --cc=bjorn.andersson@linaro.org \
    --cc=daniel.lezcano@linaro.org \
    --cc=devicetree@vger.kernel.org \
    --cc=edubezval@gmail.com \
    --cc=linux-arm-msm@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pm@vger.kernel.org \
    --cc=mark.rutland@arm.com \
    --cc=rjw@rjwysocki.net \
    --cc=rui.zhang@intel.com \
    --cc=ulf.hansson@linaro.org \
    /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 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.