Received: by 2002:ab2:784b:0:b0:1fd:adc2:8405 with SMTP id m11csp443183lqp; Mon, 10 Jun 2024 08:40:11 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCV/Vv63QnDO0oRGxjed5WexqxFZVhkV/+RAybShNsuFtZ1Y7pIdKx58289RODcF2bxdg+J3f3QW6/WD/4DLE+Ib5KYo4aLQswguBWm0Qw== X-Google-Smtp-Source: AGHT+IG9Iv3yVj4BI0HvnTuLm8/X8JmE3Qe45TuTxJ22kLIe/DukGe07UajIcbr7N4BFuMmTsdvL X-Received: by 2002:a05:651c:210b:b0:2eb:dfe9:b462 with SMTP id 38308e7fff4ca-2ebdfe9b4e7mr26925661fa.45.1718034011532; Mon, 10 Jun 2024 08:40:11 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1718034011; cv=pass; d=google.com; s=arc-20160816; b=qAn5qvc4CIRyRG0mWaxoQSJyygtmsQt2IZJW9MbwiWFF/Us3TxbJcdxZyRCZ32z/BY a24c6eEHafIZcs0VeardT69HiA5ADaAdCwZdhEd/7Lo4GnhyyPt7c09hha4LM+rH1CMF a02A7ywajDMPI9zwI7UYh2q+/PMZvDGtNV4wPzClMZgaHevh2+Ee08wbJM3GQNV0xZjc nV0+Bls7CrIPYOGfteYaKSH8BStB5b4GbJxqo8XKfIuZp8NcWEw+otWm8nhj5R2wtsdx sb9zT1/mrv29f1qslpIMI5Rfw7qOqfEMm4C2uKwimzL/TXCTfTAtR/0Dg4BAmzb4qsJU IxVQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:in-reply-to:from:content-language :references:cc:to:subject:user-agent:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:date:message-id:dkim-signature; bh=IN6SCRg+DVp9dgLbqgctyQbu4DLKQVDaG4D0Al5y+ZY=; fh=yWTzZM3H6lLpDoIBEhm6F5vuRI/vsm1kaBXe8x6z5es=; b=xXI4cQuZA+wv0nfxVzdRHV18pgZdN0l8ZsWrg+iLXw70QBYgXMiA95LZG+i1XBp/EH 9xBeKb/r6exScW+s1Ek0v4a6UySN1vI97UyDrw9t7RLKCCU76AZ6poXCTdbwKT5htwRl J5nId0vX1nlPalxb0sTylHVsFfZ6E2zD9mCj0og7wmc1uI4/ZnG+OVH+gyPJfJh1GroJ 1B7n+DiBpjfsJgX4MySmzOxqYlLNzoOlLjjWy4o0mkcMdzQAfaL5/JN61G1SAvPdAroa 1raW9++9Lyr/CdMsDfmDtC+hFW7yWB67+kakhCHluG/mW7Xs+FgVJKe7DM5Pqm64s5z+ i9dg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b="W/cDA5Mv"; arc=pass (i=1 spf=pass spfdomain=intel.com dkim=pass dkdomain=intel.com dmarc=pass fromdomain=intel.com); spf=pass (google.com: domain of linux-kernel+bounces-208490-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-208490-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id 4fb4d7f45d1cf-57aae25f918si4780227a12.508.2024.06.10.08.40.11 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 10 Jun 2024 08:40:11 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-208490-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b="W/cDA5Mv"; arc=pass (i=1 spf=pass spfdomain=intel.com dkim=pass dkdomain=intel.com dmarc=pass fromdomain=intel.com); spf=pass (google.com: domain of linux-kernel+bounces-208490-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-208490-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id C88441F27818 for ; Mon, 10 Jun 2024 15:31:23 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id F235D80BE5; Mon, 10 Jun 2024 15:30:56 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="W/cDA5Mv" Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.18]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 784E013F450; Mon, 10 Jun 2024 15:30:54 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.175.65.18 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718033456; cv=none; b=Bbw4WFSgAk/6Ro73Hz/oJVbGLru8kzhIs7LK65IhAkXxXK46LhqcXwYVk6D7bsDt/6fG2ykq2cVqJ6dWv8l185Mf6b+v+ML5p+XPVbhgPXsy7u0roJQUhrDqEy/E6lkqrQGCQvPh33uqq5kwnpQTl5veu3GUVrGHTfvdumHS0NI= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718033456; c=relaxed/simple; bh=iKyqX56r+EgSOmMQluTvLMOh9m7hcIcp9NB6Ui81e2A=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=GERjR7jmurAAjiBLD/qKi0Tw45uTGaND91V5/gs3C8p1d1G/I2Dz7kwsMLGulbfVspzqVHvsEXSbUUSutXW8TOllhZXN+zZRi19ZcsIj+rJdLOvzRBAMfLC09CEFx03b2fWctFxxuJwLFo4w0Ti6Eo8ReiUXl/MtABkMTyU6bdY= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com; spf=pass smtp.mailfrom=intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=W/cDA5Mv; arc=none smtp.client-ip=198.175.65.18 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=intel.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1718033454; x=1749569454; h=message-id:date:mime-version:subject:to:cc:references: from:in-reply-to:content-transfer-encoding; bh=iKyqX56r+EgSOmMQluTvLMOh9m7hcIcp9NB6Ui81e2A=; b=W/cDA5MvuVlgsycJPzyEVl0sJcwz7JRflyACIkiTyE77aWwvu1w8mYRp cr8GeQZK5PpEHhc5YDXrfkGTB5l8+6A8XtgmoqD/MSL6Ipb8d8MAL+4vL AE2y79PLNCbqLZB143gwgl+pneptPDRe5FVnU+rsrf3pUZEuSnY4UaZHr qPwFYmWMMgzRRojpf0jlv2ghTo0xWDu3i/c6H9a3RcHSpAC+Q6bLMavpx Jw3vidV8yAhbNE4XcupNjThS4Z7w8Stt4E+2kiLw7eiCCpJ+RF27sdvaU dVodRkbEK35xb9kjpP2aHBAqdkMLwfCmNxBQ6S7hvJuDRx7QwX44mDHYS Q==; X-CSE-ConnectionGUID: bGjccpmITCKRMQNrMIX4wg== X-CSE-MsgGUID: pOP0lA+yS2y32thDSEomrQ== X-IronPort-AV: E=McAfee;i="6600,9927,11099"; a="14854893" X-IronPort-AV: E=Sophos;i="6.08,227,1712646000"; d="scan'208";a="14854893" Received: from fmviesa001.fm.intel.com ([10.60.135.141]) by orvoesa110.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 10 Jun 2024 08:30:54 -0700 X-CSE-ConnectionGUID: OvsHo99mTbmHyP838esLMA== X-CSE-MsgGUID: cZ9jOguASvm+QrACeEky3g== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.08,227,1712646000"; d="scan'208";a="70267100" Received: from unknown (HELO [10.125.110.62]) ([10.125.110.62]) by smtpauth.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 10 Jun 2024 08:30:53 -0700 Message-ID: Date: Mon, 10 Jun 2024 08:30:52 -0700 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH] PCI: switchtec: make switchtec_class constant To: Greg Kroah-Hartman , linux-pci@vger.kernel.org Cc: linux-kernel@vger.kernel.org, Kurt Schwemmer , Logan Gunthorpe , Jon Mason , Allen Hubbe , Bjorn Helgaas , ntb@lists.linux.dev References: <2024061053-online-unwound-b173@gregkh> Content-Language: en-US From: Dave Jiang In-Reply-To: <2024061053-online-unwound-b173@gregkh> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit On 6/10/24 1:20 AM, Greg Kroah-Hartman wrote: > 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: Kurt Schwemmer > Cc: Logan Gunthorpe > Cc: Jon Mason > Cc: Dave Jiang > Cc: Allen Hubbe > Cc: Bjorn Helgaas > Cc: linux-pci@vger.kernel.org > Cc: ntb@lists.linux.dev > Signed-off-by: Greg Kroah-Hartman Reviewed-by: Dave Jiang > --- > drivers/ntb/hw/mscc/ntb_hw_switchtec.c | 2 +- > drivers/pci/switch/switchtec.c | 16 ++++++++-------- > include/linux/switchtec.h | 2 +- > 3 files changed, 10 insertions(+), 10 deletions(-) > > diff --git a/drivers/ntb/hw/mscc/ntb_hw_switchtec.c b/drivers/ntb/hw/mscc/ntb_hw_switchtec.c > index d6bbcc7b5b90..31946387badf 100644 > --- a/drivers/ntb/hw/mscc/ntb_hw_switchtec.c > +++ b/drivers/ntb/hw/mscc/ntb_hw_switchtec.c > @@ -1565,7 +1565,7 @@ static struct class_interface switchtec_interface = { > > static int __init switchtec_ntb_init(void) > { > - switchtec_interface.class = switchtec_class; > + switchtec_interface.class = &switchtec_class; > return class_interface_register(&switchtec_interface); > } > module_init(switchtec_ntb_init); > diff --git a/drivers/pci/switch/switchtec.c b/drivers/pci/switch/switchtec.c > index 5a4adf6c04cf..c7e1089ffdaf 100644 > --- a/drivers/pci/switch/switchtec.c > +++ b/drivers/pci/switch/switchtec.c > @@ -37,7 +37,9 @@ MODULE_PARM_DESC(nirqs, "number of interrupts to allocate (more may be useful fo > static dev_t switchtec_devt; > static DEFINE_IDA(switchtec_minor_ida); > > -struct class *switchtec_class; > +const struct class switchtec_class = { > + .name = "switchtec", > +}; > EXPORT_SYMBOL_GPL(switchtec_class); > > enum mrpc_state { > @@ -1363,7 +1365,7 @@ static struct switchtec_dev *stdev_create(struct pci_dev *pdev) > > dev = &stdev->dev; > device_initialize(dev); > - dev->class = switchtec_class; > + dev->class = &switchtec_class; > dev->parent = &pdev->dev; > dev->groups = switchtec_device_groups; > dev->release = stdev_release; > @@ -1851,11 +1853,9 @@ static int __init switchtec_init(void) > if (rc) > return rc; > > - switchtec_class = class_create("switchtec"); > - if (IS_ERR(switchtec_class)) { > - rc = PTR_ERR(switchtec_class); > + rc = class_register(&switchtec_class); > + if (rc) > goto err_create_class; > - } > > rc = pci_register_driver(&switchtec_pci_driver); > if (rc) > @@ -1866,7 +1866,7 @@ static int __init switchtec_init(void) > return 0; > > err_pci_register: > - class_destroy(switchtec_class); > + class_unregister(&switchtec_class); > > err_create_class: > unregister_chrdev_region(switchtec_devt, max_devices); > @@ -1878,7 +1878,7 @@ module_init(switchtec_init); > static void __exit switchtec_exit(void) > { > pci_unregister_driver(&switchtec_pci_driver); > - class_destroy(switchtec_class); > + class_unregister(&switchtec_class); > unregister_chrdev_region(switchtec_devt, max_devices); > ida_destroy(&switchtec_minor_ida); > > diff --git a/include/linux/switchtec.h b/include/linux/switchtec.h > index 8d8fac1626bd..cdb58d61c152 100644 > --- a/include/linux/switchtec.h > +++ b/include/linux/switchtec.h > @@ -521,6 +521,6 @@ static inline struct switchtec_dev *to_stdev(struct device *dev) > return container_of(dev, struct switchtec_dev, dev); > } > > -extern struct class *switchtec_class; > +extern const struct class switchtec_class; > > #endif