From: Matthew Garrett <mjg@redhat.com>
To: Amit Daniel Kachhap <amit.kachhap@linaro.org>
Cc: linux-pm@lists.linux-foundation.org,
linux-kernel@vger.kernel.org, linux-acpi@vger.kernel.org,
lenb@kernel.org, rui.zhang@intel.com,
linaro-dev@lists.linaro.org, patches@linaro.org
Subject: Re: [RFC PATCH 1/2] thermal: Add a new trip type to use cooling device instance number
Date: Wed, 1 Feb 2012 14:49:31 +0000 [thread overview]
Message-ID: <20120201144931.GC30184@srcf.ucam.org> (raw)
In-Reply-To: <1323789196-4942-2-git-send-email-amit.kachhap@linaro.org>
I'm not really a fan of this as it stands - the name isn't very
intuitive and the code's pretty difficult to read. Would the following
(incomplete and obviously untested) not have the effect you want? Then
you register multiple trip points with the same cooling device but
different private values, and the state set does whatever you want it
to. Or am I misunderstanding the problem you're trying to solve?
diff --git a/drivers/thermal/thermal_sys.c b/drivers/thermal/thermal_sys.c
index 220ce7e..817f2ba 100644
--- a/drivers/thermal/thermal_sys.c
+++ b/drivers/thermal/thermal_sys.c
@@ -50,6 +50,7 @@ struct thermal_cooling_device_instance {
char attr_name[THERMAL_NAME_LENGTH];
struct device_attribute attr;
struct list_head node;
+ unsigned long private;
};
static DEFINE_IDR(thermal_tz_idr);
@@ -909,7 +910,8 @@ static struct class thermal_class = {
* @ops: standard thermal cooling devices callbacks.
*/
struct thermal_cooling_device *thermal_cooling_device_register(
- char *type, void *devdata, const struct thermal_cooling_device_ops *ops)
+ char *type, void *devdata, const struct thermal_cooling_device_ops *ops,
+ unsigned long private)
{
struct thermal_cooling_device *cdev;
struct thermal_zone_device *pos;
@@ -936,6 +938,7 @@ struct thermal_cooling_device *thermal_cooling_device_register(
cdev->ops = ops;
cdev->device.class = &thermal_class;
cdev->devdata = devdata;
+ cdev->private = private;
dev_set_name(&cdev->device, "cooling_device%d", cdev->id);
result = device_register(&cdev->device);
if (result) {
@@ -1079,11 +1082,14 @@ void thermal_zone_device_update(struct thermal_zone_device *tz)
continue;
cdev = instance->cdev;
-
- if (temp >= trip_temp)
- cdev->ops->set_cur_state(cdev, 1);
- else
- cdev->ops->set_cur_state(cdev, 0);
+ if (cdev->private) {
+ cdev->ops->set_cur_state(cdev, cdev->private);
+ } else {
+ if (temp >= trip_temp)
+ cdev->ops->set_cur_state(cdev, 1);
+ else
+ cdev->ops->set_cur_state(cdev, 0);
+ }
}
break;
case THERMAL_TRIP_PASSIVE:
diff --git a/include/linux/thermal.h b/include/linux/thermal.h
index 796f1ff..04aac09 100644
--- a/include/linux/thermal.h
+++ b/include/linux/thermal.h
@@ -148,7 +148,7 @@ int thermal_zone_unbind_cooling_device(struct thermal_zone_device *, int,
struct thermal_cooling_device *);
void thermal_zone_device_update(struct thermal_zone_device *);
struct thermal_cooling_device *thermal_cooling_device_register(char *, void *,
- const struct thermal_cooling_device_ops *);
+ const struct thermal_cooling_device_ops *, unsigned long private);
void thermal_cooling_device_unregister(struct thermal_cooling_device *);
#ifdef CONFIG_NET
--
Matthew Garrett | mjg59@srcf.ucam.org
next prev parent reply other threads:[~2012-02-01 14:49 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-12-13 15:13 [RFC PATCH 0/2] thermal: Add generic cpu cooling devices according to thermal framework Amit Daniel Kachhap
2011-12-13 15:13 ` [RFC PATCH 1/2] thermal: Add a new trip type to use cooling device instance number Amit Daniel Kachhap
2011-12-20 12:37 ` [linux-pm] " Vincent Guittot
[not found] ` <CAK44p232PbvGRXKB7_3TYn0Q3iqgRJg6Qv81W_EwXCHL+79baA@mail.gmail.com>
2011-12-21 5:11 ` Amit Kachhap
2012-01-11 8:12 ` Rob Lee
2012-01-13 4:02 ` Amit Kachhap
2012-02-01 14:49 ` Matthew Garrett [this message]
2012-02-02 7:16 ` Amit Kachhap
2011-12-13 15:13 ` [RFC PATCH 2/2] thermal: Add generic cpu cooling implementation Amit Daniel Kachhap
2012-01-11 8:02 ` Rob Lee
2012-01-13 3:50 ` Amit Kachhap
2012-01-16 14:13 ` Rob Lee
2012-02-01 14:57 ` Matthew Garrett
2012-02-02 9:16 ` Amit Kachhap
2012-02-07 8:25 ` [linux-pm] " Eduardo Valentin
2012-02-07 18:21 ` Amit Kachhap
2012-02-07 19:34 ` Eduardo Valentin
2012-01-19 9:17 ` [RFC PATCH 0/2] thermal: Add generic cpu cooling devices according to thermal framework Amit Kachhap
2012-02-03 7:12 ` Zhang Rui
2012-02-03 12:13 ` Amit Kachhap
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=20120201144931.GC30184@srcf.ucam.org \
--to=mjg@redhat.com \
--cc=amit.kachhap@linaro.org \
--cc=lenb@kernel.org \
--cc=linaro-dev@lists.linaro.org \
--cc=linux-acpi@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-pm@lists.linux-foundation.org \
--cc=patches@linaro.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;
as well as URLs for NNTP newsgroup(s).