From patchwork Tue Oct 24 11:48:35 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg KH X-Patchwork-Id: 157395 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:ce89:0:b0:403:3b70:6f57 with SMTP id p9csp1882060vqx; Tue, 24 Oct 2023 04:48:59 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEvE6IFxbax60W/STvjFu+WXbujJxeVxDjVznghfLV+YzkCRTTbIqrCiiWgCZhvT+VpdSJR X-Received: by 2002:a17:903:41c3:b0:1ca:8468:f05e with SMTP id u3-20020a17090341c300b001ca8468f05emr11019338ple.29.1698148139694; Tue, 24 Oct 2023 04:48:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1698148139; cv=none; d=google.com; s=arc-20160816; b=AedYhCT+jgiXDzqSVLq+NAB7Q7i49ANovIPeolTwDKz4OfHo09pgbNcmsQfP8xhqfu exfp0oc31SA+OoO2UfEblMSpSNnLvNJ7WFf1+DqcAGUbB9iSZy4bzHsIKzxqwec6kOlF jyMUmU+STuBQhMZ0Tei53MaXMbqrpoGjvcAylmlbSskXK/8Mbvs1GitDSSgRNNkvraMs r2my0O41hLt+OVWNy9UzLyBCuf7lWC7n7W6rPP258203mdf99TamenPUxPVzCnqrzL2H EbFggYxqoIH8pUmhixmRpzrEWGoxxbJqQIIA0JkMs8unM4ssgC61amZbOnvzHjr1QByS QwBg== 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=ytwTEDXwoBGfeewP/4/cQL13to7elTpwyEk+O3n7e6k=; fh=YKRbR53MwEIx2ucp3xxJRvecHW/1KfQ8x6RVk6NHtDM=; b=QEH91yLv/lX5/QktIBVvmoK5b1pkIlfw4DdFtLd5tSVw5G6cDxvr18bNfVKVPh0A5Y yzRREQAr260my7YmOxsX9rOWXiAFj0rT7vEXpIy2U0aGOgNkyJty696903zl6efR+Vp+ mnEWvTzBahdIS8HgUaakGyA4F7MFVkInOLV600cyTMSTzvdRhs04SoK2IcCVyT7IvpKJ 0XzoO0ChciOsvNtRY1AVawYIlhL+H1oVIi66YzqXjdygKPro3XL8AXOK/gfQz+ijemr/ X7EIDSJbS/rdQQo7YHCQSZvYu+FVR0DtEgq0dIddD2JpfaD6J2FHVVMGHCRd4kNVvCyL YIoQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=kNIK7y8E; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 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 snail.vger.email (snail.vger.email. [2620:137:e000::3:7]) by mx.google.com with ESMTPS id c7-20020a170902d48700b001b8c824e826si2148887plg.533.2023.10.24.04.48.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 24 Oct 2023 04:48:59 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) client-ip=2620:137:e000::3:7; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=kNIK7y8E; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 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 snail.vger.email (Postfix) with ESMTP id CCAE5805F0A1; Tue, 24 Oct 2023 04:48:58 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at snail.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231341AbjJXLsq (ORCPT + 26 others); Tue, 24 Oct 2023 07:48:46 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58252 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229829AbjJXLsp (ORCPT ); Tue, 24 Oct 2023 07:48:45 -0400 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2779FF9 for ; Tue, 24 Oct 2023 04:48:43 -0700 (PDT) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 6B690C433C7; Tue, 24 Oct 2023 11:48:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1698148122; bh=K1yZ5Y/kn6qVIOzgf5AlQf61xblYYAfEXDw52gcn18A=; h=From:To:Cc:Subject:Date:From; b=kNIK7y8E7xV3EQUU5BYjE4pLRg7t2qHcryORasDbY+/J4USpmA0+Qtu26NHDUeBQK pYpcA8T3dGw8x1oPwKZXpC44+4LLCYa/CaXnH+CyE9AzKGtoGAdmDWBd5PdfLMMlgc DaoXLoZyg+MfFy79mSUu8luULRPVqikoBSNPFAQ4= From: Greg Kroah-Hartman To: linuxppc-dev@lists.ozlabs.org Cc: linux-kernel@vger.kernel.org, Greg Kroah-Hartman , Frederic Barrat , Andrew Donnellan , Arnd Bergmann Subject: [PATCH] cxl: make cxl_class constant Date: Tue, 24 Oct 2023 13:48:35 +0200 Message-ID: <2023102434-haiku-uphill-0c11@gregkh> X-Mailer: git-send-email 2.42.0 MIME-Version: 1.0 Lines: 90 X-Developer-Signature: v=1; a=openpgp-sha256; l=2742; i=gregkh@linuxfoundation.org; h=from:subject:message-id; bh=K1yZ5Y/kn6qVIOzgf5AlQf61xblYYAfEXDw52gcn18A=; b=owGbwMvMwCRo6H6F97bub03G02pJDKnm64Ve7Dm24tiyzxcOBJ/TqGwN8U1eI8Z0OFQzcu3tP 6nzYr2WdMSyMAgyMciKKbJ82cZzdH/FIUUvQ9vTMHNYmUCGMHBxCsBEfnAzzPfewsi8+0CScuy2 RQuPP/mwqf7M3YcM86uE+UICTJo+yHk+m/bOg/NWTp7qQQA= X-Developer-Key: i=gregkh@linuxfoundation.org; a=openpgp; fpr=F4B60CC5BF78C2214A313DCB3147D40DDB2DFB29 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, RCVD_IN_DNSWL_BLOCKED,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net 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 (snail.vger.email [0.0.0.0]); Tue, 24 Oct 2023 04:48:58 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1780637383962598005 X-GMAIL-MSGID: 1780637383962598005 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: Frederic Barrat Cc: Andrew Donnellan Cc: Arnd Bergmann Cc: linuxppc-dev@lists.ozlabs.org Signed-off-by: Greg Kroah-Hartman Acked-by: Frederic Barrat --- drivers/misc/cxl/file.c | 21 ++++++++++----------- 1 file changed, 10 insertions(+), 11 deletions(-) diff --git a/drivers/misc/cxl/file.c b/drivers/misc/cxl/file.c index 144d1f2d78ce..012e11b959bc 100644 --- a/drivers/misc/cxl/file.c +++ b/drivers/misc/cxl/file.c @@ -38,8 +38,6 @@ static dev_t cxl_dev; -static struct class *cxl_class; - static int __afu_open(struct inode *inode, struct file *file, bool master) { struct cxl *adapter; @@ -559,7 +557,10 @@ static char *cxl_devnode(const struct device *dev, umode_t *mode) return kasprintf(GFP_KERNEL, "cxl/%s", dev_name(dev)); } -extern struct class *cxl_class; +static const struct class cxl_class = { + .name = "cxl", + .devnode = cxl_devnode, +}; static int cxl_add_chardev(struct cxl_afu *afu, dev_t devt, struct cdev *cdev, struct device **chardev, char *postfix, char *desc, @@ -575,7 +576,7 @@ static int cxl_add_chardev(struct cxl_afu *afu, dev_t devt, struct cdev *cdev, return rc; } - dev = device_create(cxl_class, &afu->dev, devt, afu, + dev = device_create(&cxl_class, &afu->dev, devt, afu, "afu%i.%i%s", afu->adapter->adapter_num, afu->slice, postfix); if (IS_ERR(dev)) { rc = PTR_ERR(dev); @@ -633,14 +634,14 @@ void cxl_chardev_afu_remove(struct cxl_afu *afu) int cxl_register_afu(struct cxl_afu *afu) { - afu->dev.class = cxl_class; + afu->dev.class = &cxl_class; return device_register(&afu->dev); } int cxl_register_adapter(struct cxl *adapter) { - adapter->dev.class = cxl_class; + adapter->dev.class = &cxl_class; /* * Future: When we support dynamically reprogramming the PSL & AFU we @@ -678,13 +679,11 @@ int __init cxl_file_init(void) pr_devel("CXL device allocated, MAJOR %i\n", MAJOR(cxl_dev)); - cxl_class = class_create("cxl"); - if (IS_ERR(cxl_class)) { + rc = class_register(&cxl_class); + if (rc) { pr_err("Unable to create CXL class\n"); - rc = PTR_ERR(cxl_class); goto err; } - cxl_class->devnode = cxl_devnode; return 0; @@ -696,5 +695,5 @@ int __init cxl_file_init(void) void cxl_file_exit(void) { unregister_chrdev_region(cxl_dev, CXL_NUM_MINORS); - class_destroy(cxl_class); + class_unregister(&cxl_class); }