Skip to content

Commit 02fa4bc

Browse files
ivanorlov2206gregkh
authored andcommitted
oradax: make 'cl' a static const structure
Now that the driver core allows for struct class to be in read-only memory, move the 'cl' structure to be declared at build time placing it into read-only memory, instead of having to be dynamically allocated at load time. Cc: "David S. Miller" <davem@davemloft.net> Cc: Andrew Morton <akpm@linux-foundation.org> Cc: Jonathan Corbet <corbet@lwn.net> Cc: Benjamin Tissoires <benjamin.tissoires@redhat.com> Cc: "Mike Rapoport (IBM)" <rppt@kernel.org> Cc: Suren Baghdasaryan <surenb@google.com> Cc: Ivan Orlov <ivan.orlov0322@gmail.com> Cc: sparclinux@vger.kernel.org Suggested-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org> Signed-off-by: Ivan Orlov <ivan.orlov0322@gmail.com> Acked-by: Sam Ravnborg <sam@ravnborg.org> Link: https://lore.kernel.org/r/20230620183446.684061-2-gregkh@linuxfoundation.org Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent fa50d6b commit 02fa4bc

1 file changed

Lines changed: 10 additions & 11 deletions

File tree

drivers/sbus/char/oradax.c

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -226,8 +226,10 @@ static int dax_ccb_info(u64 ca, struct ccb_info_result *info);
226226
static int dax_ccb_kill(u64 ca, u16 *kill_res);
227227

228228
static struct cdev c_dev;
229-
static struct class *cl;
230229
static dev_t first;
230+
static const struct class cl = {
231+
.name = DAX_NAME,
232+
};
231233

232234
static int max_ccb_version;
233235
static int dax_debug;
@@ -323,14 +325,11 @@ static int __init dax_attach(void)
323325
goto done;
324326
}
325327

326-
cl = class_create(DAX_NAME);
327-
if (IS_ERR(cl)) {
328-
dax_err("class_create failed");
329-
ret = PTR_ERR(cl);
328+
ret = class_register(&cl);
329+
if (ret)
330330
goto class_error;
331-
}
332331

333-
if (device_create(cl, NULL, first, NULL, dax_name) == NULL) {
332+
if (device_create(&cl, NULL, first, NULL, dax_name) == NULL) {
334333
dax_err("device_create failed");
335334
ret = -ENXIO;
336335
goto device_error;
@@ -347,9 +346,9 @@ static int __init dax_attach(void)
347346
goto done;
348347

349348
cdev_error:
350-
device_destroy(cl, first);
349+
device_destroy(&cl, first);
351350
device_error:
352-
class_destroy(cl);
351+
class_unregister(&cl);
353352
class_error:
354353
unregister_chrdev_region(first, 1);
355354
done:
@@ -362,8 +361,8 @@ static void __exit dax_detach(void)
362361
{
363362
pr_info("Cleaning up DAX module\n");
364363
cdev_del(&c_dev);
365-
device_destroy(cl, first);
366-
class_destroy(cl);
364+
device_destroy(&cl, first);
365+
class_unregister(&cl);
367366
unregister_chrdev_region(first, 1);
368367
}
369368
module_exit(dax_detach);

0 commit comments

Comments
 (0)