Received: by 2002:a05:7412:251c:b0:e2:908c:2ebd with SMTP id w28csp1827476rda; Tue, 24 Oct 2023 04:48:58 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGZCtnoc7wk/GPOwvVaTLZkyPN7++LB/0oM2XiGrujSZSX9+k8ICaBjCNaSzSbVrgTciLw4 X-Received: by 2002:a17:902:f9cb:b0:1ca:87c9:d4df with SMTP id kz11-20020a170902f9cb00b001ca87c9d4dfmr8076277plb.11.1698148138024; Tue, 24 Oct 2023 04:48:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1698148138; cv=none; d=google.com; s=arc-20160816; b=YNkbJEnN8+bb4iCggN3aGeMHIkTsaxSUfrzPakyY7qB47KNW+hoRIaoYWo42mAi6lT KG9+rRDDIeITZCBbFksM5KEuAzZsMji4B7F6+OZQ9xxYgF/MvCmdCe3AE+6Ww75nEjXe KS6azAQKHWwj00XZ50byHOexv9Ts7CLtSZm5AxdTjHKzAMOqzFTd8mjdbyKzWXAlXKAG Zaz/M0S82C8UFqhZxK9kcv+Qvuvwn8MUhNGXfVWIOcmDI4D1R2fmFJcw72KoFl+OG50E i8eeJf0IHYVLA0kNSqO4/SR7h3uYeSnNoxc1cdYkpdhyM+M+7NgnhkEqM87sLf/d7BrD p9eA== 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 23.128.96.37 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 snail.vger.email (snail.vger.email. [23.128.96.37]) by mx.google.com with ESMTPS id q15-20020a17090311cf00b001b7ea20dbf2si8284320plh.224.2023.10.24.04.48.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 24 Oct 2023 04:48:58 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) client-ip=23.128.96.37; 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 23.128.96.37 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 2FDF2805F0A1; Tue, 24 Oct 2023 04:48:57 -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 S231234AbjJXLsq (ORCPT + 99 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 Content-Transfer-Encoding: 8bit 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:57 -0700 (PDT) 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 --- 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); } -- 2.42.0