treewide: use is_enabled_cpu() on cycles over device list
use is_enabled_cpu() on cycles over device list to check
whether the current device is enabled cpu.
TEST: compile test and qemu run successfully with coreinfo
payload
Signed-off-by: Fabio Aiuto <fabioaiuto83@gmail.com>
Change-Id: If64bd18f006b6f5fecef4f606c1df7d3a4d42883
Reviewed-on: https://review.coreboot.org/c/coreboot/+/67797
Reviewed-by: Tim Wawrzynczak <inforichland@gmail.com>
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Felix Held <felix-coreboot@felixheld.de>
diff --git a/src/acpi/acpi.c b/src/acpi/acpi.c
index 78d5f07..e211558 100644
--- a/src/acpi/acpi.c
+++ b/src/acpi/acpi.c
@@ -147,11 +147,7 @@
int index, apic_ids[CONFIG_MAX_CPUS] = {0}, num_cpus = 0;
for (cpu = all_devices; cpu; cpu = cpu->next) {
- if ((cpu->path.type != DEVICE_PATH_APIC) ||
- (cpu->bus->dev->path.type != DEVICE_PATH_CPU_CLUSTER)) {
- continue;
- }
- if (!cpu->enabled)
+ if (!is_enabled_cpu(cpu))
continue;
if (num_cpus >= ARRAY_SIZE(apic_ids))
break;
diff --git a/src/arch/x86/mpspec.c b/src/arch/x86/mpspec.c
index 93058f1..2e65e25 100644
--- a/src/arch/x86/mpspec.c
+++ b/src/arch/x86/mpspec.c
@@ -160,12 +160,7 @@
for (order_id = 0; order_id < 256; order_id++) {
for (cpu = all_devices; cpu; cpu = cpu->next) {
unsigned long cpu_flag;
- if ((cpu->path.type != DEVICE_PATH_APIC) ||
- (cpu->bus->dev->path.type !=
- DEVICE_PATH_CPU_CLUSTER))
- continue;
-
- if (!cpu->enabled)
+ if (!is_enabled_cpu(cpu))
continue;
cpu_flag = MPC_CPU_ENABLED;
diff --git a/src/cpu/intel/speedstep/acpi.c b/src/cpu/intel/speedstep/acpi.c
index b340b6d..d997ee8 100644
--- a/src/cpu/intel/speedstep/acpi.c
+++ b/src/cpu/intel/speedstep/acpi.c
@@ -14,11 +14,7 @@
struct device *cpu;
int count = 0;
for (cpu = all_devices; cpu; cpu = cpu->next) {
- if ((cpu->path.type != DEVICE_PATH_APIC) ||
- (cpu->bus->dev->path.type != DEVICE_PATH_CPU_CLUSTER)) {
- continue;
- }
- if (!cpu->enabled)
+ if (!is_enabled_cpu(cpu))
continue;
count++;
}
diff --git a/src/device/device_util.c b/src/device/device_util.c
index 1e13bca..0be6cfb 100644
--- a/src/device/device_util.c
+++ b/src/device/device_util.c
@@ -917,10 +917,7 @@
int count = 0;
for (cpu = all_devices; cpu; cpu = cpu->next) {
- if ((cpu->path.type != DEVICE_PATH_APIC) ||
- (cpu->bus->dev->path.type != DEVICE_PATH_CPU_CLUSTER))
- continue;
- if (!cpu->enabled)
+ if (!is_enabled_cpu(cpu))
continue;
count++;
}
diff --git a/src/mainboard/prodrive/hermes/mainboard.c b/src/mainboard/prodrive/hermes/mainboard.c
index 2f0de61..a713342 100644
--- a/src/mainboard/prodrive/hermes/mainboard.c
+++ b/src/mainboard/prodrive/hermes/mainboard.c
@@ -104,11 +104,7 @@
/* Update CPU fields */
for (struct device *cpu = all_devices; cpu; cpu = cpu->next) {
- if (cpu->path.type != DEVICE_PATH_APIC)
- continue;
- if (cpu->bus->dev->path.type != DEVICE_PATH_CPU_CLUSTER)
- continue;
- if (!cpu->enabled)
+ if (!is_enabled_cpu(cpu))
continue;
layout.cpu_count++;
if (!layout.cpu_name[0])
diff --git a/src/soc/intel/xeon_sp/cpx/soc_acpi.c b/src/soc/intel/xeon_sp/cpx/soc_acpi.c
index 0d102a1..d6e7cf0 100644
--- a/src/soc/intel/xeon_sp/cpx/soc_acpi.c
+++ b/src/soc/intel/xeon_sp/cpx/soc_acpi.c
@@ -224,11 +224,7 @@
uint8_t num_cpus = 0;
for (cpu = all_devices; cpu; cpu = cpu->next) {
- if ((cpu->path.type != DEVICE_PATH_APIC) ||
- (cpu->bus->dev->path.type != DEVICE_PATH_CPU_CLUSTER)) {
- continue;
- }
- if (!cpu->enabled)
+ if (!is_enabled_cpu(cpu))
continue;
current += acpi_create_madt_lapic((acpi_madt_lapic_t *)current,
num_cpus, cpu->path.apic.apic_id);
diff --git a/src/soc/intel/xeon_sp/nb_acpi.c b/src/soc/intel/xeon_sp/nb_acpi.c
index b3e4575..64851f5 100644
--- a/src/soc/intel/xeon_sp/nb_acpi.c
+++ b/src/soc/intel/xeon_sp/nb_acpi.c
@@ -25,11 +25,7 @@
unsigned int cpu_index = 0;
for (cpu = all_devices; cpu; cpu = cpu->next) {
- if ((cpu->path.type != DEVICE_PATH_APIC) ||
- (cpu->bus->dev->path.type != DEVICE_PATH_CPU_CLUSTER)) {
- continue;
- }
- if (!cpu->enabled)
+ if (!is_enabled_cpu(cpu))
continue;
printk(BIOS_DEBUG, "SRAT: lapic cpu_index=%02x, node_id=%02x, apic_id=%02x\n",
cpu_index, cpu->path.apic.node_id, cpu->path.apic.apic_id);
diff --git a/src/soc/intel/xeon_sp/skx/soc_acpi.c b/src/soc/intel/xeon_sp/skx/soc_acpi.c
index 23bb6d6..621e755 100644
--- a/src/soc/intel/xeon_sp/skx/soc_acpi.c
+++ b/src/soc/intel/xeon_sp/skx/soc_acpi.c
@@ -155,11 +155,7 @@
uint8_t num_cpus = 0;
for (cpu = all_devices; cpu; cpu = cpu->next) {
- if ((cpu->path.type != DEVICE_PATH_APIC) ||
- (cpu->bus->dev->path.type != DEVICE_PATH_CPU_CLUSTER)) {
- continue;
- }
- if (!cpu->enabled)
+ if (!is_enabled_cpu(cpu))
continue;
current += acpi_create_madt_lapic((acpi_madt_lapic_t *)current,
num_cpus, cpu->path.apic.apic_id);
diff --git a/src/southbridge/intel/i82371eb/acpi_tables.c b/src/southbridge/intel/i82371eb/acpi_tables.c
index 5d4ca69..c23c2f6 100644
--- a/src/southbridge/intel/i82371eb/acpi_tables.c
+++ b/src/southbridge/intel/i82371eb/acpi_tables.c
@@ -11,13 +11,8 @@
struct device *cpu;
int count = 0;
for (cpu = all_devices; cpu; cpu = cpu->next) {
- if ((cpu->path.type != DEVICE_PATH_APIC) ||
- (cpu->bus->dev->path.type != DEVICE_PATH_CPU_CLUSTER)) {
+ if (!is_enabled_cpu(cpu))
continue;
- }
- if (!cpu->enabled) {
- continue;
- }
count++;
}
return count;