From patchwork Fri Oct 6 14:00:14 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg KH X-Patchwork-Id: 149268 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:a888:0:b0:403:3b70:6f57 with SMTP id x8csp350634vqo; Fri, 6 Oct 2023 07:01:21 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEzJxp2KK1+BwB7vi4ZDZhtb8xqIGufenjZ0qua8i2Ouyfl67bJYmJX1y93wdhhQoX0HlwU X-Received: by 2002:a05:6a00:8c7:b0:68b:e710:ee9c with SMTP id s7-20020a056a0008c700b0068be710ee9cmr9996778pfu.19.1696600881295; Fri, 06 Oct 2023 07:01:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1696600881; cv=none; d=google.com; s=arc-20160816; b=XixI+hxecMW/85E9ODjSjvSxVyyCeZlo3d2APQYA/Grq/BeXq9mNU/ab3cACI5s65A +kNQrfjAYi9D+nI+trKQRQ7xdJgK+qkLoXGsR7xVy3bbmZC5ov4CdeiR0PDt4ZAxLvRQ OCeNhi6DJ1woVDOGxzk9jo65zs7Kfdj3EFIfFT3eln66KDYRyWUvkKlpJq0wsUA1WfSr fGjVtZbJ5iS+NqEzZBfHQ6oKvWaSsaMWeYnOcO6j1ulo7ydyhg7sCuOgNk2vrHibPFPf fgOxzcsv3Tt4pTPjUexO4q/59DUvFpyGhqeg0BKNALtDoGzReoHAt5TpNqsJs3ncmSZp Bhsg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:lines:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=pVtamONbAszgLTeF4SWgImSLT2FQVqf6bXurpompn+k=; fh=TfNPsliuLZUVrACrlNRozy5mGWNteoeIQlYRo5SwmH4=; b=Gv6WDoOgJpTXdgLDXuVoqzXp3PquESyys2FuaF+G03vqbgD11zkhWP1emihIbSqEze wy/BXDbefbp+SXeSXq1MIJuXFRHgh6a7Anjc9Uoc0RjoZXKmMq/8orODcPpotBYeotbq 5g6XwXGjsm0HeUWCyA6VzrJyH45vc51fafwCB7dSF16I7N9w/rtglv1xEaYeQw0r59s4 2mgCeNuzxoRRjc9uA7syqSST6pGGupF5c9viJDnDPtFJx4c+yhzJkE+DGXsMFMf36PVz GhcO28g2qrNw/ZvQiTqVwn6RVoVa25X+ciaMLjuqNqUYhyWu6QDDGpGg48OYFWjbAp5g +CDQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=VK7hsTp0; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:4 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: from howler.vger.email (howler.vger.email. [2620:137:e000::3:4]) by mx.google.com with ESMTPS id u191-20020a6279c8000000b0068fc8b33074si1479446pfc.161.2023.10.06.07.01.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 06 Oct 2023 07:01:21 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:4 as permitted sender) client-ip=2620:137:e000::3:4; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=VK7hsTp0; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:4 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by howler.vger.email (Postfix) with ESMTP id 5B79F808204D; Fri, 6 Oct 2023 07:00:36 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at howler.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232447AbjJFOAU (ORCPT + 18 others); Fri, 6 Oct 2023 10:00:20 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37916 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232357AbjJFOAT (ORCPT ); Fri, 6 Oct 2023 10:00:19 -0400 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CE9AEBB for ; Fri, 6 Oct 2023 07:00:17 -0700 (PDT) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 1A496C433C7; Fri, 6 Oct 2023 14:00:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1696600817; bh=n60Zl5/dYdqZbu0B+NBdbry8iIlOp840xx7nxoVwwvo=; h=From:To:Cc:Subject:Date:From; b=VK7hsTp0UWarjXE4myPTx9v5PwbCI7E3mpqrpGnHuzAfW3Lf7LeLzPGEBZvQbh5+t 3+chdH5S/plWueiR3gjHpuyGWrHK4tJ9h1gWfcWclwg6iEjy6woWSBQBZ1OoyTSr/L W8f/Dp2xZZs+ixlTe/uYMvDLUfTQ4udj5+l0aYro= From: Greg Kroah-Hartman To: op-tee@lists.trustedfirmware.org Cc: linux-kernel@vger.kernel.org, Greg Kroah-Hartman , Jens Wiklander , Sumit Garg Subject: [PATCH] tee: make tee_class constant Date: Fri, 6 Oct 2023 16:00:14 +0200 Message-ID: <2023100613-lustiness-affiliate-7dcb@gregkh> X-Mailer: git-send-email 2.42.0 MIME-Version: 1.0 Lines: 82 X-Developer-Signature: v=1; a=openpgp-sha256; l=2566; i=gregkh@linuxfoundation.org; h=from:subject:message-id; bh=n60Zl5/dYdqZbu0B+NBdbry8iIlOp840xx7nxoVwwvo=; b=owGbwMvMwCRo6H6F97bub03G02pJDKkKQm+DmW9IrpTaWZu1vX292vpn4c0z5ULuhH6v3j+Dp ywsykumI5aFQZCJQVZMkeXLNp6j+ysOKXoZ2p6GmcPKBDKEgYtTACZyLZRhrnD/3llKbl7e7iwL 5hhJLz8S9tvDnmHBVhdJffvVG6bNUUvWkFs/wb+nwm0mAA== X-Developer-Key: i=gregkh@linuxfoundation.org; a=openpgp; fpr=F4B60CC5BF78C2214A313DCB3147D40DDB2DFB29 X-Spam-Status: No, score=2.7 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RCVD_IN_SBL_CSS,SPF_HELO_NONE,SPF_PASS autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on howler.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (howler.vger.email [0.0.0.0]); Fri, 06 Oct 2023 07:00:36 -0700 (PDT) X-Spam-Level: ** X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1779014965757534024 X-GMAIL-MSGID: 1779014965757534024 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 Reviewed-by: Sumit Garg --- drivers/tee/tee_core.c | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) 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"); - return PTR_ERR(tee_class); + return rc; } rc = alloc_chrdev_region(&tee_devt, 0, TEE_NUM_DEVICES, "tee"); @@ -1249,8 +1252,7 @@ static int __init tee_init(void) out_unreg_chrdev: unregister_chrdev_region(tee_devt, TEE_NUM_DEVICES); out_unreg_class: - class_destroy(tee_class); - tee_class = NULL; + class_unregister(&tee_class); return rc; } @@ -1259,8 +1261,7 @@ static void __exit tee_exit(void) { bus_unregister(&tee_bus_type); unregister_chrdev_region(tee_devt, TEE_NUM_DEVICES); - class_destroy(tee_class); - tee_class = NULL; + class_unregister(&tee_class); } subsys_initcall(tee_init);