From: Thierry Reding <thierry.reding@gmail.com>
To: "Rafael J . Wysocki" <rafael@kernel.org>,
Daniel Lezcano <daniel.lezcano@linaro.org>
Cc: Amit Kucheria <amitk@kernel.org>, Zhang Rui <rui.zhang@intel.com>,
Jon Hunter <jonathanh@nvidia.com>,
linux-pm@vger.kernel.org, linux-tegra@vger.kernel.org,
linux-kernel@vger.kernel.org
Subject: [PATCH 1/2] thermal: Add support for cooling device bind/unbind operations
Date: Thu, 9 Feb 2023 17:35:54 +0100 [thread overview]
Message-ID: <20230209163555.1993557-1-thierry.reding@gmail.com> (raw)
From: Thierry Reding <treding@nvidia.com>
Drivers for cooling devices can implement these operations when they
need to perform extra work at the time when a cooling device is bound to
a given thermal zone.
Signed-off-by: Thierry Reding <treding@nvidia.com>
---
drivers/thermal/thermal_core.c | 11 +++++++++++
include/linux/thermal.h | 6 ++++++
2 files changed, 17 insertions(+)
diff --git a/drivers/thermal/thermal_core.c b/drivers/thermal/thermal_core.c
index 0675df54c8e6..627fccd100ef 100644
--- a/drivers/thermal/thermal_core.c
+++ b/drivers/thermal/thermal_core.c
@@ -694,6 +694,14 @@ int thermal_zone_bind_cooling_device(struct thermal_zone_device *tz,
mutex_unlock(&cdev->lock);
mutex_unlock(&tz->lock);
+ if (cdev->ops->bind) {
+ result = cdev->ops->bind(cdev, tz, trip, upper, lower, weight);
+ if (result < 0) {
+ pr_err("failed to bind %s to %s: %d\n", cdev->type,
+ tz->type, result);
+ }
+ }
+
if (!result)
return 0;
@@ -730,6 +738,9 @@ int thermal_zone_unbind_cooling_device(struct thermal_zone_device *tz,
{
struct thermal_instance *pos, *next;
+ if (cdev->ops->unbind)
+ cdev->ops->unbind(cdev, tz, trip);
+
mutex_lock(&tz->lock);
mutex_lock(&cdev->lock);
list_for_each_entry_safe(pos, next, &tz->thermal_instances, tz_node) {
diff --git a/include/linux/thermal.h b/include/linux/thermal.h
index 2bb4bf33f4f3..95ed8a0cbba8 100644
--- a/include/linux/thermal.h
+++ b/include/linux/thermal.h
@@ -89,6 +89,12 @@ struct thermal_trip {
};
struct thermal_cooling_device_ops {
+ int (*bind)(struct thermal_cooling_device *cdev,
+ struct thermal_zone_device *tz, int trip_id,
+ unsigned long upper, unsigned long lower,
+ unsigned int weight);
+ void (*unbind)(struct thermal_cooling_device *cdev,
+ struct thermal_zone_device *tz, int trip_id);
int (*get_max_state) (struct thermal_cooling_device *, unsigned long *);
int (*get_cur_state) (struct thermal_cooling_device *, unsigned long *);
int (*set_cur_state) (struct thermal_cooling_device *, unsigned long);
--
2.39.1
next reply other threads:[~2023-02-09 16:36 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-02-09 16:35 Thierry Reding [this message]
2023-02-09 16:35 ` [PATCH 2/2] thermal: tegra: Implement bind/unbind for cooling device Thierry Reding
2023-02-10 12:31 ` [PATCH 1/2] thermal: Add support for cooling device bind/unbind operations Daniel Lezcano
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=20230209163555.1993557-1-thierry.reding@gmail.com \
--to=thierry.reding@gmail.com \
--cc=amitk@kernel.org \
--cc=daniel.lezcano@linaro.org \
--cc=jonathanh@nvidia.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-pm@vger.kernel.org \
--cc=linux-tegra@vger.kernel.org \
--cc=rafael@kernel.org \
--cc=rui.zhang@intel.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