Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

dibs: change dibs_class to a const struct

The class_create() call has been deprecated in favor of class_register()
as the driver core now allows for a struct class to be in read-only
memory. Change dibs_class to be a const struct class and drop the
class_create() call.

Link: https://lore.kernel.org/all/2023040244-duffel-pushpin-f738@gregkh/

Suggested-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Jori Koolstra <jkoolstra@xs4all.nl>
Reviewed-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Reviewed-by: Alexandra Winter <wintera@linux.ibm.com>
Link: https://patch.msgid.link/20260303163104.3749311-1-jkoolstra@xs4all.nl
Signed-off-by: Jakub Kicinski <kuba@kernel.org>

authored by

Jori Koolstra and committed by
Jakub Kicinski
ad3dfa80 d37f5382

+8 -6
+8 -6
drivers/dibs/dibs_main.c
··· 19 19 MODULE_DESCRIPTION("Direct Internal Buffer Sharing class"); 20 20 MODULE_LICENSE("GPL"); 21 21 22 - static struct class *dibs_class; 22 + static const struct class dibs_class = { 23 + .name = "dibs", 24 + }; 23 25 24 26 /* use an array rather a list for fast mapping: */ 25 27 static struct dibs_client *clients[MAX_DIBS_CLIENTS]; ··· 139 137 if (!dibs) 140 138 return dibs; 141 139 dibs->dev.release = dibs_dev_release; 142 - dibs->dev.class = dibs_class; 140 + dibs->dev.class = &dibs_class; 143 141 device_initialize(&dibs->dev); 144 142 145 143 return dibs; ··· 255 253 { 256 254 int rc; 257 255 258 - dibs_class = class_create("dibs"); 259 - if (IS_ERR(dibs_class)) 260 - return PTR_ERR(dibs_class); 256 + rc = class_register(&dibs_class); 257 + if (rc) 258 + return rc; 261 259 262 260 rc = dibs_loopback_init(); 263 261 if (rc) ··· 269 267 static void __exit dibs_exit(void) 270 268 { 271 269 dibs_loopback_exit(); 272 - class_destroy(dibs_class); 270 + class_unregister(&dibs_class); 273 271 } 274 272 275 273 subsys_initcall(dibs_init);