linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/2] isdn: constify struct class usage
@ 2024-03-05 20:04 Ricardo B. Marliere
  2024-03-05 20:04 ` [PATCH 1/2] isdn: mISDN: make elements_class constant Ricardo B. Marliere
                   ` (2 more replies)
  0 siblings, 3 replies; 6+ messages in thread
From: Ricardo B. Marliere @ 2024-03-05 20:04 UTC (permalink / raw)
  To: Karsten Keil
  Cc: Greg Kroah-Hartman, netdev, linux-kernel, Ricardo B. Marliere

This is a simple and straight forward cleanup series that aims to make the
class structures in isdn constant. This has been possible since 2023 [1].

[1]: https://lore.kernel.org/all/2023040248-customary-release-4aec@gregkh/

Signed-off-by: Ricardo B. Marliere <ricardo@marliere.net>
---
Ricardo B. Marliere (2):
      isdn: mISDN: make elements_class constant
      isdn: capi: make capi_class constant

 drivers/isdn/capi/capi.c          | 21 ++++++++++++---------
 drivers/isdn/mISDN/dsp_pipeline.c | 16 ++++++++++------
 2 files changed, 22 insertions(+), 15 deletions(-)
---
base-commit: 90d35da658da8cff0d4ecbb5113f5fac9d00eb72
change-id: 20240305-class_cleanup-isdn-9810c8ca3e64

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


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

* [PATCH 1/2] isdn: mISDN: make elements_class constant
  2024-03-05 20:04 [PATCH 0/2] isdn: constify struct class usage Ricardo B. Marliere
@ 2024-03-05 20:04 ` Ricardo B. Marliere
  2024-03-06 19:55   ` Simon Horman
  2024-03-05 20:04 ` [PATCH 2/2] isdn: capi: make capi_class constant Ricardo B. Marliere
  2024-03-08  5:00 ` [PATCH 0/2] isdn: constify struct class usage patchwork-bot+netdevbpf
  2 siblings, 1 reply; 6+ messages in thread
From: Ricardo B. Marliere @ 2024-03-05 20:04 UTC (permalink / raw)
  To: Karsten Keil
  Cc: Greg Kroah-Hartman, netdev, linux-kernel, 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 elements_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/isdn/mISDN/dsp_pipeline.c | 16 ++++++++++------
 1 file changed, 10 insertions(+), 6 deletions(-)

diff --git a/drivers/isdn/mISDN/dsp_pipeline.c b/drivers/isdn/mISDN/dsp_pipeline.c
index 09b72f14d4b7..b4ed0bb8ddfb 100644
--- a/drivers/isdn/mISDN/dsp_pipeline.c
+++ b/drivers/isdn/mISDN/dsp_pipeline.c
@@ -31,7 +31,9 @@ struct dsp_element_entry {
 static LIST_HEAD(dsp_elements);
 
 /* sysfs */
-static struct class *elements_class;
+static const struct class elements_class = {
+	.name = "dsp_pipeline",
+};
 
 static ssize_t
 attr_show_args(struct device *dev, struct device_attribute *attr, char *buf)
@@ -80,7 +82,7 @@ int mISDN_dsp_element_register(struct mISDN_dsp_element *elem)
 	INIT_LIST_HEAD(&entry->list);
 	entry->elem = elem;
 
-	entry->dev.class = elements_class;
+	entry->dev.class = &elements_class;
 	entry->dev.release = mISDN_dsp_dev_release;
 	dev_set_drvdata(&entry->dev, elem);
 	dev_set_name(&entry->dev, "%s", elem->name);
@@ -131,9 +133,11 @@ EXPORT_SYMBOL(mISDN_dsp_element_unregister);
 
 int dsp_pipeline_module_init(void)
 {
-	elements_class = class_create("dsp_pipeline");
-	if (IS_ERR(elements_class))
-		return PTR_ERR(elements_class);
+	int err;
+
+	err = class_register(&elements_class);
+	if (err)
+		return err;
 
 	dsp_hwec_init();
 
@@ -146,7 +150,7 @@ void dsp_pipeline_module_exit(void)
 
 	dsp_hwec_exit();
 
-	class_destroy(elements_class);
+	class_unregister(&elements_class);
 
 	list_for_each_entry_safe(entry, n, &dsp_elements, list) {
 		list_del(&entry->list);

-- 
2.43.0


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

* [PATCH 2/2] isdn: capi: make capi_class constant
  2024-03-05 20:04 [PATCH 0/2] isdn: constify struct class usage Ricardo B. Marliere
  2024-03-05 20:04 ` [PATCH 1/2] isdn: mISDN: make elements_class constant Ricardo B. Marliere
@ 2024-03-05 20:04 ` Ricardo B. Marliere
  2024-03-06 19:55   ` Simon Horman
  2024-03-08  5:00 ` [PATCH 0/2] isdn: constify struct class usage patchwork-bot+netdevbpf
  2 siblings, 1 reply; 6+ messages in thread
From: Ricardo B. Marliere @ 2024-03-05 20:04 UTC (permalink / raw)
  To: Karsten Keil
  Cc: Greg Kroah-Hartman, netdev, linux-kernel, 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 capi_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/isdn/capi/capi.c | 21 ++++++++++++---------
 1 file changed, 12 insertions(+), 9 deletions(-)

diff --git a/drivers/isdn/capi/capi.c b/drivers/isdn/capi/capi.c
index 6e80d7bd3c4d..3ed257334562 100644
--- a/drivers/isdn/capi/capi.c
+++ b/drivers/isdn/capi/capi.c
@@ -49,7 +49,9 @@ MODULE_LICENSE("GPL");
 /* -------- driver information -------------------------------------- */
 
 static DEFINE_MUTEX(capi_mutex);
-static struct class *capi_class;
+static const struct class capi_class = {
+	.name = "capi",
+};
 static int capi_major = 68;		/* allocated */
 
 module_param_named(major, capi_major, uint, 0);
@@ -1393,18 +1395,19 @@ static int __init capi_init(void)
 		kcapi_exit();
 		return major_ret;
 	}
-	capi_class = class_create("capi");
-	if (IS_ERR(capi_class)) {
+
+	ret = class_register(&capi_class);
+	if (ret) {
 		unregister_chrdev(capi_major, "capi20");
 		kcapi_exit();
-		return PTR_ERR(capi_class);
+		return ret;
 	}
 
-	device_create(capi_class, NULL, MKDEV(capi_major, 0), NULL, "capi20");
+	device_create(&capi_class, NULL, MKDEV(capi_major, 0), NULL, "capi20");
 
 	if (capinc_tty_init() < 0) {
-		device_destroy(capi_class, MKDEV(capi_major, 0));
-		class_destroy(capi_class);
+		device_destroy(&capi_class, MKDEV(capi_major, 0));
+		class_unregister(&capi_class);
 		unregister_chrdev(capi_major, "capi20");
 		kcapi_exit();
 		return -ENOMEM;
@@ -1427,8 +1430,8 @@ static void __exit capi_exit(void)
 {
 	proc_exit();
 
-	device_destroy(capi_class, MKDEV(capi_major, 0));
-	class_destroy(capi_class);
+	device_destroy(&capi_class, MKDEV(capi_major, 0));
+	class_unregister(&capi_class);
 	unregister_chrdev(capi_major, "capi20");
 
 	capinc_tty_exit();

-- 
2.43.0


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

* Re: [PATCH 1/2] isdn: mISDN: make elements_class constant
  2024-03-05 20:04 ` [PATCH 1/2] isdn: mISDN: make elements_class constant Ricardo B. Marliere
@ 2024-03-06 19:55   ` Simon Horman
  0 siblings, 0 replies; 6+ messages in thread
From: Simon Horman @ 2024-03-06 19:55 UTC (permalink / raw)
  To: Ricardo B. Marliere
  Cc: Karsten Keil, Greg Kroah-Hartman, netdev, linux-kernel

On Tue, Mar 05, 2024 at 05:04:47PM -0300, Ricardo B. Marliere wrote:
> 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 elements_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: Simon Horman <horms@kernel.org>


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

* Re: [PATCH 2/2] isdn: capi: make capi_class constant
  2024-03-05 20:04 ` [PATCH 2/2] isdn: capi: make capi_class constant Ricardo B. Marliere
@ 2024-03-06 19:55   ` Simon Horman
  0 siblings, 0 replies; 6+ messages in thread
From: Simon Horman @ 2024-03-06 19:55 UTC (permalink / raw)
  To: Ricardo B. Marliere
  Cc: Karsten Keil, Greg Kroah-Hartman, netdev, linux-kernel

On Tue, Mar 05, 2024 at 05:04:48PM -0300, Ricardo B. Marliere wrote:
> 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 capi_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: Simon Horman <horms@kernel.org>


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

* Re: [PATCH 0/2] isdn: constify struct class usage
  2024-03-05 20:04 [PATCH 0/2] isdn: constify struct class usage Ricardo B. Marliere
  2024-03-05 20:04 ` [PATCH 1/2] isdn: mISDN: make elements_class constant Ricardo B. Marliere
  2024-03-05 20:04 ` [PATCH 2/2] isdn: capi: make capi_class constant Ricardo B. Marliere
@ 2024-03-08  5:00 ` patchwork-bot+netdevbpf
  2 siblings, 0 replies; 6+ messages in thread
From: patchwork-bot+netdevbpf @ 2024-03-08  5:00 UTC (permalink / raw)
  To: Ricardo B. Marliere; +Cc: isdn, gregkh, netdev, linux-kernel

Hello:

This series was applied to netdev/net-next.git (main)
by Jakub Kicinski <kuba@kernel.org>:

On Tue, 05 Mar 2024 17:04:46 -0300 you wrote:
> This is a simple and straight forward cleanup series that aims to make the
> class structures in isdn constant. This has been possible since 2023 [1].
> 
> [1]: https://lore.kernel.org/all/2023040248-customary-release-4aec@gregkh/
> 
> Signed-off-by: Ricardo B. Marliere <ricardo@marliere.net>
> 
> [...]

Here is the summary with links:
  - [1/2] isdn: mISDN: make elements_class constant
    https://git.kernel.org/netdev/net-next/c/479b4bc867b9
  - [2/2] isdn: capi: make capi_class constant
    https://git.kernel.org/netdev/net-next/c/12fbd67ea3f4

You are awesome, thank you!
-- 
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html



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

end of thread, other threads:[~2024-03-08  5:00 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-03-05 20:04 [PATCH 0/2] isdn: constify struct class usage Ricardo B. Marliere
2024-03-05 20:04 ` [PATCH 1/2] isdn: mISDN: make elements_class constant Ricardo B. Marliere
2024-03-06 19:55   ` Simon Horman
2024-03-05 20:04 ` [PATCH 2/2] isdn: capi: make capi_class constant Ricardo B. Marliere
2024-03-06 19:55   ` Simon Horman
2024-03-08  5:00 ` [PATCH 0/2] isdn: constify struct class usage patchwork-bot+netdevbpf

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).