Skip to contentSkip to conversation

mtd: ubi: make ubi_class constant

PATCH In review Ricardo B. Marliere 3 participants 3 messages Mar 5, 2024 – Mar 6, 2024

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 mtd: ubi: make ubi_class constant

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 ubi_class structure to be declared at build time placing it into read-only memory, instead of having to be dynamically allocated at boot time.

---
 drivers/mtd/ubi/build.c | 2 +-
 drivers/mtd/ubi/ubi.h   | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)
drivers/mtd/ubi/build.c +1 -1
index 7d4ff1193db6..1938b61e1b74 100644
@@ -111,7 +111,7 @@ static struct attribute *ubi_class_attrs[] = {
 ATTRIBUTE_GROUPS(ubi_class);
 
 /* Root UBI "class" object (corresponds to '/<sysfs>/class/ubi/') */
-struct class ubi_class = {
+const struct class ubi_class = {
 	.name		= UBI_NAME_STR,
 	.class_groups	= ubi_class_groups,
 };
drivers/mtd/ubi/ubi.h +1 -1
index 0b42bb45dd84..21c3208a9210 100644
@@ -812,7 +812,7 @@ extern struct kmem_cache *ubi_wl_entry_slab;
 extern const struct file_operations ubi_ctrl_cdev_operations;
 extern const struct file_operations ubi_cdev_operations;
 extern const struct file_operations ubi_vol_cdev_operations;
-extern struct class ubi_class;
+extern const struct class ubi_class;
 extern struct mutex ubi_devices_mutex;
 extern struct blocking_notifier_head ubi_notifiers;
 

---
base-commit: 77bf032528393d2dc9430b3cea1fee8d0762a86f
change-id: 20240305-class_cleanup-mtd-b7dfe2ea8c26

Best regards,

Signature · 1 line
Ricardo B. Marliere <[email protected]>
reviewer Reviewed-by on v1 1/1
#1 lore raw
Quoted 6 lines · Ricardo B. Marliere

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 ubi_class structure to be declared at build time placing it into read-only memory, instead of having to be dynamically allocated at boot time.

Quoted 7 lines
---
  drivers/mtd/ubi/build.c | 2 +-
  drivers/mtd/ubi/ubi.h   | 2 +-
  2 files changed, 2 insertions(+), 2 deletions(-)
Quoted 34 lines
drivers/mtd/ubi/build.c +1 -1
index 7d4ff1193db6..1938b61e1b74 100644
@@ -111,7 +111,7 @@ static struct attribute *ubi_class_attrs[] = {
  ATTRIBUTE_GROUPS(ubi_class);
 
  /* Root UBI "class" object (corresponds to '/<sysfs>/class/ubi/') */
-struct class ubi_class = {
+const struct class ubi_class = {
  	.name		= UBI_NAME_STR,
  	.class_groups	= ubi_class_groups,
  };
drivers/mtd/ubi/ubi.h +1 -2
index 0b42bb45dd84..21c3208a9210 100644
@@ -812,7 +812,7 @@ extern struct kmem_cache *ubi_wl_entry_slab;
  extern const struct file_operations ubi_ctrl_cdev_operations;
  extern const struct file_operations ubi_cdev_operations;
  extern const struct file_operations ubi_vol_cdev_operations;
-extern struct class ubi_class;
+extern const struct class ubi_class;
  extern struct mutex ubi_devices_mutex;
  extern struct blocking_notifier_head ubi_notifiers;
 
 
---

base-commit: 77bf032528393d2dc9430b3cea1fee8d0762a86f
change-id: 20240305-class_cleanup-mtd-b7dfe2ea8c26

Best regards,

maintainer Reviewed-by on v1 1/1
#2 lore raw
In reply to Ricardo B. Marliere

Hi Ricardo,

[email protected] wrote on Tue, 05 Mar 2024 16:35:38 -0300:

Quoted 9 lines

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 ubi_class structure to be declared at build time placing it into read-only memory, instead of having to be dynamically allocated at boot time.

Thanks,
Miquèl