Chuck Ebbert 7533b16
From: Carsten Emde <C.Emde@osadl.org>
Chuck Ebbert 7533b16
Date: Mon, 24 May 2010 21:33:39 +0000 (-0700)
Chuck Ebbert 7533b16
Subject: drivers/hwmon/coretemp.c: detect the thermal sensors by CPUID
Chuck Ebbert 7533b16
X-Git-Tag: v2.6.35-rc1~297
Chuck Ebbert 7533b16
X-Git-Url: http://git.kernel.org/?p=linux%2Fkernel%2Fgit%2Ftorvalds%2Flinux-2.6.git;a=commitdiff_plain;h=5db47b009d17d69a2f8d84357e7b24c3e3c2edec
Chuck Ebbert 7533b16
Chuck Ebbert 7533b16
drivers/hwmon/coretemp.c: detect the thermal sensors by CPUID
Chuck Ebbert 7533b16
Chuck Ebbert 7533b16
The thermal sensors of Intel(R) CPUs can be detected by CPUID instruction,
Chuck Ebbert 7533b16
indicated by CPUID.06H.EAX[0].
Chuck Ebbert 7533b16
Chuck Ebbert 7533b16
Signed-off-by: Huaxu Wan <huaxu.wan@linux.intel.com>
Chuck Ebbert 7533b16
Signed-off-by: Carsten Emde <C.Emde@osadl.org>
Chuck Ebbert 7533b16
Reviewed-by: Valdis Kletnieks <valdis.kletnieks@vt.edu>
Chuck Ebbert 7533b16
Cc: Jean Delvare <khali@linux-fr.org>
Chuck Ebbert 7533b16
Cc: Henrique de Moraes Holschuh <hmh@hmh.eng.br>
Chuck Ebbert 7533b16
Cc: Yong Wang <yong.y.wang@linux.intel.com>
Chuck Ebbert 7533b16
Cc: Rudolf Marek <r.marek@assembler.cz>
Chuck Ebbert 7533b16
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Chuck Ebbert 7533b16
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Chuck Ebbert 7533b16
---
Chuck Ebbert 7533b16
Chuck Ebbert 7533b16
diff --git a/drivers/hwmon/coretemp.c b/drivers/hwmon/coretemp.c
Chuck Ebbert 7533b16
index e9b7fbc..9fae7cb 100644
Chuck Ebbert 7533b16
--- a/drivers/hwmon/coretemp.c
Chuck Ebbert 7533b16
+++ b/drivers/hwmon/coretemp.c
Chuck Ebbert 7533b16
@@ -451,28 +451,20 @@ static int __init coretemp_init(void)
Chuck Ebbert 7533b16
 
Chuck Ebbert 7533b16
 	for_each_online_cpu(i) {
Chuck Ebbert 7533b16
 		struct cpuinfo_x86 *c = &cpu_data(i);
Chuck Ebbert 7533b16
+		/*
Chuck Ebbert 7533b16
+		 * CPUID.06H.EAX[0] indicates whether the CPU has thermal
Chuck Ebbert 7533b16
+		 * sensors. We check this bit only, all the early CPUs
Chuck Ebbert 7533b16
+		 * without thermal sensors will be filtered out.
Chuck Ebbert 7533b16
+		 */
Chuck Ebbert 7533b16
+		if (c->cpuid_level >= 6 && (cpuid_eax(0x06) & 0x01)) {
Chuck Ebbert 7533b16
+			err = coretemp_device_add(i);
Chuck Ebbert 7533b16
+			if (err)
Chuck Ebbert 7533b16
+				goto exit_devices_unreg;
Chuck Ebbert 7533b16
 
Chuck Ebbert 7533b16
-		/* check if family 6, models 0xe (Pentium M DC),
Chuck Ebbert 7533b16
-		  0xf (Core 2 DC 65nm), 0x16 (Core 2 SC 65nm),
Chuck Ebbert 7533b16
-		  0x17 (Penryn 45nm), 0x1a (Nehalem), 0x1c (Atom),
Chuck Ebbert 7533b16
-		  0x1e (Lynnfield) */
Chuck Ebbert 7533b16
-		if ((c->cpuid_level < 0) || (c->x86 != 0x6) ||
Chuck Ebbert 7533b16
-		    !((c->x86_model == 0xe) || (c->x86_model == 0xf) ||
Chuck Ebbert 7533b16
-			(c->x86_model == 0x16) || (c->x86_model == 0x17) ||
Chuck Ebbert 7533b16
-			(c->x86_model == 0x1a) || (c->x86_model == 0x1c) ||
Chuck Ebbert 7533b16
-			(c->x86_model == 0x1e))) {
Chuck Ebbert 7533b16
-
Chuck Ebbert 7533b16
-			/* supported CPU not found, but report the unknown
Chuck Ebbert 7533b16
-			   family 6 CPU */
Chuck Ebbert 7533b16
-			if ((c->x86 == 0x6) && (c->x86_model > 0xf))
Chuck Ebbert 7533b16
-				printk(KERN_WARNING DRVNAME ": Unknown CPU "
Chuck Ebbert 7533b16
-					"model 0x%x\n", c->x86_model);
Chuck Ebbert 7533b16
-			continue;
Chuck Ebbert 7533b16
+		} else {
Chuck Ebbert 7533b16
+			printk(KERN_INFO DRVNAME ": CPU (model=0x%x)"
Chuck Ebbert 7533b16
+				" has no thermal sensor.\n", c->x86_model);
Chuck Ebbert 7533b16
 		}
Chuck Ebbert 7533b16
-
Chuck Ebbert 7533b16
-		err = coretemp_device_add(i);
Chuck Ebbert 7533b16
-		if (err)
Chuck Ebbert 7533b16
-			goto exit_devices_unreg;
Chuck Ebbert 7533b16
 	}
Chuck Ebbert 7533b16
 	if (list_empty(&pdev_list)) {
Chuck Ebbert 7533b16
 		err = -ENODEV;