From mboxrd@z Thu Jan 1 00:00:00 1970 From: Greg Kroah-Hartman To: op-tee@lists.trustedfirmware.org Subject: Re: [PATCH] tee: make tee_class constant Date: Mon, 09 Oct 2023 12:13:21 +0200 Message-ID: <2023100952-yapping-rockiness-f1e3@gregkh> In-Reply-To: < > MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="===============8478751562878453404==" List-Id: --===============8478751562878453404== Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable On Mon, Oct 09, 2023 at 11:04:33AM +0530, Sumit Garg wrote: > On Fri, 6 Oct 2023 at 19:30, Greg Kroah-Hartman > wrote: > > > > Now that the driver core allows for struct class to be in read-only > > memory, we should make all 'class' structures declared at build time > > placing them into read-only memory, instead of having to be dynamically > > allocated at runtime. > > > > Cc: Jens Wiklander > > Cc: Sumit Garg > > Signed-off-by: Greg Kroah-Hartman > > --- > > drivers/tee/tee_core.c | 21 +++++++++++---------- > > 1 file changed, 11 insertions(+), 10 deletions(-) > > >=20 > Apart from nit below, feel free to add: >=20 > Reviewed-by: Sumit Garg >=20 > > diff --git a/drivers/tee/tee_core.c b/drivers/tee/tee_core.c > > index 0eb342de0b00..5ddfd5d9ac7f 100644 > > --- a/drivers/tee/tee_core.c > > +++ b/drivers/tee/tee_core.c > > @@ -40,7 +40,10 @@ static const uuid_t tee_client_uuid_ns =3D UUID_INIT(0= x58ac9ca0, 0x2086, 0x4683, > > static DECLARE_BITMAP(dev_mask, TEE_NUM_DEVICES); > > static DEFINE_SPINLOCK(driver_lock); > > > > -static struct class *tee_class; > > +static const struct class tee_class =3D { > > + .name =3D "tee", > > +}; > > + > > static dev_t tee_devt; > > > > struct tee_context *teedev_open(struct tee_device *teedev) > > @@ -919,7 +922,7 @@ struct tee_device *tee_device_alloc(const struct tee_= desc *teedesc, > > teedesc->flags & TEE_DESC_PRIVILEGED ? "priv" : "", > > teedev->id - offs); > > > > - teedev->dev.class =3D tee_class; > > + teedev->dev.class =3D &tee_class; > > teedev->dev.release =3D tee_release_device; > > teedev->dev.parent =3D dev; > > > > @@ -1112,7 +1115,7 @@ tee_client_open_context(struct tee_context *start, > > dev =3D &start->teedev->dev; > > > > do { > > - dev =3D class_find_device(tee_class, dev, &match_data, ma= tch_dev); > > + dev =3D class_find_device(&tee_class, dev, &match_data, m= atch_dev); > > if (!dev) { > > ctx =3D ERR_PTR(-ENOENT); > > break; > > @@ -1226,10 +1229,10 @@ static int __init tee_init(void) > > { > > int rc; > > > > - tee_class =3D class_create("tee"); > > - if (IS_ERR(tee_class)) { > > + rc =3D class_register(&tee_class); > > + if (rc) { > > pr_err("couldn't create class\n"); >=20 > nit: this error message should be updated as well. Ah, missed that, thanks! Will send a follow-up patch for that. greg k-h --===============8478751562878453404==-- From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 4DC4EE95A91 for ; Mon, 9 Oct 2023 10:13:31 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1346084AbjJIKN3 (ORCPT ); Mon, 9 Oct 2023 06:13:29 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57382 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1346124AbjJIKN0 (ORCPT ); Mon, 9 Oct 2023 06:13:26 -0400 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5D6B9AB for ; Mon, 9 Oct 2023 03:13:23 -0700 (PDT) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 96312C433C7; Mon, 9 Oct 2023 10:13:22 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1696846403; bh=YfNHX7fOB23fzO4vlatr2RpIOyGVl9c/BlM3RYmxUM0=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=zGWbOp4LMq2AOqyx8nvBJlRVXSrYX1alxYqDB91I7RieM5AMKmxjbZUBTBa1ftxlJ LcD9S5f7WlyNl5tiag2LOvW7MSBrXq2P6sao/q4PnxKlAvjbiXwCq/0PRsok2hjQiA kp3zvHLhD3O8ofKdIV91NEFLPPhCSwGy4lvsqzEY= Date: Mon, 9 Oct 2023 12:13:21 +0200 From: Greg Kroah-Hartman To: Sumit Garg Cc: op-tee@lists.trustedfirmware.org, linux-kernel@vger.kernel.org, Jens Wiklander Subject: Re: [PATCH] tee: make tee_class constant Message-ID: <2023100952-yapping-rockiness-f1e3@gregkh> References: <2023100613-lustiness-affiliate-7dcb@gregkh> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Oct 09, 2023 at 11:04:33AM +0530, Sumit Garg wrote: > On Fri, 6 Oct 2023 at 19:30, Greg Kroah-Hartman > wrote: > > > > Now that the driver core allows for struct class to be in read-only > > memory, we should make all 'class' structures declared at build time > > placing them into read-only memory, instead of having to be dynamically > > allocated at runtime. > > > > Cc: Jens Wiklander > > Cc: Sumit Garg > > Signed-off-by: Greg Kroah-Hartman > > --- > > drivers/tee/tee_core.c | 21 +++++++++++---------- > > 1 file changed, 11 insertions(+), 10 deletions(-) > > > > Apart from nit below, feel free to add: > > Reviewed-by: Sumit Garg > > > diff --git a/drivers/tee/tee_core.c b/drivers/tee/tee_core.c > > index 0eb342de0b00..5ddfd5d9ac7f 100644 > > --- a/drivers/tee/tee_core.c > > +++ b/drivers/tee/tee_core.c > > @@ -40,7 +40,10 @@ static const uuid_t tee_client_uuid_ns = UUID_INIT(0x58ac9ca0, 0x2086, 0x4683, > > static DECLARE_BITMAP(dev_mask, TEE_NUM_DEVICES); > > static DEFINE_SPINLOCK(driver_lock); > > > > -static struct class *tee_class; > > +static const struct class tee_class = { > > + .name = "tee", > > +}; > > + > > static dev_t tee_devt; > > > > struct tee_context *teedev_open(struct tee_device *teedev) > > @@ -919,7 +922,7 @@ struct tee_device *tee_device_alloc(const struct tee_desc *teedesc, > > teedesc->flags & TEE_DESC_PRIVILEGED ? "priv" : "", > > teedev->id - offs); > > > > - teedev->dev.class = tee_class; > > + teedev->dev.class = &tee_class; > > teedev->dev.release = tee_release_device; > > teedev->dev.parent = dev; > > > > @@ -1112,7 +1115,7 @@ tee_client_open_context(struct tee_context *start, > > dev = &start->teedev->dev; > > > > do { > > - dev = class_find_device(tee_class, dev, &match_data, match_dev); > > + dev = class_find_device(&tee_class, dev, &match_data, match_dev); > > if (!dev) { > > ctx = ERR_PTR(-ENOENT); > > break; > > @@ -1226,10 +1229,10 @@ static int __init tee_init(void) > > { > > int rc; > > > > - tee_class = class_create("tee"); > > - if (IS_ERR(tee_class)) { > > + rc = class_register(&tee_class); > > + if (rc) { > > pr_err("couldn't create class\n"); > > nit: this error message should be updated as well. Ah, missed that, thanks! Will send a follow-up patch for that. greg k-h