From nobody Thu Apr 9 13:33:09 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 1438E265621 for ; Sun, 8 Mar 2026 21:49:24 +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=1773006567; cv=none; b=oyb/lfMdYZAp12ohf0p1/uI/q4tJ4j8C6Lwx3hE1j9SPliLRRbFry7DWoy9I3G1RwnAhSkxn7t99PbcnuyycsvOWZ3tbkF7+cF+ktMI5pCVqYM2XZzeorJejfkoJ1oCUqpAsax9g6Wht2csxDSM543efABDGpU2D5SKKYsuBvk0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773006567; c=relaxed/simple; bh=8eUodJoImyp3FpY1awWiZQWm9hUZMkl7VClTa58uKYc=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=E12KF90OvVeqkLfSZDA+uASR+VpuGaK6ZLWjRPHwg6e4YxzrdQWeJ47GmQSlr4jMVel/9wAw5+iqlv24ChxPt/Xw4riljhA8dwq1IUoiJz/7XzKLKBv1AN4xIulu0hdfPLCUBQWnI90+SFrIRFZB9CMFSlxP/Tyg3yH9xRDGyFs= 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=eXrOd83D; 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="eXrOd83D" X-KPN-MessageId: ab70d234-1b38-11f1-8a98-005056ab378f Received: from smtp.kpnmail.nl (unknown [10.31.155.37]) by ewsoutbound.so.kpn.org (Halon) with ESMTPS id ab70d234-1b38-11f1-8a98-005056ab378f; Sun, 08 Mar 2026 22:49:23 +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=/hD77eT0WFhDi8fkYCqVxQSPbeWfWws7rsHE8QnhqoQ=; b=eXrOd83DHK5jIx0vfFAe0m1IDqeftPLmovIVXjfIJkVVxJfthR7ZXh8dOu2/JkFLzXQzJIohN50Fy IGqqfcM+Q8TQCSylsFka0RsMku6yXdLJsV/RbMaKe7P0d4ep8LQaJL6iEhk4NOn8XCn6W/j0iLv5Ar ATCS7SMweGCbCPwYhiieHRkF7wWHkPvpbk7XTX210dIajAHQ96XKBhqG4FhVDp8Um820ZzbMFk1fyl a6gvWy9cuGIKvJdKl4hK7kXpUmmih/fuiqiP8nx7MTZ8BudiJ09+8tzfTf/3hpVQzeCg+YZIv4eT4c 214brfwQdlKWZdTCESwLw0HKny40xWg== X-KPN-MID: 33|z3L3e0rFyDUM1v+oDap6aAmV867SHMDOaNaV7jf/6+XAUdcLwO1s7Yk0cq7hrAZ qAcSlN+b8Cu5grEIIkrQbnsv8ZV0Je9mcnLpobwAHBLQ= X-KPN-VerifiedSender: Yes X-CMASSUN: 33|T6FDhkZletdXcGyERNjjjxtrbRKu9ulq1yqZMMEbVLbDY2/INX1Z6Z4fId36opD fRnUh+SzdCyGhiL57XITJow== Received: from daedalus.home (unknown [178.229.142.230]) by smtp.xs4all.nl (Halon) with ESMTPSA id a8d6e635-1b38-11f1-bdab-005056ab1411; Sun, 08 Mar 2026 22:49:23 +0100 (CET) From: Jori Koolstra To: gregkh@linuxfoundation.org, Kirti Wankhede Cc: Jori Koolstra , kvm@vger.kernel.org (open list:VFIO MEDIATED DEVICE DRIVERS), linux-kernel@vger.kernel.org (open list) Subject: [PATCH v2] vfio: mdev: replace mtty_dev->vd_class with a const struct class Date: Sun, 8 Mar 2026 22:49:39 +0100 Message-ID: <20260308214939.1215682-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 mtty_dev->vd_class with a const struct class and drop the class_create() call. Compile tested and found no errors/warns in dmesg after enabling CONFIG_VFIO and CONFIG_SAMPLE_VFIO_MDEV_MTTY. Link: https://lore.kernel.org/all/2023040244-duffel-pushpin-f738@gregkh/ Suggested-by: Greg Kroah-Hartman Signed-off-by: Jori Koolstra Acked-by: Greg Kroah-Hartman --- v2: undo whitespace reformating of struct mtty_dev samples/vfio-mdev/mtty.c | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/samples/vfio-mdev/mtty.c b/samples/vfio-mdev/mtty.c index bd92c38379b8..01a9db84c4ab 100644 --- a/samples/vfio-mdev/mtty.c +++ b/samples/vfio-mdev/mtty.c @@ -68,9 +68,12 @@ * Global Structures */ =20 +static const struct class mtty_class =3D { + .name =3D MTTY_CLASS_NAME +}; + static struct mtty_dev { dev_t vd_devt; - struct class *vd_class; struct cdev vd_cdev; struct idr vd_idr; struct device dev; @@ -1980,15 +1983,14 @@ static int __init mtty_dev_init(void) if (ret) goto err_cdev; =20 - mtty_dev.vd_class =3D class_create(MTTY_CLASS_NAME); + ret =3D class_register(&mtty_class); =20 - if (IS_ERR(mtty_dev.vd_class)) { + if (ret) { pr_err("Error: failed to register mtty_dev class\n"); - ret =3D PTR_ERR(mtty_dev.vd_class); goto err_driver; } =20 - mtty_dev.dev.class =3D mtty_dev.vd_class; + mtty_dev.dev.class =3D &mtty_class; mtty_dev.dev.release =3D mtty_device_release; dev_set_name(&mtty_dev.dev, "%s", MTTY_NAME); =20 @@ -2007,7 +2009,7 @@ static int __init mtty_dev_init(void) device_del(&mtty_dev.dev); err_put: put_device(&mtty_dev.dev); - class_destroy(mtty_dev.vd_class); + class_unregister(&mtty_class); err_driver: mdev_unregister_driver(&mtty_driver); err_cdev: @@ -2026,8 +2028,7 @@ static void __exit mtty_dev_exit(void) mdev_unregister_driver(&mtty_driver); cdev_del(&mtty_dev.vd_cdev); unregister_chrdev_region(mtty_dev.vd_devt, MINORMASK + 1); - class_destroy(mtty_dev.vd_class); - mtty_dev.vd_class =3D NULL; + class_unregister(&mtty_class); pr_info("mtty_dev: Unloaded!\n"); } =20 base-commit: d466c332e106fe666d1e2f5a24d08e308bebbfa1 --=20 2.53.0