Skip to content

Commit 5db47b0

Browse files
Carsten Emdetorvalds
authored andcommitted
drivers/hwmon/coretemp.c: detect the thermal sensors by CPUID
The thermal sensors of Intel(R) CPUs can be detected by CPUID instruction, indicated by CPUID.06H.EAX[0]. Signed-off-by: Huaxu Wan <huaxu.wan@linux.intel.com> Signed-off-by: Carsten Emde <C.Emde@osadl.org> Reviewed-by: Valdis Kletnieks <valdis.kletnieks@vt.edu> Cc: Jean Delvare <khali@linux-fr.org> Cc: Henrique de Moraes Holschuh <hmh@hmh.eng.br> Cc: Yong Wang <yong.y.wang@linux.intel.com> Cc: Rudolf Marek <r.marek@assembler.cz> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
1 parent e0c70b8 commit 5db47b0

File tree

1 file changed

+12
-20
lines changed

1 file changed

+12
-20
lines changed

drivers/hwmon/coretemp.c

Lines changed: 12 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -451,28 +451,20 @@ static int __init coretemp_init(void)
451451

452452
for_each_online_cpu(i) {
453453
struct cpuinfo_x86 *c = &cpu_data(i);
454+
/*
455+
* CPUID.06H.EAX[0] indicates whether the CPU has thermal
456+
* sensors. We check this bit only, all the early CPUs
457+
* without thermal sensors will be filtered out.
458+
*/
459+
if (c->cpuid_level >= 6 && (cpuid_eax(0x06) & 0x01)) {
460+
err = coretemp_device_add(i);
461+
if (err)
462+
goto exit_devices_unreg;
454463

455-
/* check if family 6, models 0xe (Pentium M DC),
456-
0xf (Core 2 DC 65nm), 0x16 (Core 2 SC 65nm),
457-
0x17 (Penryn 45nm), 0x1a (Nehalem), 0x1c (Atom),
458-
0x1e (Lynnfield) */
459-
if ((c->cpuid_level < 0) || (c->x86 != 0x6) ||
460-
!((c->x86_model == 0xe) || (c->x86_model == 0xf) ||
461-
(c->x86_model == 0x16) || (c->x86_model == 0x17) ||
462-
(c->x86_model == 0x1a) || (c->x86_model == 0x1c) ||
463-
(c->x86_model == 0x1e))) {
464-
465-
/* supported CPU not found, but report the unknown
466-
family 6 CPU */
467-
if ((c->x86 == 0x6) && (c->x86_model > 0xf))
468-
printk(KERN_WARNING DRVNAME ": Unknown CPU "
469-
"model 0x%x\n", c->x86_model);
470-
continue;
464+
} else {
465+
printk(KERN_INFO DRVNAME ": CPU (model=0x%x)"
466+
" has no thermal sensor.\n", c->x86_model);
471467
}
472-
473-
err = coretemp_device_add(i);
474-
if (err)
475-
goto exit_devices_unreg;
476468
}
477469
if (list_empty(&pdev_list)) {
478470
err = -ENODEV;

0 commit comments

Comments
 (0)