hwmon: (coretemp) Properly label the sensors

Don't assume that CPU entry number and core ID always match. It
worked in the simple cases (single CPU, no HT) but fails on
multi-CPU systems.

Signed-off-by: Jean Delvare <khali@linux-fr.org>
Acked-by: Huaxu Wan <huaxu.wan@intel.com>
Cc: stable@kernel.org

+5 -1
+5 -1
drivers/hwmon/coretemp.c
··· 53 struct mutex update_lock; 54 const char *name; 55 u32 id; 56 char valid; /* zero until following fields are valid */ 57 unsigned long last_updated; /* in jiffies */ 58 int temp; ··· 76 if (attr->index == SHOW_NAME) 77 ret = sprintf(buf, "%s\n", data->name); 78 else /* show label */ 79 - ret = sprintf(buf, "Core %d\n", data->id); 80 return ret; 81 } 82 ··· 305 } 306 307 data->id = pdev->id; 308 data->name = "coretemp"; 309 mutex_init(&data->update_lock); 310
··· 53 struct mutex update_lock; 54 const char *name; 55 u32 id; 56 + u16 core_id; 57 char valid; /* zero until following fields are valid */ 58 unsigned long last_updated; /* in jiffies */ 59 int temp; ··· 75 if (attr->index == SHOW_NAME) 76 ret = sprintf(buf, "%s\n", data->name); 77 else /* show label */ 78 + ret = sprintf(buf, "Core %d\n", data->core_id); 79 return ret; 80 } 81 ··· 304 } 305 306 data->id = pdev->id; 307 + #ifdef CONFIG_SMP 308 + data->core_id = c->cpu_core_id; 309 + #endif 310 data->name = "coretemp"; 311 mutex_init(&data->update_lock); 312