Received: by 2002:a05:7412:da14:b0:e2:908c:2ebd with SMTP id fe20csp400298rdb; Fri, 6 Oct 2023 07:00:36 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHa/ksrxPOiEe6WZdNN0DAXnwd443/a1jZvcnw7afPcgVZOODmfnalQLD7Hsr7wvu/LN8ek X-Received: by 2002:a17:90a:2cc4:b0:271:7cd6:165d with SMTP id n62-20020a17090a2cc400b002717cd6165dmr8030451pjd.26.1696600836555; Fri, 06 Oct 2023 07:00:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1696600836; cv=none; d=google.com; s=arc-20160816; b=tTRjBnfXxEZEu/BRpuYVg+y5FQxaZB6YbEWQ7AeMl+kqRpVheja/UcOVG47+2V35ch v3vPDXVY9rJlc4zKsqijaImH4SeANYTbt/X+dgNs8eI6srLi75iPgHhdcL9xyYv2uRj7 cbRZY1TpcLrddlFD0zgmzBMnAcEQDniz3BmmmH6Qj7/UYGqUX5ZTKYX86EGjCFeBrYOW yA7i5QmN14tpuS2GROMOdMeER+qSf2xbNIDrOFce7fNAlQtVlEJW5IwCz4tosaOTg00e 61VuJZKXjuGCS6CnytsT63fQ+KRUI5UKei79SYgUsqtbnvp9ZF0sRdNyKTvjChHbCL31 36LA== 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 23.128.96.31 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from morse.vger.email (morse.vger.email. [23.128.96.31]) by mx.google.com with ESMTPS id iq12-20020a17090afb4c00b0027408bd8420si5804849pjb.13.2023.10.06.07.00.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 06 Oct 2023 07:00:36 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.31 as permitted sender) client-ip=23.128.96.31; 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 23.128.96.31 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 morse.vger.email (Postfix) with ESMTP id 3B3448095F45; Fri, 6 Oct 2023 07:00:27 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at morse.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232418AbjJFOAU (ORCPT + 99 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 Content-Transfer-Encoding: 8bit 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 morse.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 (morse.vger.email [0.0.0.0]); Fri, 06 Oct 2023 07:00:27 -0700 (PDT) X-Spam-Level: ** 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(-) 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); -- 2.42.0