From nobody Thu Apr 9 16:34:37 2026 Received: from ewsoutbound.kpnmail.nl (ewsoutbound.kpnmail.nl [195.121.94.170]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 2C31E421F01 for ; Fri, 6 Mar 2026 19:06:28 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=195.121.94.170 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1772823989; cv=none; b=hrpqc/7CgyzkoL17w2ULPMsQRf206b3s0nQpa8+UkHqUlHDPp2nqmDC2WliFOeMvCDXzG9tOKTNwOA2PaleS5guGptz6kZgfYOWmBMrD5vmCw8YJpw/9zwW3pa9H51BRepcoSuBzdEQXZN+9x5Yp0OwRBIGDxzAk7RiNi6/0UkE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1772823989; c=relaxed/simple; bh=CMv+g1vfrTqXWReBv0pZIh3m84HSFZRK46E+iGjoyNk=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=EctSyZ7e9zrgfuQHXpv9dM7uDxOyg8dOMEU4ASU1EWRT7xUbol0iVJxjx2VvkgPgQVwITI3r4QLU3YRBcvePMTzccdrDW4oNyBQCyquNZLJiT5RV+yYkBxiQVyU+7s0jcYLNp3619138KrXmWRu52Zb+yJ3mof7XkVO3krJbuu8= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=xs4all.nl; spf=pass smtp.mailfrom=xs4all.nl; dkim=pass (2048-bit key) header.d=xs4all.nl header.i=@xs4all.nl header.b=Amzj5KPf; arc=none smtp.client-ip=195.121.94.170 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=xs4all.nl Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=xs4all.nl Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=xs4all.nl header.i=@xs4all.nl header.b="Amzj5KPf" X-KPN-MessageId: 8ff0c5dd-198f-11f1-8a98-005056ab378f Received: from smtp.kpnmail.nl (unknown [10.31.155.38]) by ewsoutbound.so.kpn.org (Halon) with ESMTPS id 8ff0c5dd-198f-11f1-8a98-005056ab378f; Fri, 06 Mar 2026 20:06:21 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=xs4all.nl; s=xs4all01; h=mime-version:message-id:date:subject:to:from; bh=Z56SMtLYepksDxwqSQj+YPsQI8n1P2G+SyQfrT3KX5Y=; b=Amzj5KPf9hQZUsigBlp+mgGnSMuE/889bQUl94JMKQZds5S/P4apOH1yP+29S0TQ9ap4GNrX77G9T LEDUJgn2qgt0B0BcTQ7RyqP72YCfA3YG7pySwJ5eI6iBT3DJP/uQO+SeHDXov4HYogY/tbbvyegbmI +2Zd8c02lWdtChpAEiGPi7f2RLPC6bsd0+xyynyw15KSUcMwAdjSe5byvUcuG5BBPeiQuixuYBvPzD U4lb+O5Zks+Rv/Xx54ORpHxCrwMhbqeKdzM6101n6ZZlJrFajo3+xicf76WPoPN4YZXz7o0NPdQMZH JpaIETAmP5ylwCJ0NifRP/Zk2rMYjDA== X-KPN-MID: 33|TETzoW3YXOqnoq+BQxMEQbEEC45AzIwfI40F21ptH/DKQ8dqDTVns6gzxJvsDGm i1fxN/gduJA+50rQfnRVRAoIdav2roEQ5IwxQdqKWCag= X-KPN-VerifiedSender: Yes X-CMASSUN: 33|OAYGFjakxNZ35aHuHM5GMgB+9vxGqpyZZ9oNJiAeRX0gfZtKmmt9IocLRH00bjw wHsxSIVrdLvpu6eAVfFItQQ== Received: from daedalus.home (unknown [178.229.169.227]) by smtp.xs4all.nl (Halon) with ESMTPSA id 8ce5196a-198f-11f1-a6ca-005056abf0db; Fri, 06 Mar 2026 20:06:21 +0100 (CET) From: Jori Koolstra To: Alex Williamson Cc: Jori Koolstra , Greg Kroah-Hartman , kvm@vger.kernel.org (open list:VFIO DRIVER), linux-kernel@vger.kernel.org (open list) Subject: [PATCH] vfio: replace vfio->class with a const struct class Date: Fri, 6 Mar 2026 20:06:28 +0100 Message-ID: <20260306190628.259203-1-jkoolstra@xs4all.nl> X-Mailer: git-send-email 2.53.0 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" 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 Signed-off-by: Jori Koolstra --- drivers/vfio/group.c | 23 +++++++++++------------ 1 file changed, 11 insertions(+), 12 deletions(-) diff --git a/drivers/vfio/group.c b/drivers/vfio/group.c index 4f15016d2a5f..d4a53f8c5be0 100644 --- a/drivers/vfio/group.c +++ b/drivers/vfio/group.c @@ -15,8 +15,13 @@ #include #include "vfio.h" =20 +static char *vfio_devnode(const struct device *, umode_t *); +static const struct class vfio_class =3D { + .name =3D "vfio", + .devnode =3D vfio_devnode +}; + static struct vfio { - struct class *class; struct list_head group_list; struct mutex group_lock; /* locks group_list */ struct ida group_ida; @@ -527,7 +532,7 @@ static struct vfio_group *vfio_group_alloc(struct iommu= _group *iommu_group, =20 device_initialize(&group->dev); group->dev.devt =3D MKDEV(MAJOR(vfio.group_devt), minor); - group->dev.class =3D vfio.class; + group->dev.class =3D &vfio_class; group->dev.release =3D vfio_group_release; cdev_init(&group->cdev, &vfio_group_fops); group->cdev.owner =3D THIS_MODULE; @@ -901,13 +906,9 @@ int __init vfio_group_init(void) return ret; =20 /* /dev/vfio/$GROUP */ - vfio.class =3D class_create("vfio"); - if (IS_ERR(vfio.class)) { - ret =3D PTR_ERR(vfio.class); + ret =3D class_register(&vfio_class); + if (ret) goto err_group_class; - } - - vfio.class->devnode =3D vfio_devnode; =20 ret =3D alloc_chrdev_region(&vfio.group_devt, 0, MINORMASK + 1, "vfio"); if (ret) @@ -915,8 +916,7 @@ int __init vfio_group_init(void) return 0; =20 err_alloc_chrdev: - class_destroy(vfio.class); - vfio.class =3D NULL; + class_unregister(&vfio_class); err_group_class: vfio_container_cleanup(); return ret; @@ -927,7 +927,6 @@ void vfio_group_cleanup(void) WARN_ON(!list_empty(&vfio.group_list)); ida_destroy(&vfio.group_ida); unregister_chrdev_region(vfio.group_devt, MINORMASK + 1); - class_destroy(vfio.class); - vfio.class =3D NULL; + class_unregister(&vfio_class); vfio_container_cleanup(); } base-commit: d466c332e106fe666d1e2f5a24d08e308bebbfa1 --=20 2.53.0