[PATCH] gpib: common: change gpib_class to a const struct

From: Jori Koolstra

Date: Tue Mar 03 2026 - 14:22:08 EST


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 gpib_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@xxxxxxxxxxxxxxxxxxx>
Signed-off-by: Jori Koolstra <jkoolstra@xxxxxxxxx>
---
drivers/gpib/common/gpib_os.c | 17 ++++++++++-------
1 file changed, 10 insertions(+), 7 deletions(-)

diff --git a/drivers/gpib/common/gpib_os.c b/drivers/gpib/common/gpib_os.c
index be757db993a5..0a8b981fc579 100644
--- a/drivers/gpib/common/gpib_os.c
+++ b/drivers/gpib/common/gpib_os.c
@@ -2169,10 +2169,13 @@ void init_gpib_status_queue(struct gpib_status_queue *device)
device->dropped_byte = 0;
}

-static struct class *gpib_class;
+static const struct class gpib_class = {
+ .name = "gpib_common",
+};

static int __init gpib_common_init_module(void)
{
+ int err;
int i;

pr_info("GPIB core driver\n");
@@ -2181,14 +2184,14 @@ static int __init gpib_common_init_module(void)
pr_err("gpib: can't get major %d\n", GPIB_CODE);
return -EIO;
}
- gpib_class = class_create("gpib_common");
- if (IS_ERR(gpib_class)) {
+ err = class_register(&gpib_class);
+ if (err) {
pr_err("gpib: failed to create gpib class\n");
unregister_chrdev(GPIB_CODE, "gpib");
- return PTR_ERR(gpib_class);
+ return err;
}
for (i = 0; i < GPIB_MAX_NUM_BOARDS; ++i)
- board_array[i].gpib_dev = device_create(gpib_class, NULL,
+ board_array[i].gpib_dev = device_create(&gpib_class, NULL,
MKDEV(GPIB_CODE, i), NULL, "gpib%i", i);

return 0;
@@ -2199,9 +2202,9 @@ static void __exit gpib_common_exit_module(void)
int i;

for (i = 0; i < GPIB_MAX_NUM_BOARDS; ++i)
- device_destroy(gpib_class, MKDEV(GPIB_CODE, i));
+ device_destroy(&gpib_class, MKDEV(GPIB_CODE, i));

- class_destroy(gpib_class);
+ class_unregister(&gpib_class);
unregister_chrdev(GPIB_CODE, "gpib");
}


base-commit: d466c332e106fe666d1e2f5a24d08e308bebbfa1
--
2.53.0