Skip to content

Commit 83bc680

Browse files
rbmarlierempe
authored andcommitted
macintosh/adb: make adb_dev_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 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. Suggested-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org> Signed-off-by: "Ricardo B. Marliere" <ricardo@marliere.net> Signed-off-by: Michael Ellerman <mpe@ellerman.id.au> Link: https://msgid.link/20240305-macintosh-v1-1-9c3f4f882045@marliere.net
1 parent 35f2078 commit 83bc680

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

drivers/macintosh/adb.c

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,9 @@ static struct adb_driver *adb_driver_list[] = {
7474
NULL
7575
};
7676

77-
static struct class *adb_dev_class;
77+
static const struct class adb_dev_class = {
78+
.name = "adb",
79+
};
7880

7981
static struct adb_driver *adb_controller;
8082
BLOCKING_NOTIFIER_HEAD(adb_client_list);
@@ -888,10 +890,10 @@ adbdev_init(void)
888890
return;
889891
}
890892

891-
adb_dev_class = class_create("adb");
892-
if (IS_ERR(adb_dev_class))
893+
if (class_register(&adb_dev_class))
893894
return;
894-
device_create(adb_dev_class, NULL, MKDEV(ADB_MAJOR, 0), NULL, "adb");
895+
896+
device_create(&adb_dev_class, NULL, MKDEV(ADB_MAJOR, 0), NULL, "adb");
895897

896898
platform_device_register(&adb_pfdev);
897899
platform_driver_probe(&adb_pfdrv, adb_dummy_probe);

0 commit comments

Comments
 (0)