drivers: intc: ioapic: initialize vtd device at compile time

Initialize the vtd device at compile time. Also removed unnecessary
macro hackery. As a result, vtd pointer can be constified.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
This commit is contained in:
Gerard Marull-Paretas 2022-08-17 13:18:45 +02:00 committed by Carles Cufí
parent a3b01b00d4
commit 4c575fa37d

View File

@ -122,7 +122,8 @@ static void IoApicRedUpdateLo(unsigned int irq, uint32_t value,
#include <zephyr/drivers/interrupt_controller/intel_vtd.h>
#include <zephyr/arch/x86/acpi.h>
static const struct device *vtd;
static const struct device *const vtd =
DEVICE_DT_GET_OR_NULL(DT_INST(0, intel_vt_d));
static uint16_t ioapic_id;
@ -132,14 +133,6 @@ static bool get_vtd(void)
return true;
}
#define DRV_COMPAT_BAK DT_DRV_COMPAT
#undef DT_DRV_COMPAT
#define DT_DRV_COMPAT intel_vt_d
vtd = DEVICE_DT_GET_OR_NULL(DT_DRV_INST(0));
#undef DT_DRV_COMPAT
#define DT_DRV_COMPAT DRV_COMPAT_BAK
#undef DRV_COMPAT_BAK
ioapic_id = z_acpi_get_dev_id_from_dmar(ACPI_DRHD_DEV_SCOPE_IOAPIC);
return vtd == NULL ? false : true;