Received: by 2002:ab2:784b:0:b0:1fd:adc2:8405 with SMTP id m11csp216766lqp; Mon, 10 Jun 2024 01:31:25 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCXDJWdwybHOra4IRFJOWcGASwXRfjWpGrmvaR2wI0M064wlPBkBpjvGhJCxCi96gV8uZVF85gpPAANrhWJi/daYbPwmcxeXRyjyIp2Jjw== X-Google-Smtp-Source: AGHT+IHqkxG87qccWXasabAk2txiq5rZL31GLFwzTnFPprUQtP7ly0WRohQcE/twoO1fKYlUOv6r X-Received: by 2002:a05:6a20:96d8:b0:1b2:a346:6c8a with SMTP id adf61e73a8af0-1b2f9dee1c5mr8052286637.54.1718008285473; Mon, 10 Jun 2024 01:31:25 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1718008285; cv=pass; d=google.com; s=arc-20160816; b=NPkrWs8dEg9xhCVVWt0yB8TcHPM4yI7XvvlaJ0i3QZllNmiZrupBYz0yH+abgCWWbV LNU9MrmrpQETP0tZQ7bXtX6VOvdgFDYb1zn2UDMqF1KKldl5r101aO/tUzoPcSqavfuv 8BImLGFPopgDhGUslAtgJlgjnkqVOki2T01aXjd6vE1s8CP9JHlql/dSIsXEMcq22zsB Cpuf77jYuPg2D6VrKek1TbkGFNWxf6v7iMal13DnhHQGmNJp6FOo4wXRbbpfJRjxvPvo 0rFZLJQCEeqECJ/1MhSodYtfLbYx2Yafx4yCZad2zymPD3uADDV6HNttKFtkg/Vz1pRz ufzA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:lines:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:message-id:date:subject:cc:to :from:dkim-signature; bh=QXEl7RVzo7rKEtkrNYmt4fonjzmGu+HvB3zLozgpG4E=; fh=J20/1HIrt/eRdpolo9tR+IVWVUwIsq0l26rp3ccVsmE=; b=aYieCoKrXZQEwNbUZNOKbkp1AwCCZVV7+BaQDErkTiCFRoVMP47AEdUsHsjgnAzCEr uNTO3l0H8Sl9EeJXaS4ppVCW5lx1WYpuy79hDmG3o3h5c+gwXk6QF+lTXBJmk3+LYix9 2oG6FlMWloaGowPT6s0MS1D2+YzWucULdpb6AfUKIiwekya7E02qOcrc9Crl5qr10Npg 8tzEF5SxrYPknTS/B3ZeYO7I2pwfWhwAkMPeU+OlbZ5Cu+MoK1o2UBBjFpGDwoxFfPfF X7YfFcQwNj6Q1ARTVfD/gXkzBdOvF19xSEwcCZuzA8ruOQH0/9FG023oLUsy1yu+q2h2 odJQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=DR36WAKj; arc=pass (i=1 dkim=pass dkdomain=linuxfoundation.org); spf=pass (google.com: domain of linux-kernel+bounces-207834-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-207834-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [2604:1380:40f1:3f00::1]) by mx.google.com with ESMTPS id d2e1a72fcca58-7041aef660dsi4694882b3a.328.2024.06.10.01.31.24 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 10 Jun 2024 01:31:25 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-207834-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) client-ip=2604:1380:40f1:3f00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=DR36WAKj; arc=pass (i=1 dkim=pass dkdomain=linuxfoundation.org); spf=pass (google.com: domain of linux-kernel+bounces-207834-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-207834-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.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 sy.mirrors.kernel.org (Postfix) with ESMTPS id 132E0B21100 for ; Mon, 10 Jun 2024 08:21:11 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 0BA9C6F2E0; Mon, 10 Jun 2024 08:20:59 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="DR36WAKj" 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 27D9B57CA2; Mon, 10 Jun 2024 08:20:57 +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=1718007658; cv=none; b=gTpXkPwu5cf9rScKmrNG0KpwdmSVMENlby9V+yImG5oh9TXcBIPsHHS1JBTaVQmSRCxsSudTUIs3ULbW8bgBqanjXpEntdooivJnwE9Yne8GzPGn4qP2K3wwCE6QIgT1tcK8Vkg/shNHvjANL1QcTiEetxHAHNVvwoBHEeNpdBY= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718007658; c=relaxed/simple; bh=CAiZ3SVovdoincgpGx3yjmnj9eAa3sknXt7flqN/34E=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=r32Te9YyBNpWFKv4lVQK5vCZsCFZRYLbMEzSe2V9UWvnH0PvYRh+dhMPVWL9e3gIpHqEts+Ny48botQgTsRvTGHynlZzlYmCZE6TIFUbeUrVwPr6FugHnsFbQv7q0Di3AszQffQKvQhI7xGaG271wa0L08VLXYkmmebVoWgWN14= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=DR36WAKj; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 1CB34C4AF1C; Mon, 10 Jun 2024 08:20:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1718007657; bh=CAiZ3SVovdoincgpGx3yjmnj9eAa3sknXt7flqN/34E=; h=From:To:Cc:Subject:Date:From; b=DR36WAKj0OoO6zEjepBa0BCBBBnZa9iPb1PzgKYmT/DIDimlQqYNgiUkMox0KCWe7 /TfRZFyLj7mX+lq/kT8LlBIeavN+C9q5v0qjAxKhN3mUBJn61PbXBDcryrpkVbVD/B +ONZ22+sYH9qZG6wQTk2sqjukqF1n1AnEd/lU5QM= From: Greg Kroah-Hartman To: linux-pci@vger.kernel.org Cc: linux-kernel@vger.kernel.org, Greg Kroah-Hartman , Kurt Schwemmer , Logan Gunthorpe , Jon Mason , Dave Jiang , Allen Hubbe , Bjorn Helgaas , ntb@lists.linux.dev Subject: [PATCH] PCI: switchtec: make switchtec_class constant Date: Mon, 10 Jun 2024 10:20:53 +0200 Message-ID: <2024061053-online-unwound-b173@gregkh> X-Mailer: git-send-email 2.45.2 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Lines: 103 X-Developer-Signature: v=1; a=openpgp-sha256; l=3586; i=gregkh@linuxfoundation.org; h=from:subject:message-id; bh=CAiZ3SVovdoincgpGx3yjmnj9eAa3sknXt7flqN/34E=; b=owGbwMvMwCRo6H6F97bub03G02pJDGlp21P5bQ5tWScq+3jdjYSCa743+6ZJTljT0FOq3MI34 dPvhBM8HbEsDIJMDLJiiixftvEc3V9xSNHL0PY0zBxWJpAhDFycAjCRsByGBcdMJ5r9NunUs9Zm WnDUfq8Wg3pdIsOCjVdkZ1rY380Oqso4+/bQmy+vUjxuAwA= X-Developer-Key: i=gregkh@linuxfoundation.org; a=openpgp; fpr=F4B60CC5BF78C2214A313DCB3147D40DDB2DFB29 Content-Transfer-Encoding: 8bit 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 --- 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