Skip to content

Commit 4599510

Browse files
superm1groeck
authored andcommitted
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>
1 parent 0050c16 commit 4599510

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
@@ -438,16 +438,21 @@ static int k10temp_probe(struct pci_dev *pdev, const struct pci_device_id *id)
438438
data->disp_negative = true;
439439
}
440440

441-
if (boot_cpu_data.x86 == 0x15 &&
441+
data->is_zen = cpu_feature_enabled(X86_FEATURE_ZEN);
442+
if (data->is_zen) {
443+
data->temp_adjust_mask = ZEN_CUR_TEMP_RANGE_SEL_MASK;
444+
data->read_tempreg = read_tempreg_nb_zen;
445+
} else if (boot_cpu_data.x86 == 0x15 &&
442446
((boot_cpu_data.x86_model & 0xf0) == 0x60 ||
443447
(boot_cpu_data.x86_model & 0xf0) == 0x70)) {
444448
data->read_htcreg = read_htcreg_nb_f15;
445449
data->read_tempreg = read_tempreg_nb_f15;
446-
} else if (boot_cpu_data.x86 == 0x17 || boot_cpu_data.x86 == 0x18) {
447-
data->temp_adjust_mask = ZEN_CUR_TEMP_RANGE_SEL_MASK;
448-
data->read_tempreg = read_tempreg_nb_zen;
449-
data->is_zen = true;
450+
} else {
451+
data->read_htcreg = read_htcreg_pci;
452+
data->read_tempreg = read_tempreg_pci;
453+
}
450454

455+
if (boot_cpu_data.x86 == 0x17 || boot_cpu_data.x86 == 0x18) {
451456
switch (boot_cpu_data.x86_model) {
452457
case 0x1: /* Zen */
453458
case 0x8: /* Zen+ */
@@ -469,10 +474,6 @@ static int k10temp_probe(struct pci_dev *pdev, const struct pci_device_id *id)
469474
break;
470475
}
471476
} else if (boot_cpu_data.x86 == 0x19) {
472-
data->temp_adjust_mask = ZEN_CUR_TEMP_RANGE_SEL_MASK;
473-
data->read_tempreg = read_tempreg_nb_zen;
474-
data->is_zen = true;
475-
476477
switch (boot_cpu_data.x86_model) {
477478
case 0x0 ... 0x1: /* Zen3 SP3/TR */
478479
case 0x8: /* Zen3 TR Chagall */
@@ -496,13 +497,6 @@ static int k10temp_probe(struct pci_dev *pdev, const struct pci_device_id *id)
496497
k10temp_get_ccd_support(data, 12);
497498
break;
498499
}
499-
} else if (boot_cpu_data.x86 == 0x1a) {
500-
data->temp_adjust_mask = ZEN_CUR_TEMP_RANGE_SEL_MASK;
501-
data->read_tempreg = read_tempreg_nb_zen;
502-
data->is_zen = true;
503-
} else {
504-
data->read_htcreg = read_htcreg_pci;
505-
data->read_tempreg = read_tempreg_pci;
506500
}
507501

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

0 commit comments

Comments
 (0)