From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 0694D194AE6 for ; Mon, 9 Mar 2026 06:01:18 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773036079; cv=none; b=SzPQdpHFoPPsamJimOzPPdTOIG6jtZsaWVbIcDTnbGP1iBDiby6VnQXMiMFIU0TMinxowbs1L43Iz0p2LnghoNN8J0c6kakQ4HEToEhzwaIkAAy6nm50UZI8Hp/vDi6KCmQq//nnNMaCiOhsXm4b1I0W7m4clnhOdJHz1I0ISUg= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773036079; c=relaxed/simple; bh=gVxcvHJNBraLn9M5BiTJWU/1HdTbvq+6QHUIrPxzgXk=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=VOmrzTYEmYwjCZHXPqEk8H6E16i7XY9j25cRlWGBlW1SFDZzHm39YG0KOqFmJfVIoRDkKN+qLmvslU/5SgPms5wT1yh7ohF+mwAIsGIxbq4vXjQ237cfbruhXpP1NhQlH0m9/ETkHktGqdlYebzLJKFg12LOzIT1Uw6NTW6NIfM= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=15RTuOMn; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="15RTuOMn" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 063A3C4CEF7; Mon, 9 Mar 2026 06:01:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1773036078; bh=gVxcvHJNBraLn9M5BiTJWU/1HdTbvq+6QHUIrPxzgXk=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=15RTuOMn5e9UtCmYbatnqrEpDrmYSoEuuiG6YS2iMtIHowfu0e7HEWq/oFZRIWHSS +SfPyuwociimJ283zgBd62ohu7PhxSeh3A28z4Eoa8aEnC26cyvVMtYCO3JafeiPPV YEFL3ecS5neM52NaHKjfqf+PyF5Kt6S5Dn2CuLYg= Date: Mon, 9 Mar 2026 07:01:03 +0100 From: Greg KH To: Jori Koolstra Cc: Madhavan Srinivasan , Michael Ellerman , Nicholas Piggin , "Christophe Leroy (CS GROUP)" , Haren Myneni , Srikar Dronamraju , Jonathan Greental , Kees Cook , Shrikanth Hegde , "open list:LINUX FOR POWERPC (32-BIT AND 64-BIT)" , open list Subject: Re: [PATCH v2] powerpc: vas-api: constify dynamic struct class in coproc api register Message-ID: <2026030924-penniless-hermit-ffc0@gregkh> References: <20260308214634.1215051-1-jkoolstra@xs4all.nl> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20260308214634.1215051-1-jkoolstra@xs4all.nl> On Sun, Mar 08, 2026 at 10:46:31PM +0100, Jori Koolstra wrote: > 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/platforms/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 = { > .unlocked_ioctl = coproc_ioctl, > }; > > +static const struct class nx_gzip_class = { > + .name = "nx-gzip", > + .devnode = 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 vas_cop_type cop_type, > { > int rc = -EINVAL; > dev_t devno; > + const struct class* class = cop_to_class(cop_type); > + > + if (!class) > + return rc; How can this happen? This feels odd, are different types of devices being registered here? I don't see where VAS_COP_TYPE_GZIP was being tested in the original code, why add this additional logic? thanks, greg k-h