]> www.infradead.org Git - users/dwmw2/linux.git/commitdiff
mtd: ubi: make ubi_class constant
authorRicardo B. Marliere <ricardo@marliere.net>
Tue, 5 Mar 2024 19:35:38 +0000 (16:35 -0300)
committerRichard Weinberger <richard@nod.at>
Fri, 12 Jul 2024 17:45:09 +0000 (19:45 +0200)
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.

Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Suggested-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Ricardo B. Marliere <ricardo@marliere.net>
Reviewed-by: Zhihao Cheng <chengzhihao1@huawei.com>
Reviewed-by: Miquel Raynal <miquel.raynal@bootlin.com>
Signed-off-by: Richard Weinberger <richard@nod.at>
drivers/mtd/ubi/build.c
drivers/mtd/ubi/ubi.h

index a7e3a6246c0e93309805c588391640936993bce5..952c80269f570799fe5b794e6d4e8e80f433c7e3 100644 (file)
@@ -112,7 +112,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,
 };
index 32009a24869e7e49584e352ef37c52bba8c2cc4c..1aead55090d0a17c2aa0f4d4fb137c7976a27df7 100644 (file)
@@ -814,7 +814,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;