From nobody Thu Apr 9 13:32:57 2026 Received: from ewsoutbound.kpnmail.nl (ewsoutbound.kpnmail.nl [195.121.94.185]) (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 9A4CA2741C9 for ; Sun, 8 Mar 2026 21:46:30 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=195.121.94.185 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773006393; cv=none; b=i9Tc42M1svsu3OlsPf0buXd6/mME44e3cwfdPDDxEP6iOx99Ojh23TTlR9WKUYnNGG6nWz0biEA0osZpzmev0BEyb6x74CNs13FBSJ9D1J1OgOyUT1vZRS145uhML3F4h4XJNxwiMvJbsl2FOxD8VTGN4vWRCoQ/utvH4M8ssbg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773006393; c=relaxed/simple; bh=0Th/Z/GOdLASAsuaahCoJHr5X2tfvX2kIlPKgk3SrEE=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=Zw4JHm8QZ50IOHvl8icB5yExlqFGyhsiQeZM3wcy9FuSmPt3R4SjQmhyGAdsm2SrS2IG5wcAp27H+mW29U15uQ3VeYz8OtbzmiUI0A5AWxc8BOOGIyfpOgMOPZzjU+abO+0JFNbMh0fXXHe7NtLwcaVK1i4sZvb/AxDFyJ3WhzQ= 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=Rf+iXjLc; arc=none smtp.client-ip=195.121.94.185 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="Rf+iXjLc" X-KPN-MessageId: 42ca8ed2-1b38-11f1-8ff1-005056999439 Received: from smtp.kpnmail.nl (unknown [10.31.155.8]) by ewsoutbound.so.kpn.org (Halon) with ESMTPS id 42ca8ed2-1b38-11f1-8ff1-005056999439; Sun, 08 Mar 2026 22:46:27 +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=d0nM3NMJSApSZY/BYBveAOgnRj3sO/ez5p7n6+qLOOw=; b=Rf+iXjLcAZ8xqz1QQinSmc7qqgH0eeMgzD8YNSOji4HLLk5YE+PqhbhebKKSA1VQ/5abjAZMzBG84 e+0V2WCjLT4QK2VKeoz4memJvL55aESvAX8TNhRdDtUbzRDkfHGR/7sTWljvLUIsUjL2SvHe9yqyi0 Am9cwQyJjOWQziXeULGcqFRMebftcOptXJ6YWoacccC3JKkgmutlley56ZPrfwL3e68TJ94RtQG7Vd y+9lsuhpB4aXNVqWjieahXI55TKtFTiNveA+FMBceRvYBIm5u3pbHlhS8Cw4urS/Fx7Wei6YgFmmOt jcL3DkurO6n+lkgzq3DiHveKfo02GgA== X-KPN-MID: 33|fnxeyDsQwFoawVkoO51YnO6zb17fsq4BeGwRvBKyWYwlzNmyg2ABJNisDpFIEkb ka1QMb1yarTAemgkQncLth+IL5cr02jQftpxOKqSqqJE= X-KPN-VerifiedSender: Yes X-CMASSUN: 33|X4Tob/CwPUbF9QQyL6HjZu3JD40t82EpG/0VlQ7+ibTG4xEWsluC4ewC5l8U1CC Td66ySa0CJyLa1OEikWK+RQ== Received: from daedalus.home (unknown [178.229.142.230]) by smtp.xs4all.nl (Halon) with ESMTPSA id 3f797210-1b38-11f1-9c04-00505699d6e5; Sun, 08 Mar 2026 22:46:27 +0100 (CET) From: Jori Koolstra To: gregkh@linuxfoundation.org, Madhavan Srinivasan , Michael Ellerman , Nicholas Piggin , "Christophe Leroy (CS GROUP)" Cc: Jori Koolstra , Haren Myneni , Srikar Dronamraju , Jonathan Greental , Kees Cook , Shrikanth Hegde , linuxppc-dev@lists.ozlabs.org (open list:LINUX FOR POWERPC (32-BIT AND 64-BIT)), linux-kernel@vger.kernel.org (open list) Subject: [PATCH v2] powerpc: vas-api: constify dynamic struct class in coproc api register Date: Sun, 8 Mar 2026 22:46:31 +0100 Message-ID: <20260308214634.1215051-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. In vas_register_coproc_api() the dynamic allocation of the struct class corresonding to the coprocessor type (right now only nx-gzip) is replaced by calling static const struct class* cop_to_class(enum vas_cop_type cop) which links the coprocessor type to the appropriate static const struct class. Compile tested only. Link: https://lore.kernel.org/all/2023040244-duffel-pushpin-f738@gregkh/ Suggested-by: Greg Kroah-Hartman Signed-off-by: Jori Koolstra --- v2: undo whitespace removal arch/powerpc/platforms/book3s/vas-api.c | 34 +++++++++++++++++++------ 1 file changed, 26 insertions(+), 8 deletions(-) diff --git a/arch/powerpc/platforms/book3s/vas-api.c b/arch/powerpc/platfor= ms/book3s/vas-api.c index ea4ffa63f043..e377981fd533 100644 --- a/arch/powerpc/platforms/book3s/vas-api.c +++ b/arch/powerpc/platforms/book3s/vas-api.c @@ -45,7 +45,7 @@ static struct coproc_dev { struct device *device; char *name; dev_t devt; - struct class *class; + const struct class *class; enum vas_cop_type cop_type; const struct vas_user_win_ops *vops; } coproc_device; @@ -599,6 +599,21 @@ static struct file_operations coproc_fops =3D { .unlocked_ioctl =3D coproc_ioctl, }; =20 +static const struct class nx_gzip_class =3D { + .name =3D "nx-gzip", + .devnode =3D coproc_devnode +}; + +static const struct class* cop_to_class(enum vas_cop_type cop) +{ + switch (cop) { + case VAS_COP_TYPE_GZIP: return &nx_gzip_class; + default: + pr_err("No device class defined for cop type %d\n", cop); + return NULL; + } +} + /* * Supporting only nx-gzip coprocessor type now, but this API code * extended to other coprocessor types later. @@ -609,6 +624,10 @@ int vas_register_coproc_api(struct module *mod, enum v= as_cop_type cop_type, { int rc =3D -EINVAL; dev_t devno; + const struct class* class =3D cop_to_class(cop_type); + + if (!class) + return rc; =20 rc =3D alloc_chrdev_region(&coproc_device.devt, 1, 1, name); if (rc) { @@ -619,13 +638,12 @@ int vas_register_coproc_api(struct module *mod, enum = vas_cop_type cop_type, pr_devel("%s device allocated, dev [%i,%i]\n", name, MAJOR(coproc_device.devt), MINOR(coproc_device.devt)); =20 - coproc_device.class =3D class_create(name); - if (IS_ERR(coproc_device.class)) { - rc =3D PTR_ERR(coproc_device.class); - pr_err("Unable to create %s class %d\n", name, rc); + rc =3D class_register(class); + if (rc) { + pr_err("Unable to register %s class %d\n", name, rc); goto err_class; } - coproc_device.class->devnode =3D coproc_devnode; + coproc_device.class =3D class; coproc_device.cop_type =3D cop_type; coproc_device.vops =3D vops; =20 @@ -654,7 +672,7 @@ int vas_register_coproc_api(struct module *mod, enum va= s_cop_type cop_type, err: cdev_del(&coproc_device.cdev); err_cdev: - class_destroy(coproc_device.class); + class_unregister(coproc_device.class); err_class: unregister_chrdev_region(coproc_device.devt, 1); return rc; @@ -668,6 +686,6 @@ void vas_unregister_coproc_api(void) devno =3D MKDEV(MAJOR(coproc_device.devt), 0); device_destroy(coproc_device.class, devno); =20 - class_destroy(coproc_device.class); + class_unregister(coproc_device.class); unregister_chrdev_region(coproc_device.devt, 1); } base-commit: d466c332e106fe666d1e2f5a24d08e308bebbfa1 --=20 2.53.0