Skip to content

Commit 18b24a5

Browse files
zhang-ruigroeck
authored andcommitted
hwmon: (coretemp) Remove redundant temp_data->is_pkg_data
temp_data->index saves the index in pdata->core_data[]. It is not used by package temp_data. Use temp_data->index as the indicator of package temp_data and remove redundant temp_data->is_pkg_data. No functional change. Signed-off-by: Zhang Rui <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Guenter Roeck <[email protected]>
1 parent 326241f commit 18b24a5

File tree

1 file changed

+11
-8
lines changed

1 file changed

+11
-8
lines changed

drivers/hwmon/coretemp.c

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -70,19 +70,16 @@ enum coretemp_attr_index {
7070
* @status_reg: One of IA32_THERM_STATUS or IA32_PACKAGE_THERM_STATUS,
7171
* from where the temperature values should be read.
7272
* @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.
7573
*/
7674
struct temp_data {
7775
int temp;
7876
int tjmax;
7977
unsigned long last_updated;
8078
unsigned int cpu;
81-
unsigned int index;
79+
int index;
8280
u32 cpu_core_id;
8381
u32 status_reg;
8482
int attr_size;
85-
bool is_pkg_data;
8683
struct device_attribute sd_attrs[TOTAL_ATTRS];
8784
char attr_name[TOTAL_ATTRS][CORETEMP_NAME_LENGTH];
8885
struct attribute *attrs[TOTAL_ATTRS + 1];
@@ -149,6 +146,11 @@ static const struct tjmax_model tjmax_model_table[] = {
149146
*/
150147
};
151148

149+
static bool is_pkg_temp_data(struct temp_data *tdata)
150+
{
151+
return tdata->index < 0;
152+
}
153+
152154
static int adjust_tjmax(struct cpuinfo_x86 *c, u32 id, struct device *dev)
153155
{
154156
/* The 100C is default for both mobile and non mobile CPUs */
@@ -341,7 +343,7 @@ static ssize_t show_label(struct device *dev,
341343
struct platform_data *pdata = dev_get_drvdata(dev);
342344
struct temp_data *tdata = container_of(devattr, struct temp_data, sd_attrs[ATTR_LABEL]);
343345

344-
if (tdata->is_pkg_data)
346+
if (is_pkg_temp_data(tdata))
345347
return sprintf(buf, "Package id %u\n", pdata->pkg_id);
346348

347349
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)
433435
* The attr number is always core id + 2
434436
* The Pkgtemp will always show up as temp1_*, if available
435437
*/
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;
437439

438440
snprintf(tdata->attr_name[i], CORETEMP_NAME_LENGTH,
439441
"temp%d_%s", attr_no, suffixes[i]);
@@ -484,6 +486,8 @@ init_temp_data(struct platform_data *pdata, unsigned int cpu, int pkg_flag)
484486

485487
if (pkg_flag) {
486488
pdata->pkg_data = tdata;
489+
/* Use tdata->index as indicator of package temp data */
490+
tdata->index = -1;
487491
} else {
488492
tdata->index = ida_alloc_max(&pdata->ida, NUM_REAL_CORES - 1, GFP_KERNEL);
489493
if (tdata->index < 0) {
@@ -495,7 +499,6 @@ init_temp_data(struct platform_data *pdata, unsigned int cpu, int pkg_flag)
495499

496500
tdata->status_reg = pkg_flag ? MSR_IA32_PACKAGE_THERM_STATUS :
497501
MSR_IA32_THERM_STATUS;
498-
tdata->is_pkg_data = pkg_flag;
499502
tdata->cpu = cpu;
500503
tdata->cpu_core_id = topology_core_id(cpu);
501504
tdata->attr_size = MAX_CORE_ATTRS;
@@ -505,7 +508,7 @@ init_temp_data(struct platform_data *pdata, unsigned int cpu, int pkg_flag)
505508

506509
static void destroy_temp_data(struct platform_data *pdata, struct temp_data *tdata)
507510
{
508-
if (tdata->is_pkg_data) {
511+
if (is_pkg_temp_data(tdata)) {
509512
pdata->pkg_data = NULL;
510513
} else {
511514
pdata->core_data[tdata->index] = NULL;

0 commit comments

Comments
 (0)