From patchwork Tue Oct 24 11:49:59 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg KH X-Patchwork-Id: 157398 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:ce89:0:b0:403:3b70:6f57 with SMTP id p9csp1882786vqx; Tue, 24 Oct 2023 04:50:49 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGuaifve7riz8t77w4woU6rW8OKyF5VNRpBpMYoNow3gaJwBt0id8jzg5GY2quqaCBOMlv0 X-Received: by 2002:a05:6358:690d:b0:168:ef9b:6c0d with SMTP id d13-20020a056358690d00b00168ef9b6c0dmr4176433rwh.32.1698148249590; Tue, 24 Oct 2023 04:50:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1698148249; cv=none; d=google.com; s=arc-20160816; b=JFBfi6euyvSJFu3Ii7zPD7Dd/aDrHR3EMweD+FMSZjCX9qs1AngHDfgTZE3X1YxwyP LGT4homEcBWgbpfWtwp/xi46Mk6Bv4ehN1VlEXlQGkZ9LQ2bD1OjBkQUxBsELfSgAzxX 7lvR4kGorVOVz+nQlMjG5AD85FinCwta6dqTPlDjWGYhlOpa2jsqSwnBCkZT+ccqCY8V v9CivRisd4Z9OOLicJN5lDEVoRRneBu5fYl1UpHPIwcCG0DmZLpyEV2XmKWZHOnnj30s FGApwLs1tAI3TnZY4vQothWhUNwr32QUyVnu96WFOC6xyK1xctOjlxMnEfJmhciMzlhP Hk1w== 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=nP8Pn8gIiS20sqgPwVxydlrCTaLJ8zUz+qMWfcHGbjw=; fh=vnh8V7vedCdXtHXZnKyF45e3c5BvBWb6LlqrEg6V8/s=; b=uPW2xhCfRZxMnLxNDENfdu/DCrt3fGXTm4bQW9pVx0d4W6hhz89EpTTT/5qlNiskYB luMEGjeOsy3VHi+De0bwzqCZ40qKdA46koAoox7OqqpoXw9Nm858e12plGaRwqMAUBm3 k1uUi8rozWCxX+wVmNfIzocyBH8jHV4YZ0gg9uk957+pz0xtC1WCTI8DPbq66GVtAXVR 8fJq+IUU4kB6eB908Uczva6P1+gLIwXBMJUPNwRaHYVEpY2Ng8biRv/zRsK/DrKr/P67 eKuvRKCzynNtqE0XuKH4BzHtcJmjW2zZ1hbtF8K9LbPXzwLzegMCI0wnrrlqCIi7uOsI m+sg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=AXiGxmFo; 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 c76-20020a63354f000000b00584a495d8efsi8363887pga.582.2023.10.24.04.50.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 24 Oct 2023 04:50:49 -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=AXiGxmFo; 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 DA297807DE17; Tue, 24 Oct 2023 04:50:20 -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 S232942AbjJXLuH (ORCPT + 26 others); Tue, 24 Oct 2023 07:50:07 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37022 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232742AbjJXLuF (ORCPT ); Tue, 24 Oct 2023 07:50:05 -0400 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A6AFDD68 for ; Tue, 24 Oct 2023 04:50:02 -0700 (PDT) Received: by smtp.kernel.org (Postfix) with ESMTPSA id D6C5BC433C8; Tue, 24 Oct 2023 11:50:01 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1698148202; bh=/di0nuchbi/scniKqa/QIzyLS/gyMwWSJ3huyvVHoTU=; h=From:To:Cc:Subject:Date:From; b=AXiGxmFohtREcmv1E7XvCwf13O44ss7wYntxcIqUOt39HWrCEtCmwmXskBRztiiDM PuIlFobNe93mWoUntxzeaRc4bsUVNiK10qIaXWPDbNVZ//bL57x+cowgOZK0AQdFaG 3ks4UwmoJR+jnl6d22gK9G48CG07r9Z5yJZHKlYI= From: Greg Kroah-Hartman To: linux-accelerators@lists.ozlabs.org Cc: linux-kernel@vger.kernel.org, Greg Kroah-Hartman , Zhangfei Gao , Zhou Wang , Arnd Bergmann Subject: [PATCH] uacce: make uacce_class constant Date: Tue, 24 Oct 2023 13:49:59 +0200 Message-ID: <2023102458-designate-vicinity-4c86@gregkh> X-Mailer: git-send-email 2.42.0 MIME-Version: 1.0 Lines: 71 X-Developer-Signature: v=1; a=openpgp-sha256; l=2210; i=gregkh@linuxfoundation.org; h=from:subject:message-id; bh=/di0nuchbi/scniKqa/QIzyLS/gyMwWSJ3huyvVHoTU=; b=owGbwMvMwCRo6H6F97bub03G02pJDKnm69NMrnaesteR5N94b0dbeW91etkX7549YkWT/B5we 0dPrrXqiGVhEGRikBVTZPmyjefo/opDil6Gtqdh5rAygQxh4OIUgIlwGzHMU7Fs/dCx5txKvrXH 1tzInXnqC1PXG4b5Xv2r43OFYnwn8e/qtDh/9mxJQDk/AA== X-Developer-Key: i=gregkh@linuxfoundation.org; a=openpgp; fpr=F4B60CC5BF78C2214A313DCB3147D40DDB2DFB29 X-Spam-Status: No, score=-0.9 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=unavailable 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]); Tue, 24 Oct 2023 04:50:20 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1780637498747589946 X-GMAIL-MSGID: 1780637498747589946 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: Zhangfei Gao Cc: Zhou Wang Cc: Arnd Bergmann Cc: linux-accelerators@lists.ozlabs.org Signed-off-by: Greg Kroah-Hartman Tested-by: Zhangfei Gao --- drivers/misc/uacce/uacce.c | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/drivers/misc/uacce/uacce.c b/drivers/misc/uacce/uacce.c index 930c252753a0..bdc2e6fda782 100644 --- a/drivers/misc/uacce/uacce.c +++ b/drivers/misc/uacce/uacce.c @@ -7,10 +7,13 @@ #include #include -static struct class *uacce_class; static dev_t uacce_devt; static DEFINE_XARRAY_ALLOC(uacce_xa); +static const struct class uacce_class = { + .name = UACCE_NAME, +}; + /* * If the parent driver or the device disappears, the queue state is invalid and * ops are not usable anymore. @@ -530,7 +533,7 @@ struct uacce_device *uacce_alloc(struct device *parent, mutex_init(&uacce->mutex); device_initialize(&uacce->dev); uacce->dev.devt = MKDEV(MAJOR(uacce_devt), uacce->dev_id); - uacce->dev.class = uacce_class; + uacce->dev.class = &uacce_class; uacce->dev.groups = uacce_dev_groups; uacce->dev.parent = uacce->parent; uacce->dev.release = uacce_release; @@ -623,13 +626,13 @@ static int __init uacce_init(void) { int ret; - uacce_class = class_create(UACCE_NAME); - if (IS_ERR(uacce_class)) - return PTR_ERR(uacce_class); + ret = class_register(&uacce_class); + if (ret) + return ret; ret = alloc_chrdev_region(&uacce_devt, 0, MINORMASK, UACCE_NAME); if (ret) - class_destroy(uacce_class); + class_unregister(&uacce_class); return ret; } @@ -637,7 +640,7 @@ static int __init uacce_init(void) static __exit void uacce_exit(void) { unregister_chrdev_region(uacce_devt, MINORMASK); - class_destroy(uacce_class); + class_unregister(&uacce_class); } subsys_initcall(uacce_init);