[PATCH] rapidio: make rio_mport_class constant

From: Ricardo B. Marliere
Date: Tue Mar 05 2024 - 15:15:28 EST


Since commit 43a7206b0963 ("driver core: class: make class_register() take
a const *"), the driver core allows for struct class to be in read-only
memory, so move the rio_mport_class structure to be declared at build time
placing it into read-only memory, instead of having to be dynamically
allocated at boot time.

Cc: Greg Kroah-Hartman <gregkh@xxxxxxxxxxxxxxxxxxx>
Suggested-by: Greg Kroah-Hartman <gregkh@xxxxxxxxxxxxxxxxxxx>
Signed-off-by: Ricardo B. Marliere <ricardo@xxxxxxxxxxxx>
---
drivers/rapidio/rio-driver.c | 2 +-
include/linux/rio.h | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/rapidio/rio-driver.c b/drivers/rapidio/rio-driver.c
index 1b3b4c2e015d..9aacb5edf6b3 100644
--- a/drivers/rapidio/rio-driver.c
+++ b/drivers/rapidio/rio-driver.c
@@ -221,7 +221,7 @@ static int rio_uevent(const struct device *dev, struct kobj_uevent_env *env)
return 0;
}

-struct class rio_mport_class = {
+const struct class rio_mport_class = {
.name = "rapidio_port",
.dev_groups = rio_mport_groups,
};
diff --git a/include/linux/rio.h b/include/linux/rio.h
index 2cd637268b4f..55cebdddabfe 100644
--- a/include/linux/rio.h
+++ b/include/linux/rio.h
@@ -79,7 +79,7 @@
#define RIO_CTAG_UDEVID 0x0001ffff /* Unique device identifier */

extern struct bus_type rio_bus_type;
-extern struct class rio_mport_class;
+extern const struct class rio_mport_class;

struct rio_mport;
struct rio_dev;

---
base-commit: 90d35da658da8cff0d4ecbb5113f5fac9d00eb72
change-id: 20240305-rapidio-fc61b2014cff

Best regards,
--
Ricardo B. Marliere <ricardo@xxxxxxxxxxxx>