Received: by 2002:ab2:715a:0:b0:1fd:c064:50c with SMTP id l26csp72444lqm; Mon, 10 Jun 2024 13:04:46 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCVGkoY5HV827VCZod9jmRdoTJRhcHqTI6/mUI8Tnev/j9PNdbKXrBicGt4Xspf/sNK3K3Qxe+M1NohOQOH3ML9b4LH2xabrw+6rF/1CGw== X-Google-Smtp-Source: AGHT+IGvWS4REeI7v0rMRASi/krfVIgD6QdLht/FQmOJRbRrkutmI2jdIbeN414EXubxEcWKwDnC X-Received: by 2002:a17:907:2da6:b0:a6e:fc0a:efaf with SMTP id a640c23a62f3a-a6efc0af27emr499292166b.49.1718049886084; Mon, 10 Jun 2024 13:04:46 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1718049886; cv=pass; d=google.com; s=arc-20160816; b=kHWwcqowIAaTnwyALhXlbmlfxcgbTCp0Sad6wIQalVFSfn5h/v2G517cwxDIb9q1pB IV+cKaF+pD1wFo3+O/Ic3rUSsanFMV58DcHXFzm9i74Z5MwT0kRF0L1vOlccGrfhwVwc 5XIqTaPLh8FjkuLaGh+eObTp2m3jYDTAKrGPL/vdM5s49aGe3Gi7PLhjsuqigE5PCN2S cjGpE0bbPZgFP02tH64hJDKTpuN1ZvgTUBmlWiLQXG7dy9sBsQYwYcXA/lygYZa93l9t MRdsNiPZKAuvEbBUXzpgK7Vku1r4Flh+++CsBSP6QpBOsQhmB/NZBhafYI/Ks1LtFiJj 6zzw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=in-reply-to:content-disposition:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:message-id:subject:cc:to:from :date:dkim-signature; bh=Ph0He0hqSHqkHzBQnTyD6FZGis3UCg8E5nHqZ/WsAv4=; fh=A6YeLJAI7mzumoKtJqzcZ5cD0d+pO9I9jr3Y0rQfXJs=; b=zA77w+KS1z6q21GWAkyis8DfEIFWh1vMGWa2b6t5OMN/JK1RX4yAOsver7+rfpKvYy K9WThhfuJOe03BAhSOV9VS259xhlN74Oy7Gi8SXH1WVHXVWvdWusGJhu4N7Rw08boR1m wUWmoED1di47iyG1xHzAFA61Jm/fTg079/+CzhPtzoga1jRrxtqQmoOwqddm1D1vEcag OAcN+dIxFa7dtyrPzSrGxciEkqYWpvJFmowdOndbZt0efcqRJ9gSndlk4Nf79u9Lt7sL BVW9nA5mPfqgeYiCxwZuEl9TK14U5T4N4YFKEnttm8t7dhZ+ULJm3qUTo2f1hXz6dpWd WlXA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=oGGUwV6w; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-208828-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-208828-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id a640c23a62f3a-a6f110e9373si217899266b.678.2024.06.10.13.04.46 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 10 Jun 2024 13:04:46 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-208828-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=@kernel.org header.s=k20201202 header.b=oGGUwV6w; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-208828-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-208828-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org 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 9FF9D1F223E3 for ; Mon, 10 Jun 2024 20:04:45 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id A326B14F132; Mon, 10 Jun 2024 20:04:37 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="oGGUwV6w" Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 C0B64B65E; Mon, 10 Jun 2024 20:04:36 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718049876; cv=none; b=nRGeci4M4xrtJAF3mxfkDXFBhR67tiRYSoerwrOavHmRHtpCbs35ioDCjjh7KSt3KpkHnPJjfM9vropQmWHf0SSUBaeUWSKk61shsBejigfqXGBmYNypcP+cQdvvHsZtqZWAHGjAdsCbZE/5wXSYgfimM7v46BVFtU9Z4r6xcR8= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718049876; c=relaxed/simple; bh=AxmMtKgOguwKMibo2q1t63b0ArwV5cabYSTSkrpTae0=; h=Date:From:To:Cc:Subject:Message-ID:MIME-Version:Content-Type: Content-Disposition:In-Reply-To; b=X6+b5XXXv6ol+TMuUugWcbVVy/hAtv0dniF3YOXJEoLgek0DBrOsrW3mbl9AN8aDnRWGlVnbffBJs2DK9F5dfk2BVgW0B3WvDr33aI9D5sO/Dm7yaSf5RtACfZs/+RNwxf0rbXUtSEsubljWhdIoWpZ4KTGufh0Y+YRS8itOq0Y= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=oGGUwV6w; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 104A2C2BBFC; Mon, 10 Jun 2024 20:04:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1718049876; bh=AxmMtKgOguwKMibo2q1t63b0ArwV5cabYSTSkrpTae0=; h=Date:From:To:Cc:Subject:In-Reply-To:From; b=oGGUwV6wlkuuMXhIelwruH+R2JTmUX0ySl17ItKcvME4jvsDYbRhLLPL1CBRUnOBp vAMvtnQX4E0vE4xkvhRAwCEWeabV/71uwMukQeaXkHJdl3hJihemaHM9B15C6yjTEN RakU9bvu1yn5EiZAngSPVx7ABsrbQLE7WN3ZUrd6XQ00SUBsISVrcn0lBu23aMExKq sNMGnLCXM8uHLvhUqHSv1Ugl+hoyfRSBN2+6OiGldRUe5nH++0G4Bl1GkajkImJDZ+ 1YFePPaZA6Nwal0sfsZGqafwxe5pnbrlhQ/KSkBvqeGMOMOWMwcNItWUFvhI6sy5vY UXjkIBL1wsgnA== Date: Mon, 10 Jun 2024 15:04:34 -0500 From: Bjorn Helgaas To: Greg Kroah-Hartman Cc: linux-pci@vger.kernel.org, linux-kernel@vger.kernel.org, Kurt Schwemmer , Logan Gunthorpe , Jon Mason , Dave Jiang , Allen Hubbe , Bjorn Helgaas , ntb@lists.linux.dev Subject: Re: [PATCH] PCI: switchtec: make switchtec_class constant Message-ID: <20240610200434.GA958238@bhelgaas> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <2024061053-online-unwound-b173@gregkh> On Mon, Jun 10, 2024 at 10:20:53AM +0200, 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 Applied with reviewed-by from Dave and Logan to pci/switchtec for v6.11, thanks! > --- > 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 > -- > 2.45.2 >