linux-mtd.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] mtd: ubi: make ubi_class constant
@ 2024-03-05 19:35 Ricardo B. Marliere
  2024-03-06  1:21 ` Zhihao Cheng
  2024-03-06  8:18 ` Miquel Raynal
  0 siblings, 2 replies; 3+ messages in thread
From: Ricardo B. Marliere @ 2024-03-05 19:35 UTC (permalink / raw)
  To: Richard Weinberger, Miquel Raynal, Vignesh Raghavendra
  Cc: linux-mtd, linux-kernel, Greg Kroah-Hartman, 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.

Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Suggested-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Ricardo B. Marliere <ricardo@marliere.net>
---
 drivers/mtd/ubi/build.c | 2 +-
 drivers/mtd/ubi/ubi.h   | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/mtd/ubi/build.c b/drivers/mtd/ubi/build.c
index 7d4ff1193db6..1938b61e1b74 100644
--- a/drivers/mtd/ubi/build.c
+++ b/drivers/mtd/ubi/build.c
@@ -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,
 };
diff --git a/drivers/mtd/ubi/ubi.h b/drivers/mtd/ubi/ubi.h
index 0b42bb45dd84..21c3208a9210 100644
--- a/drivers/mtd/ubi/ubi.h
+++ b/drivers/mtd/ubi/ubi.h
@@ -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,
-- 
Ricardo B. Marliere <ricardo@marliere.net>


______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] mtd: ubi: make ubi_class constant
  2024-03-05 19:35 [PATCH] mtd: ubi: make ubi_class constant Ricardo B. Marliere
@ 2024-03-06  1:21 ` Zhihao Cheng
  2024-03-06  8:18 ` Miquel Raynal
  1 sibling, 0 replies; 3+ messages in thread
From: Zhihao Cheng @ 2024-03-06  1:21 UTC (permalink / raw)
  To: Ricardo B. Marliere, Richard Weinberger, Miquel Raynal,
	Vignesh Raghavendra
  Cc: linux-mtd, linux-kernel, Greg Kroah-Hartman

在 2024/3/6 3:35, 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.
> 
> Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
> Suggested-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
> Signed-off-by: Ricardo B. Marliere <ricardo@marliere.net>
> ---
>   drivers/mtd/ubi/build.c | 2 +-
>   drivers/mtd/ubi/ubi.h   | 2 +-
>   2 files changed, 2 insertions(+), 2 deletions(-)

Reviewed-by: Zhihao Cheng <chengzhihao1@huawei.com>
> 
> diff --git a/drivers/mtd/ubi/build.c b/drivers/mtd/ubi/build.c
> index 7d4ff1193db6..1938b61e1b74 100644
> --- a/drivers/mtd/ubi/build.c
> +++ b/drivers/mtd/ubi/build.c
> @@ -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,
>   };
> diff --git a/drivers/mtd/ubi/ubi.h b/drivers/mtd/ubi/ubi.h
> index 0b42bb45dd84..21c3208a9210 100644
> --- a/drivers/mtd/ubi/ubi.h
> +++ b/drivers/mtd/ubi/ubi.h
> @@ -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,
> 


______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] mtd: ubi: make ubi_class constant
  2024-03-05 19:35 [PATCH] mtd: ubi: make ubi_class constant Ricardo B. Marliere
  2024-03-06  1:21 ` Zhihao Cheng
@ 2024-03-06  8:18 ` Miquel Raynal
  1 sibling, 0 replies; 3+ messages in thread
From: Miquel Raynal @ 2024-03-06  8:18 UTC (permalink / raw)
  To: Ricardo B. Marliere
  Cc: Richard Weinberger, Vignesh Raghavendra, linux-mtd, linux-kernel,
	Greg Kroah-Hartman

Hi Ricardo,

ricardo@marliere.net wrote on Tue, 05 Mar 2024 16:35:38 -0300:

> 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: Miquel Raynal <miquel.raynal@bootlin.com>

Thanks,
Miquèl

______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2024-03-06  8:18 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-03-05 19:35 [PATCH] mtd: ubi: make ubi_class constant Ricardo B. Marliere
2024-03-06  1:21 ` Zhihao Cheng
2024-03-06  8:18 ` Miquel Raynal

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).