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.

vfio: replace vfio->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 vfio->class with a const struct class and drop the
class_create() call.

Compile tested and found no errors/warns in dmesg after enabling
VFIO_GROUP.

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://lore.kernel.org/r/20260306190628.259203-1-jkoolstra@xs4all.nl
Signed-off-by: Alex Williamson <alex@shazbot.org>

authored by

Jori Koolstra and committed by
Alex Williamson
5efa9a54 f1839638

+11 -12
+11 -12
drivers/vfio/group.c
··· 15 15 #include <linux/anon_inodes.h> 16 16 #include "vfio.h" 17 17 18 + static char *vfio_devnode(const struct device *, umode_t *); 19 + static const struct class vfio_class = { 20 + .name = "vfio", 21 + .devnode = vfio_devnode 22 + }; 23 + 18 24 static struct vfio { 19 - struct class *class; 20 25 struct list_head group_list; 21 26 struct mutex group_lock; /* locks group_list */ 22 27 struct ida group_ida; ··· 532 527 533 528 device_initialize(&group->dev); 534 529 group->dev.devt = MKDEV(MAJOR(vfio.group_devt), minor); 535 - group->dev.class = vfio.class; 530 + group->dev.class = &vfio_class; 536 531 group->dev.release = vfio_group_release; 537 532 cdev_init(&group->cdev, &vfio_group_fops); 538 533 group->cdev.owner = THIS_MODULE; ··· 906 901 return ret; 907 902 908 903 /* /dev/vfio/$GROUP */ 909 - vfio.class = class_create("vfio"); 910 - if (IS_ERR(vfio.class)) { 911 - ret = PTR_ERR(vfio.class); 904 + ret = class_register(&vfio_class); 905 + if (ret) 912 906 goto err_group_class; 913 - } 914 - 915 - vfio.class->devnode = vfio_devnode; 916 907 917 908 ret = alloc_chrdev_region(&vfio.group_devt, 0, MINORMASK + 1, "vfio"); 918 909 if (ret) ··· 916 915 return 0; 917 916 918 917 err_alloc_chrdev: 919 - class_destroy(vfio.class); 920 - vfio.class = NULL; 918 + class_unregister(&vfio_class); 921 919 err_group_class: 922 920 vfio_container_cleanup(); 923 921 return ret; ··· 927 927 WARN_ON(!list_empty(&vfio.group_list)); 928 928 ida_destroy(&vfio.group_ida); 929 929 unregister_chrdev_region(vfio.group_devt, MINORMASK + 1); 930 - class_destroy(vfio.class); 931 - vfio.class = NULL; 930 + class_unregister(&vfio_class); 932 931 vfio_container_cleanup(); 933 932 }