Skip to content

Commit 299af26

Browse files
rbmarliererichardweinberger
authored andcommitted
mtd: ubi: make ubi_class constant
Since commit 43a7206 ("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>
1 parent 745d9f4 commit 299af26

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

drivers/mtd/ubi/build.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ static struct attribute *ubi_class_attrs[] = {
112112
ATTRIBUTE_GROUPS(ubi_class);
113113

114114
/* Root UBI "class" object (corresponds to '/<sysfs>/class/ubi/') */
115-
struct class ubi_class = {
115+
const struct class ubi_class = {
116116
.name = UBI_NAME_STR,
117117
.class_groups = ubi_class_groups,
118118
};

drivers/mtd/ubi/ubi.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -814,7 +814,7 @@ extern struct kmem_cache *ubi_wl_entry_slab;
814814
extern const struct file_operations ubi_ctrl_cdev_operations;
815815
extern const struct file_operations ubi_cdev_operations;
816816
extern const struct file_operations ubi_vol_cdev_operations;
817-
extern struct class ubi_class;
817+
extern const struct class ubi_class;
818818
extern struct mutex ubi_devices_mutex;
819819
extern struct blocking_notifier_head ubi_notifiers;
820820

0 commit comments

Comments
 (0)