From: Jean Delvare <khali@linux-fr.org>
To: Len Brown <len.brown@intel.com>
Cc: LKML <linux-kernel@vger.kernel.org>,
Rene Herman <rene.herman@gmail.com>,
Guenter Roeck <guenter.roeck@ericsson.com>
Subject: [PATCH v2 2/3] thermal: Split hwmon lookup to a separate function
Date: Tue, 26 Apr 2011 17:02:53 +0200 [thread overview]
Message-ID: <20110426170253.58f05975@endymion.delvare> (raw)
In-Reply-To: <20110426165600.1d9ac91b@endymion.delvare>
We'll soon need to reuse it.
Signed-off-by: Jean Delvare <khali@linux-fr.org>
Cc: Rene Herman <rene.herman@gmail.com>
Cc: Len Brown <len.brown@intel.com>
Cc: Guenter Roeck <guenter.roeck@ericsson.com>
---
drivers/thermal/thermal_sys.c | 25 +++++++++++++++++++------
1 file changed, 19 insertions(+), 6 deletions(-)
--- linux-2.6.39-rc4.orig/drivers/thermal/thermal_sys.c 2011-04-25 14:40:17.000000000 +0200
+++ linux-2.6.39-rc4/drivers/thermal/thermal_sys.c 2011-04-25 14:44:52.000000000 +0200
@@ -469,22 +469,35 @@ temp_crit_show(struct device *dev, struc
}
-static int
-thermal_add_hwmon_sysfs(struct thermal_zone_device *tz)
+static struct thermal_hwmon_device *
+thermal_hwmon_lookup_by_type(const struct thermal_zone_device *tz)
{
struct thermal_hwmon_device *hwmon;
- int new_hwmon_device = 1;
- int result;
mutex_lock(&thermal_list_lock);
list_for_each_entry(hwmon, &thermal_hwmon_list, node)
if (!strcmp(hwmon->type, tz->type)) {
- new_hwmon_device = 0;
mutex_unlock(&thermal_list_lock);
- goto register_sys_interface;
+ return hwmon;
}
mutex_unlock(&thermal_list_lock);
+ return NULL;
+}
+
+static int
+thermal_add_hwmon_sysfs(struct thermal_zone_device *tz)
+{
+ struct thermal_hwmon_device *hwmon;
+ int new_hwmon_device = 1;
+ int result;
+
+ hwmon = thermal_hwmon_lookup_by_type(tz);
+ if (hwmon) {
+ new_hwmon_device = 0;
+ goto register_sys_interface;
+ }
+
hwmon = kzalloc(sizeof(struct thermal_hwmon_device), GFP_KERNEL);
if (!hwmon)
return -ENOMEM;
--
Jean Delvare
next prev parent reply other threads:[~2011-04-26 15:03 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-04-26 14:56 [PATCH v2 0/3] thermal: Cleanups Jean Delvare
2011-04-26 15:02 ` [PATCH v2 1/3] thermal: Hide CONFIG_THERMAL_HWMON Jean Delvare
2011-04-26 15:52 ` Guenter Roeck
2011-04-26 15:02 ` Jean Delvare [this message]
2011-04-26 15:53 ` [PATCH v2 2/3] thermal: Split hwmon lookup to a separate function Guenter Roeck
2011-04-26 15:04 ` [PATCH v2 3/3] thermal: Make THERMAL_HWMON implementation fully internal Jean Delvare
2011-04-26 15:52 ` Guenter Roeck
2011-04-26 16:29 ` Jean Delvare
2011-04-26 17:43 ` Guenter Roeck
2011-04-26 19:39 ` Jean Delvare
2011-04-26 21:00 ` Guenter Roeck
2011-04-27 11:59 ` Jean Delvare
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=20110426170253.58f05975@endymion.delvare \
--to=khali@linux-fr.org \
--cc=guenter.roeck@ericsson.com \
--cc=len.brown@intel.com \
--cc=linux-kernel@vger.kernel.org \
--cc=rene.herman@gmail.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
all inboxes | Powered by JetHome®