[PATCH] treewide: Staticize and constify acpi ops
Marek Vasut
marek.vasut+renesas at mailbox.org
Fri Jun 12 04:05:38 CEST 2026
Set the acpi_ops structure as static const where applicable. The
The structure is not accessible from outside of drivers and is not
going to be modified at runtime. The structure may be unused in a
couple of drivers depending on their configuration, mark those
sites with __maybe_unused .
Signed-off-by: Marek Vasut <marek.vasut+renesas at mailbox.org>
---
Cc: Simon Glass <sjg at chromium.org>
Cc: Tom Rini <trini at konsulko.com>
Cc: u-boot at lists.denx.de
---
arch/arm/lib/gic-v2.c | 2 +-
arch/arm/lib/gic-v3-its.c | 2 +-
arch/x86/cpu/apollolake/cpu.c | 4 +---
arch/x86/cpu/apollolake/hostbridge.c | 2 +-
arch/x86/cpu/apollolake/lpc.c | 2 +-
arch/x86/cpu/intel_common/generic_wifi.c | 2 +-
arch/x86/lib/fsp/fsp_graphics.c | 2 +-
board/google/chromebook_coral/coral.c | 2 +-
drivers/core/acpi.c | 4 ++--
drivers/core/root.c | 2 +-
drivers/cpu/armv8_cpu.c | 2 +-
drivers/cpu/bcm283x_cpu.c | 2 +-
drivers/gpio/sandbox.c | 4 ++--
drivers/i2c/designware_i2c_pci.c | 2 +-
drivers/mmc/pci_mmc.c | 4 ++--
drivers/rtc/sandbox_rtc.c | 2 +-
drivers/sound/da7219.c | 2 +-
drivers/sound/max98357a.c | 2 +-
drivers/tpm/cr50_i2c.c | 2 +-
include/dm/device.h | 2 +-
test/dm/acpi.c | 2 +-
21 files changed, 24 insertions(+), 26 deletions(-)
diff --git a/arch/arm/lib/gic-v2.c b/arch/arm/lib/gic-v2.c
index b70434a45d4..378bdb54c89 100644
--- a/arch/arm/lib/gic-v2.c
+++ b/arch/arm/lib/gic-v2.c
@@ -38,7 +38,7 @@ static int acpi_gicv2_fill_madt(const struct udevice *dev, struct acpi_ctx *ctx)
return 0;
}
-static struct acpi_ops gic_v2_acpi_ops = {
+static const struct acpi_ops gic_v2_acpi_ops = {
.fill_madt = acpi_gicv2_fill_madt,
};
#endif
diff --git a/arch/arm/lib/gic-v3-its.c b/arch/arm/lib/gic-v3-its.c
index d11a1ea436e..064b93b2aa1 100644
--- a/arch/arm/lib/gic-v3-its.c
+++ b/arch/arm/lib/gic-v3-its.c
@@ -197,7 +197,7 @@ static int acpi_gicv3_fill_madt(const struct udevice *dev, struct acpi_ctx *ctx)
return 0;
}
-struct acpi_ops gic_v3_acpi_ops = {
+static const struct acpi_ops gic_v3_acpi_ops = {
.fill_madt = acpi_gicv3_fill_madt,
};
#endif
diff --git a/arch/x86/cpu/apollolake/cpu.c b/arch/x86/cpu/apollolake/cpu.c
index f480bb1d8c3..d1f592ec57e 100644
--- a/arch/x86/cpu/apollolake/cpu.c
+++ b/arch/x86/cpu/apollolake/cpu.c
@@ -171,11 +171,9 @@ static int cpu_apl_probe(struct udevice *dev)
return 0;
}
-#ifdef CONFIG_ACPIGEN
-struct acpi_ops apl_cpu_acpi_ops = {
+static const struct acpi_ops __maybe_unused apl_cpu_acpi_ops = {
.fill_ssdt = acpi_cpu_fill_ssdt,
};
-#endif
static const struct cpu_ops cpu_x86_apl_ops = {
.get_desc = cpu_x86_get_desc,
diff --git a/arch/x86/cpu/apollolake/hostbridge.c b/arch/x86/cpu/apollolake/hostbridge.c
index 284f16cfd91..360d091121c 100644
--- a/arch/x86/cpu/apollolake/hostbridge.c
+++ b/arch/x86/cpu/apollolake/hostbridge.c
@@ -366,7 +366,7 @@ ulong sa_get_tseg_base(struct udevice *dev)
return sa_read_reg(dev, TSEG);
}
-struct acpi_ops apl_hostbridge_acpi_ops = {
+static const struct acpi_ops __maybe_unused apl_hostbridge_acpi_ops = {
.get_name = apl_acpi_hb_get_name,
#if CONFIG_IS_ENABLED(GENERATE_ACPI_TABLE)
.write_tables = apl_acpi_hb_write_tables,
diff --git a/arch/x86/cpu/apollolake/lpc.c b/arch/x86/cpu/apollolake/lpc.c
index f34c199bf73..008c4dc0037 100644
--- a/arch/x86/cpu/apollolake/lpc.c
+++ b/arch/x86/cpu/apollolake/lpc.c
@@ -119,7 +119,7 @@ static int apl_acpi_lpc_get_name(const struct udevice *dev, char *out_name)
return acpi_copy_name(out_name, "LPCB");
}
-struct acpi_ops apl_lpc_acpi_ops = {
+static const struct acpi_ops __maybe_unused apl_lpc_acpi_ops = {
.get_name = apl_acpi_lpc_get_name,
#ifdef CONFIG_GENERATE_ACPI_TABLE
.write_tables = intel_southbridge_write_acpi_tables,
diff --git a/arch/x86/cpu/intel_common/generic_wifi.c b/arch/x86/cpu/intel_common/generic_wifi.c
index 75fa4e01d8a..1a24c10ab0b 100644
--- a/arch/x86/cpu/intel_common/generic_wifi.c
+++ b/arch/x86/cpu/intel_common/generic_wifi.c
@@ -102,7 +102,7 @@ static int intel_wifi_acpi_fill_ssdt(const struct udevice *dev,
return 0;
}
-struct acpi_ops wifi_acpi_ops = {
+static const struct acpi_ops wifi_acpi_ops = {
.fill_ssdt = intel_wifi_acpi_fill_ssdt,
};
diff --git a/arch/x86/lib/fsp/fsp_graphics.c b/arch/x86/lib/fsp/fsp_graphics.c
index ad25020086c..d425e80760b 100644
--- a/arch/x86/lib/fsp/fsp_graphics.c
+++ b/arch/x86/lib/fsp/fsp_graphics.c
@@ -150,7 +150,7 @@ static int fsp_video_acpi_write_tables(const struct udevice *dev,
}
#endif
-struct acpi_ops fsp_video_acpi_ops = {
+static const struct acpi_ops __maybe_unused fsp_video_acpi_ops = {
#ifdef CONFIG_INTEL_GMA_ACPI
.write_tables = fsp_video_acpi_write_tables,
#endif
diff --git a/board/google/chromebook_coral/coral.c b/board/google/chromebook_coral/coral.c
index b4053fa097d..2bb54d59bb8 100644
--- a/board/google/chromebook_coral/coral.c
+++ b/board/google/chromebook_coral/coral.c
@@ -293,7 +293,7 @@ static int coral_write_acpi_tables(const struct udevice *dev,
return 0;
}
-struct acpi_ops coral_acpi_ops = {
+static const struct acpi_ops __maybe_unused coral_acpi_ops = {
.write_tables = coral_write_acpi_tables,
.inject_dsdt = chromeos_acpi_gpio_generate,
};
diff --git a/drivers/core/acpi.c b/drivers/core/acpi.c
index 6a431171c8d..284fb70b036 100644
--- a/drivers/core/acpi.c
+++ b/drivers/core/acpi.c
@@ -87,7 +87,7 @@ int acpi_copy_name(char *out_name, const char *name)
int acpi_get_name(const struct udevice *dev, char *out_name)
{
- struct acpi_ops *aops;
+ const struct acpi_ops *aops;
const char *name;
int ret;
@@ -275,7 +275,7 @@ static int sort_acpi_item_type(struct acpi_ctx *ctx, void *start,
acpi_method acpi_get_method(struct udevice *dev, enum method_t method)
{
- struct acpi_ops *aops;
+ const struct acpi_ops *aops;
aops = device_get_acpi_ops(dev);
if (aops) {
diff --git a/drivers/core/root.c b/drivers/core/root.c
index 1f32f33b295..2aa16d59b69 100644
--- a/drivers/core/root.c
+++ b/drivers/core/root.c
@@ -459,7 +459,7 @@ static int root_acpi_get_name(const struct udevice *dev, char *out_name)
return acpi_copy_name(out_name, "\\_SB");
}
-struct acpi_ops root_acpi_ops = {
+static const struct acpi_ops root_acpi_ops = {
.get_name = root_acpi_get_name,
};
#endif
diff --git a/drivers/cpu/armv8_cpu.c b/drivers/cpu/armv8_cpu.c
index ed87841b723..337661c23a8 100644
--- a/drivers/cpu/armv8_cpu.c
+++ b/drivers/cpu/armv8_cpu.c
@@ -124,7 +124,7 @@ int armv8_cpu_fill_madt(const struct udevice *dev, struct acpi_ctx *ctx)
return 0;
}
-static struct acpi_ops armv8_cpu_acpi_ops = {
+static const struct acpi_ops armv8_cpu_acpi_ops = {
.fill_ssdt = armv8_cpu_fill_ssdt,
.fill_madt = armv8_cpu_fill_madt,
};
diff --git a/drivers/cpu/bcm283x_cpu.c b/drivers/cpu/bcm283x_cpu.c
index ad638cd8fff..43e74d1811b 100644
--- a/drivers/cpu/bcm283x_cpu.c
+++ b/drivers/cpu/bcm283x_cpu.c
@@ -193,7 +193,7 @@ static int bcm_cpu_probe(struct udevice *dev)
return ret;
}
-struct acpi_ops bcm283x_cpu_acpi_ops = {
+static const struct acpi_ops __maybe_unused bcm283x_cpu_acpi_ops = {
.fill_ssdt = armv8_cpu_fill_ssdt,
.fill_madt = armv8_cpu_fill_madt,
};
diff --git a/drivers/gpio/sandbox.c b/drivers/gpio/sandbox.c
index e8f50d815d7..76aff0ed5aa 100644
--- a/drivers/gpio/sandbox.c
+++ b/drivers/gpio/sandbox.c
@@ -306,7 +306,7 @@ static int sb_gpio_get_name(const struct udevice *dev, char *out_name)
return acpi_copy_name(out_name, "GPIO");
}
-struct acpi_ops gpio_sandbox_acpi_ops = {
+static const struct acpi_ops gpio_sandbox_acpi_ops = {
.get_name = sb_gpio_get_name,
};
#endif /* ACPIGEN */
@@ -568,7 +568,7 @@ static struct pinctrl_ops sandbox_pinctrl_gpio_ops = {
};
#if CONFIG_IS_ENABLED(ACPIGEN)
-struct acpi_ops pinctrl_sandbox_acpi_ops = {
+static const struct acpi_ops pinctrl_sandbox_acpi_ops = {
.get_name = sb_pinctrl_get_name,
};
#endif
diff --git a/drivers/i2c/designware_i2c_pci.c b/drivers/i2c/designware_i2c_pci.c
index ad4122c2abd..db2706fdb6e 100644
--- a/drivers/i2c/designware_i2c_pci.c
+++ b/drivers/i2c/designware_i2c_pci.c
@@ -168,7 +168,7 @@ static int dw_i2c_acpi_fill_ssdt(const struct udevice *dev,
return 0;
}
-static struct acpi_ops dw_i2c_acpi_ops = {
+static const struct acpi_ops dw_i2c_acpi_ops = {
.fill_ssdt = dw_i2c_acpi_fill_ssdt,
};
diff --git a/drivers/mmc/pci_mmc.c b/drivers/mmc/pci_mmc.c
index d446c55f72b..82e393fd9d6 100644
--- a/drivers/mmc/pci_mmc.c
+++ b/drivers/mmc/pci_mmc.c
@@ -137,11 +137,11 @@ static int pci_mmc_acpi_fill_ssdt(const struct udevice *dev,
return 0;
}
-struct acpi_ops pci_mmc_acpi_ops = {
#ifdef CONFIG_ACPIGEN
+static const struct acpi_ops pci_mmc_acpi_ops = {
.fill_ssdt = pci_mmc_acpi_fill_ssdt,
-#endif
};
+#endif
static const struct udevice_id pci_mmc_match[] = {
{ .compatible = "intel,apl-sd", .data = TYPE_SD },
diff --git a/drivers/rtc/sandbox_rtc.c b/drivers/rtc/sandbox_rtc.c
index 4404501c2f6..1ade5d50b23 100644
--- a/drivers/rtc/sandbox_rtc.c
+++ b/drivers/rtc/sandbox_rtc.c
@@ -73,7 +73,7 @@ static int sandbox_rtc_get_name(const struct udevice *dev, char *out_name)
return acpi_copy_name(out_name, "RTCC");
}
-struct acpi_ops sandbox_rtc_acpi_ops = {
+static const struct acpi_ops sandbox_rtc_acpi_ops = {
.get_name = sandbox_rtc_get_name,
};
#endif
diff --git a/drivers/sound/da7219.c b/drivers/sound/da7219.c
index 5b9b3f65263..d1d03ae91d4 100644
--- a/drivers/sound/da7219.c
+++ b/drivers/sound/da7219.c
@@ -170,7 +170,7 @@ static int da7219_acpi_setup_nhlt(const struct udevice *dev,
}
#endif
-struct acpi_ops da7219_acpi_ops = {
+static const struct acpi_ops da7219_acpi_ops = {
#ifdef CONFIG_ACPIGEN
.fill_ssdt = da7219_acpi_fill_ssdt,
#ifdef CONFIG_X86
diff --git a/drivers/sound/max98357a.c b/drivers/sound/max98357a.c
index da56ffdd6bb..47978d4fe27 100644
--- a/drivers/sound/max98357a.c
+++ b/drivers/sound/max98357a.c
@@ -136,7 +136,7 @@ static int max98357a_acpi_setup_nhlt(const struct udevice *dev,
}
#endif
-struct acpi_ops max98357a_acpi_ops = {
+static const struct acpi_ops max98357a_acpi_ops = {
#ifdef CONFIG_ACPIGEN
.fill_ssdt = max98357a_acpi_fill_ssdt,
#ifdef CONFIG_X86
diff --git a/drivers/tpm/cr50_i2c.c b/drivers/tpm/cr50_i2c.c
index 14a94f8d4a8..46805eaa013 100644
--- a/drivers/tpm/cr50_i2c.c
+++ b/drivers/tpm/cr50_i2c.c
@@ -889,7 +889,7 @@ static int cr50_i2c_probe(struct udevice *dev)
return 0;
}
-struct acpi_ops cr50_acpi_ops = {
+static const struct acpi_ops cr50_acpi_ops = {
.fill_ssdt = cr50_acpi_fill_ssdt,
};
diff --git a/include/dm/device.h b/include/dm/device.h
index 7bcf6df2892..5d700888503 100644
--- a/include/dm/device.h
+++ b/include/dm/device.h
@@ -388,7 +388,7 @@ struct driver {
const void *ops; /* driver-specific operations */
uint32_t flags;
#if CONFIG_IS_ENABLED(ACPIGEN)
- struct acpi_ops *acpi_ops;
+ const struct acpi_ops *acpi_ops;
#endif
};
diff --git a/test/dm/acpi.c b/test/dm/acpi.c
index 2de7983f9ae..293ea0274b5 100644
--- a/test/dm/acpi.c
+++ b/test/dm/acpi.c
@@ -136,7 +136,7 @@ static int testacpi_inject_dsdt(const struct udevice *dev, struct acpi_ctx *ctx)
return 0;
}
-struct acpi_ops testacpi_ops = {
+static const struct acpi_ops testacpi_ops = {
.get_name = testacpi_get_name,
.write_tables = testacpi_write_tables,
.fill_madt = testacpi_fill_madt,
--
2.53.0
More information about the U-Boot
mailing list