[PATCH] nvmem: core: Constify struct bus_type

From: Christophe JAILLET
Date: Sat Jul 20 2024 - 03:58:04 EST


'struct bus_type' is not modified in this driver.

Constifying this structure moves some data to a read-only section, so
increase overall security, especially when the structure holds some
function pointers.

On a x86_64, with allmodconfig, as an example:
Before:
======
text data bss dec hex filename
36908 3256 32 40196 9d04 drivers/nvmem/core.o

After:
=====
text data bss dec hex filename
37068 3096 32 40196 9d04 drivers/nvmem/core.o

Signed-off-by: Christophe JAILLET <christophe.jaillet@xxxxxxxxxx>
---
Compile tested-only.
---
drivers/nvmem/core.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/nvmem/core.c b/drivers/nvmem/core.c
index 516dfd861b9f..19f2b90e6740 100644
--- a/drivers/nvmem/core.c
+++ b/drivers/nvmem/core.c
@@ -534,7 +534,7 @@ static const struct device_type nvmem_provider_type = {
.release = nvmem_release,
};

-static struct bus_type nvmem_bus_type = {
+static const struct bus_type nvmem_bus_type = {
.name = "nvmem",
};

--
2.45.2