All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] macintosh: adb: make adb_dev_class constant
@ 2024-03-05 20:13 Ricardo B. Marliere
  2024-03-13 13:19 ` Michael Ellerman
  0 siblings, 1 reply; 2+ messages in thread
From: Ricardo B. Marliere @ 2024-03-05 20:13 UTC (permalink / raw)
  To: linuxppc-dev, linux-kernel; +Cc: 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 adb_dev_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/macintosh/adb.c | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)

diff --git a/drivers/macintosh/adb.c b/drivers/macintosh/adb.c
index 057b0221f695..b0407c5fadb2 100644
--- a/drivers/macintosh/adb.c
+++ b/drivers/macintosh/adb.c
@@ -74,7 +74,9 @@ static struct adb_driver *adb_driver_list[] = {
 	NULL
 };
 
-static struct class *adb_dev_class;
+static const struct class adb_dev_class = {
+	.name = "adb",
+};
 
 static struct adb_driver *adb_controller;
 BLOCKING_NOTIFIER_HEAD(adb_client_list);
@@ -888,10 +890,10 @@ adbdev_init(void)
 		return;
 	}
 
-	adb_dev_class = class_create("adb");
-	if (IS_ERR(adb_dev_class))
+	if (class_register(&adb_dev_class))
 		return;
-	device_create(adb_dev_class, NULL, MKDEV(ADB_MAJOR, 0), NULL, "adb");
+
+	device_create(&adb_dev_class, NULL, MKDEV(ADB_MAJOR, 0), NULL, "adb");
 
 	platform_device_register(&adb_pfdev);
 	platform_driver_probe(&adb_pfdrv, adb_dummy_probe);

---
base-commit: 90d35da658da8cff0d4ecbb5113f5fac9d00eb72
change-id: 20240305-macintosh-9b027d413a05

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


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

* Re: [PATCH] macintosh: adb: make adb_dev_class constant
  2024-03-05 20:13 [PATCH] macintosh: adb: make adb_dev_class constant Ricardo B. Marliere
@ 2024-03-13 13:19 ` Michael Ellerman
  0 siblings, 0 replies; 2+ messages in thread
From: Michael Ellerman @ 2024-03-13 13:19 UTC (permalink / raw)
  To: linuxppc-dev, linux-kernel, Ricardo B. Marliere; +Cc: Greg Kroah-Hartman

On Tue, 05 Mar 2024 17:13:48 -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 adb_dev_class structure to be declared at build time
> placing it into read-only memory, instead of having to be dynamically
> allocated at boot time.
> 
> 
> [...]

Applied to powerpc/next.

[1/1] macintosh: adb: make adb_dev_class constant
      https://git.kernel.org/powerpc/c/83bc680e87292f78c6e823100e417d58a66dcb06

cheers

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

end of thread, other threads:[~2024-03-13 13:28 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-03-05 20:13 [PATCH] macintosh: adb: make adb_dev_class constant Ricardo B. Marliere
2024-03-13 13:19 ` Michael Ellerman

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.