Skip to content

Commit e46156e

Browse files
committed
hwmon: (k10temp): Use cpu_feature_enabled() for detecting zen
JIRA: https://issues.redhat.com/browse/RHEL-104300 commit 4599510 Author: Mario Limonciello <mario.limonciello@amd.com> Date: Tue Aug 20 00:35:57 2024 -0500 hwmon: (k10temp): Use cpu_feature_enabled() for detecting zen This removes some boilerplate from the code and will allow adding future CPUs by just device IDs. Signed-off-by: Mario Limonciello <mario.limonciello@amd.com> Message-ID: <20240820053558.1052853-1-superm1@kernel.org> Signed-off-by: Guenter Roeck <linux@roeck-us.net> Signed-off-by: David Arcari <darcari@redhat.com>
1 parent 5d1ca4f commit e46156e

File tree

1 file changed

+10
-16
lines changed

1 file changed

+10
-16
lines changed

drivers/hwmon/k10temp.c

Lines changed: 10 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -443,16 +443,21 @@ static int k10temp_probe(struct pci_dev *pdev, const struct pci_device_id *id)
443443
data->disp_negative = true;
444444
}
445445

446-
if (boot_cpu_data.x86 == 0x15 &&
446+
data->is_zen = cpu_feature_enabled(X86_FEATURE_ZEN);
447+
if (data->is_zen) {
448+
data->temp_adjust_mask = ZEN_CUR_TEMP_RANGE_SEL_MASK;
449+
data->read_tempreg = read_tempreg_nb_zen;
450+
} else if (boot_cpu_data.x86 == 0x15 &&
447451
((boot_cpu_data.x86_model & 0xf0) == 0x60 ||
448452
(boot_cpu_data.x86_model & 0xf0) == 0x70)) {
449453
data->read_htcreg = read_htcreg_nb_f15;
450454
data->read_tempreg = read_tempreg_nb_f15;
451-
} else if (boot_cpu_data.x86 == 0x17 || boot_cpu_data.x86 == 0x18) {
452-
data->temp_adjust_mask = ZEN_CUR_TEMP_RANGE_SEL_MASK;
453-
data->read_tempreg = read_tempreg_nb_zen;
454-
data->is_zen = true;
455+
} else {
456+
data->read_htcreg = read_htcreg_pci;
457+
data->read_tempreg = read_tempreg_pci;
458+
}
455459

460+
if (boot_cpu_data.x86 == 0x17 || boot_cpu_data.x86 == 0x18) {
456461
switch (boot_cpu_data.x86_model) {
457462
case 0x1: /* Zen */
458463
case 0x8: /* Zen+ */
@@ -474,10 +479,6 @@ static int k10temp_probe(struct pci_dev *pdev, const struct pci_device_id *id)
474479
break;
475480
}
476481
} else if (boot_cpu_data.x86 == 0x19) {
477-
data->temp_adjust_mask = ZEN_CUR_TEMP_RANGE_SEL_MASK;
478-
data->read_tempreg = read_tempreg_nb_zen;
479-
data->is_zen = true;
480-
481482
switch (boot_cpu_data.x86_model) {
482483
case 0x0 ... 0x1: /* Zen3 SP3/TR */
483484
case 0x8: /* Zen3 TR Chagall */
@@ -501,13 +502,6 @@ static int k10temp_probe(struct pci_dev *pdev, const struct pci_device_id *id)
501502
k10temp_get_ccd_support(data, 12);
502503
break;
503504
}
504-
} else if (boot_cpu_data.x86 == 0x1a) {
505-
data->temp_adjust_mask = ZEN_CUR_TEMP_RANGE_SEL_MASK;
506-
data->read_tempreg = read_tempreg_nb_zen;
507-
data->is_zen = true;
508-
} else {
509-
data->read_htcreg = read_htcreg_pci;
510-
data->read_tempreg = read_tempreg_pci;
511505
}
512506

513507
for (i = 0; i < ARRAY_SIZE(tctl_offset_table); i++) {

0 commit comments

Comments
 (0)