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

Configure Feed

Select the types of activity you want to include in your feed.

most: replace cdev_component->class with a const struct class

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. Replace cdev_component->class with a const struct class and drop
the class_create() call. Compile tested only.

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>
Link: https://patch.msgid.link/20260401170043.3844117-1-jkoolstra@xs4all.nl
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

authored by

Jori Koolstra and committed by
Greg Kroah-Hartman
f7a1fec4 4dc0c899

+12 -8
+12 -8
drivers/most/most_cdev.c
··· 19 19 20 20 #define CHRDEV_REGION_SIZE 50 21 21 22 + static const struct class most_cdev_class = { 23 + .name = "most_cdev" 24 + }; 25 + 22 26 static struct cdev_component { 23 27 dev_t devno; 24 28 struct ida minor_id; 25 29 unsigned int major; 26 - struct class *class; 27 30 struct most_component cc; 28 31 } comp; 29 32 ··· 94 91 { 95 92 unsigned long flags; 96 93 97 - device_destroy(comp.class, c->devno); 94 + device_destroy(&most_cdev_class, c->devno); 98 95 cdev_del(&c->cdev); 99 96 spin_lock_irqsave(&ch_list_lock, flags); 100 97 list_del(&c->list); ··· 458 455 spin_lock_irqsave(&ch_list_lock, cl_flags); 459 456 list_add_tail(&c->list, &channel_list); 460 457 spin_unlock_irqrestore(&ch_list_lock, cl_flags); 461 - c->dev = device_create(comp.class, NULL, c->devno, NULL, "%s", name); 458 + c->dev = device_create(&most_cdev_class, NULL, c->devno, NULL, "%s", name); 462 459 463 460 if (IS_ERR(c->dev)) { 464 461 retval = PTR_ERR(c->dev); ··· 490 487 }, 491 488 }; 492 489 490 + 493 491 static int __init most_cdev_init(void) 494 492 { 495 493 int err; 496 494 497 - comp.class = class_create("most_cdev"); 498 - if (IS_ERR(comp.class)) 499 - return PTR_ERR(comp.class); 495 + err = class_register(&most_cdev_class); 496 + if (err) 497 + return err; 500 498 501 499 ida_init(&comp.minor_id); 502 500 ··· 519 515 unregister_chrdev_region(comp.devno, CHRDEV_REGION_SIZE); 520 516 dest_ida: 521 517 ida_destroy(&comp.minor_id); 522 - class_destroy(comp.class); 518 + class_unregister(&most_cdev_class); 523 519 return err; 524 520 } 525 521 ··· 536 532 } 537 533 unregister_chrdev_region(comp.devno, CHRDEV_REGION_SIZE); 538 534 ida_destroy(&comp.minor_id); 539 - class_destroy(comp.class); 535 + class_unregister(&most_cdev_class); 540 536 } 541 537 542 538 module_init(most_cdev_init);