From nobody Thu Apr 9 13:38:29 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 81E8B36F424 for ; Sun, 8 Mar 2026 12:40:25 +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=1772973628; cv=none; b=aUU4aownF9BIgWXYV0kDVKPdg6+F0x4I8GNVX0wj+FLLIar1ODTj3NfX7eO9tiYniXCQ58FQnRnuoWWXzdJZChfs++i44ffRxmgDmG6cmqpRBlRon6ZAOuSn9joesXTG0brH5n0Vbs6P9ES54JCFha2Fg1IPiExNTxDUw5Fu3SM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1772973628; c=relaxed/simple; bh=k7AIedccvI8iYlBE6P77eSu8w5VjQvpeVnRmNsCi+Z0=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=WuP31a7B54BdYmJVNPfdBIbTd1byjHgriY1xdLOUjsOpw9xT/MpfxAoOvEsGo4+DoNDR52kWMDWx3ta/F+pKOScGRratH0rtf3bhEh8D99CrLYes0SSwT2gSRGDMmLTB4+LCwUPU/PkrLARYxnZdperKxFWfLyKPzK0aXIAtQGw= 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=a3fAmZZj; 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="a3fAmZZj" X-KPN-MessageId: d14c40f8-1aeb-11f1-8ff1-005056999439 Received: from smtp.kpnmail.nl (unknown [10.31.155.5]) by ewsoutbound.so.kpn.org (Halon) with ESMTPS id d14c40f8-1aeb-11f1-8ff1-005056999439; Sun, 08 Mar 2026 13:39:15 +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=0M5fq6GQKjdtR/P2umoJCU/F3SWygqu3KnSWN1cXy5k=; b=a3fAmZZj6/wXvn5LBG5RExIBO5M93eybes70WDkSkx9letj3iOSK5jN6zcZlChREFVTRZBly66vzr LuVg1zDVTq/DyTTrAhi5ix+ewHNME1TU2jNcihaOK8q76rd9SFFv/7YFs/7a9FtGc8e4v0G4HwkCPG sXp0Yq5ISi0fSx8eEJdyti91oCdr10GlRE0P0DSZ0SGuIuhtIMwlOsqrvsZVikCOH+ZRYqpf2hTU50 gTjl2uDWLoR6/VQ/MbvHiwxsByJYP+hz7SB3Uut9LxyxFAxkzmFSKNBU+4tKouONVeN0p/b0Atc+PE w1izppKltR/XXvT8xApRd9NQQyak7gw== X-KPN-MID: 33|EtE+IxibxxNHIpCg/T5rdQHdZr55+HdEAiuXCgaF2hlkTxhc3AJ5c/H7/Jumz7S s1zjvMtgv7E95xKR2qVjiI+cczrjsaUHHIlsIrFWoogw= X-KPN-VerifiedSender: Yes X-CMASSUN: 33|AyMyV0D977UAwUbrLBC2OmIXSSwQ5ABOwr3hmrwWDpVO/71Xl4ThChnmwRAQqOa TDzWN2gGgrBP5f7S4nEH8AA== Received: from daedalus.home (unknown [178.229.45.71]) by smtp.xs4all.nl (Halon) with ESMTPSA id ceab51e8-1aeb-11f1-8d40-00505699b758; Sun, 08 Mar 2026 13:39:15 +0100 (CET) From: Jori Koolstra To: gregkh@linuxfoundation.org, Madhavan Srinivasan , Michael Ellerman , Nicholas Piggin , "Christophe Leroy (CS GROUP)" Cc: Jori Koolstra , Srikar Dronamraju , Shrikanth Hegde , Kees Cook , Haren Myneni , linuxppc-dev@lists.ozlabs.org (open list:LINUX FOR POWERPC (32-BIT AND 64-BIT)), linux-kernel@vger.kernel.org (open list) Subject: [PATCH] powerpc: vas-api: constify dynamic struct class in coproc api register Date: Sun, 8 Mar 2026 13:39:12 +0100 Message-ID: <20260308123917.1013607-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 --- arch/powerpc/platforms/book3s/vas-api.c | 34 ++++++++++++++++----- arch/powerpc/platforms/powernv/vas-window.c | 1 - 2 files changed, 26 insertions(+), 9 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); } diff --git a/arch/powerpc/platforms/powernv/vas-window.c b/arch/powerpc/pla= tforms/powernv/vas-window.c index 9f093176b8db..34403582c895 100644 --- a/arch/powerpc/platforms/powernv/vas-window.c +++ b/arch/powerpc/platforms/powernv/vas-window.c @@ -1459,7 +1459,6 @@ static const struct vas_user_win_ops vops =3D { int vas_register_api_powernv(struct module *mod, enum vas_cop_type cop_typ= e, const char *name) { - return vas_register_coproc_api(mod, cop_type, name, &vops); } EXPORT_SYMBOL_GPL(vas_register_api_powernv); base-commit: d466c332e106fe666d1e2f5a24d08e308bebbfa1 --=20 2.53.0