@@ -70,19 +70,16 @@ enum coretemp_attr_index {
70
70
* @status_reg: One of IA32_THERM_STATUS or IA32_PACKAGE_THERM_STATUS,
71
71
* from where the temperature values should be read.
72
72
* @attr_size: Total number of pre-core attrs displayed in the sysfs.
73
- * @is_pkg_data: If this is 1, the temp_data holds pkgtemp data.
74
- * Otherwise, temp_data holds coretemp data.
75
73
*/
76
74
struct temp_data {
77
75
int temp ;
78
76
int tjmax ;
79
77
unsigned long last_updated ;
80
78
unsigned int cpu ;
81
- unsigned int index ;
79
+ int index ;
82
80
u32 cpu_core_id ;
83
81
u32 status_reg ;
84
82
int attr_size ;
85
- bool is_pkg_data ;
86
83
struct device_attribute sd_attrs [TOTAL_ATTRS ];
87
84
char attr_name [TOTAL_ATTRS ][CORETEMP_NAME_LENGTH ];
88
85
struct attribute * attrs [TOTAL_ATTRS + 1 ];
@@ -149,6 +146,11 @@ static const struct tjmax_model tjmax_model_table[] = {
149
146
*/
150
147
};
151
148
149
+ static bool is_pkg_temp_data (struct temp_data * tdata )
150
+ {
151
+ return tdata -> index < 0 ;
152
+ }
153
+
152
154
static int adjust_tjmax (struct cpuinfo_x86 * c , u32 id , struct device * dev )
153
155
{
154
156
/* The 100C is default for both mobile and non mobile CPUs */
@@ -341,7 +343,7 @@ static ssize_t show_label(struct device *dev,
341
343
struct platform_data * pdata = dev_get_drvdata (dev );
342
344
struct temp_data * tdata = container_of (devattr , struct temp_data , sd_attrs [ATTR_LABEL ]);
343
345
344
- if (tdata -> is_pkg_data )
346
+ if (is_pkg_temp_data ( tdata ) )
345
347
return sprintf (buf , "Package id %u\n" , pdata -> pkg_id );
346
348
347
349
return sprintf (buf , "Core %u\n" , tdata -> cpu_core_id );
@@ -433,7 +435,7 @@ static int create_core_attrs(struct temp_data *tdata, struct device *dev)
433
435
* The attr number is always core id + 2
434
436
* The Pkgtemp will always show up as temp1_*, if available
435
437
*/
436
- int attr_no = tdata -> is_pkg_data ? 1 : tdata -> cpu_core_id + 2 ;
438
+ int attr_no = is_pkg_temp_data ( tdata ) ? 1 : tdata -> cpu_core_id + 2 ;
437
439
438
440
snprintf (tdata -> attr_name [i ], CORETEMP_NAME_LENGTH ,
439
441
"temp%d_%s" , attr_no , suffixes [i ]);
@@ -484,6 +486,8 @@ init_temp_data(struct platform_data *pdata, unsigned int cpu, int pkg_flag)
484
486
485
487
if (pkg_flag ) {
486
488
pdata -> pkg_data = tdata ;
489
+ /* Use tdata->index as indicator of package temp data */
490
+ tdata -> index = -1 ;
487
491
} else {
488
492
tdata -> index = ida_alloc_max (& pdata -> ida , NUM_REAL_CORES - 1 , GFP_KERNEL );
489
493
if (tdata -> index < 0 ) {
@@ -495,7 +499,6 @@ init_temp_data(struct platform_data *pdata, unsigned int cpu, int pkg_flag)
495
499
496
500
tdata -> status_reg = pkg_flag ? MSR_IA32_PACKAGE_THERM_STATUS :
497
501
MSR_IA32_THERM_STATUS ;
498
- tdata -> is_pkg_data = pkg_flag ;
499
502
tdata -> cpu = cpu ;
500
503
tdata -> cpu_core_id = topology_core_id (cpu );
501
504
tdata -> attr_size = MAX_CORE_ATTRS ;
@@ -505,7 +508,7 @@ init_temp_data(struct platform_data *pdata, unsigned int cpu, int pkg_flag)
505
508
506
509
static void destroy_temp_data (struct platform_data * pdata , struct temp_data * tdata )
507
510
{
508
- if (tdata -> is_pkg_data ) {
511
+ if (is_pkg_temp_data ( tdata ) ) {
509
512
pdata -> pkg_data = NULL ;
510
513
} else {
511
514
pdata -> core_data [tdata -> index ] = NULL ;
0 commit comments