drivers/dibs/dibs_main.c | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-)
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.
Suggested-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Jori Koolstra <jkoolstra@xs4all.nl>
---
drivers/dibs/dibs_main.c | 14 ++++++++------
1 file changed, 8 insertions(+), 6 deletions(-)
diff --git a/drivers/dibs/dibs_main.c b/drivers/dibs/dibs_main.c
index f1816361b74d..14c3e2d84902 100644
--- a/drivers/dibs/dibs_main.c
+++ b/drivers/dibs/dibs_main.c
@@ -19,7 +19,9 @@
MODULE_DESCRIPTION("Direct Internal Buffer Sharing class");
MODULE_LICENSE("GPL");
-static struct class *dibs_class;
+static const struct class dibs_class = {
+ .name = "dibs",
+};
/* use an array rather a list for fast mapping: */
static struct dibs_client *clients[MAX_DIBS_CLIENTS];
@@ -137,7 +139,7 @@ struct dibs_dev *dibs_dev_alloc(void)
if (!dibs)
return dibs;
dibs->dev.release = dibs_dev_release;
- dibs->dev.class = dibs_class;
+ dibs->dev.class = &dibs_class;
device_initialize(&dibs->dev);
return dibs;
@@ -253,9 +255,9 @@ static int __init dibs_init(void)
{
int rc;
- dibs_class = class_create("dibs");
- if (IS_ERR(dibs_class))
- return PTR_ERR(dibs_class);
+ rc = class_register(&dibs_class);
+ if (rc)
+ return rc;
rc = dibs_loopback_init();
if (rc)
@@ -267,7 +269,7 @@ static int __init dibs_init(void)
static void __exit dibs_exit(void)
{
dibs_loopback_exit();
- class_destroy(dibs_class);
+ class_unregister(&dibs_class);
}
subsys_initcall(dibs_init);
base-commit: d466c332e106fe666d1e2f5a24d08e308bebbfa1
--
2.53.0
On Mon, Mar 02, 2026 at 05:31:03PM +0100, Jori Koolstra wrote: > 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. > > Suggested-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org> > Signed-off-by: Jori Koolstra <jkoolstra@xs4all.nl> > --- > drivers/dibs/dibs_main.c | 14 ++++++++------ > 1 file changed, 8 insertions(+), 6 deletions(-) Reviewed-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
On 02.03.26 23:54, Greg Kroah-Hartman wrote: > On Mon, Mar 02, 2026 at 05:31:03PM +0100, Jori Koolstra wrote: >> 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. >> >> Suggested-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org> >> Signed-off-by: Jori Koolstra <jkoolstra@xs4all.nl> >> --- >> drivers/dibs/dibs_main.c | 14 ++++++++------ >> 1 file changed, 8 insertions(+), 6 deletions(-) > > Reviewed-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org> Reviewed-by: Alexandra Winter <wintera@linux.ibm.com> Thank you for the patch Jori. Would you mind adding a link to explain the "as the driver core now allows"? Maybe Link: https://lore.kernel.org/all/2023040248-outrage-obsolete-5a9a@gregkh/ For my education: How could I have noticed that class_create() call has been deprecated? Is that marked somewhere somehow?
Hi Alexandra, > > Thank you for the patch Jori. > Would you mind adding a link to explain the "as the driver core now allows"? > Maybe > Link: https://lore.kernel.org/all/2023040248-outrage-obsolete-5a9a@gregkh/ > Yes, see this one indeed: https://lore.kernel.org/all/2023040244-duffel-pushpin-f738@gregkh/ > > For my education: How could I have noticed that class_create() call has been deprecated? > Is that marked somewhere somehow? > I think this is for Greg to answer, but my guess would be that you maybe could not have. I don't know if there is a formal deprecation procedure. This is just cleanup work that has been laying around for a while and some beginners like me have progressed this to gain kernel patching experience. I see that this was already being worked on in 2023. I am now removing the last references to class_create() in drivers so that the API can finally be retired. Thanks, Jori.
On 03.03.26 14:23, Jori Koolstra wrote: > Hi Alexandra, > >> >> Thank you for the patch Jori. >> Would you mind adding a link to explain the "as the driver core now allows"? >> Maybe >> Link: https://lore.kernel.org/all/2023040248-outrage-obsolete-5a9a@gregkh/ >> > > Yes, see this one indeed: > https://lore.kernel.org/all/2023040244-duffel-pushpin-f738@gregkh/ > Thank you. Would you mind sending a quick v2 with the link, so netdev maintainers can take this? But I'm also fine with taking this version.
> > Thank you. > Would you mind sending a quick v2 with the link, so netdev maintainers can take this? > Sure. How does that work with the reviewed-by tags? Do I have to add them manually to v2, or ... ?
On 03.03.26 14:47, Jori Koolstra wrote: > >> >> Thank you. >> Would you mind sending a quick v2 with the link, so netdev maintainers can take this? >> > > Sure. How does that work with the reviewed-by tags? Do I have to add them > manually to v2, or ... ? Yes, that is my understanding.
© 2016 - 2026 Red Hat, Inc.