All of lore.kernel.org
 help / color / mirror / Atom feed
From: Alexander Stein <alexander.stein@ew.tq-group.com>
To: Bjorn Helgaas <bhelgaas@google.com>
Cc: Alexander Stein <alexander.stein@ew.tq-group.com>,
	linux-pci@vger.kernel.org, linux-kernel@vger.kernel.org,
	Korneliusz Osmenda <korneliuszo@gmail.com>,
	Oliver Neukum <oneukum@suse.com>
Subject: [PATCH 2/3] PCI/sysfs: create private functions for pci_create_legacy_files/pci_create_sysfs_dev_files
Date: Thu, 27 Apr 2023 16:29:00 +0200	[thread overview]
Message-ID: <20230427142901.3570536-3-alexander.stein@ew.tq-group.com> (raw)
In-Reply-To: <20230427142901.3570536-1-alexander.stein@ew.tq-group.com>

The only difference is they don't have the check against sysfs_initialized.
This is a preparation for the sysfs init race condition fix.
No functional change intended.

Signed-off-by: Alexander Stein <alexander.stein@ew.tq-group.com>
---
 drivers/pci/pci-sysfs.c | 44 ++++++++++++++++++++++++++---------------
 1 file changed, 28 insertions(+), 16 deletions(-)

diff --git a/drivers/pci/pci-sysfs.c b/drivers/pci/pci-sysfs.c
index 289c1c17b41f..7d4733773633 100644
--- a/drivers/pci/pci-sysfs.c
+++ b/drivers/pci/pci-sysfs.c
@@ -938,24 +938,10 @@ void __weak pci_adjust_legacy_attr(struct pci_bus *b,
 {
 }
 
-/**
- * pci_create_legacy_files - create legacy I/O port and memory files
- * @b: bus to create files under
- *
- * Some platforms allow access to legacy I/O port and ISA memory space on
- * a per-bus basis.  This routine creates the files and ties them into
- * their associated read, write and mmap files from pci-sysfs.c
- *
- * On error unwind, but don't propagate the error to the caller
- * as it is ok to set up the PCI bus without these files.
- */
-void pci_create_legacy_files(struct pci_bus *b)
+static void __pci_create_legacy_files(struct pci_bus *b)
 {
 	int error;
 
-	if (!sysfs_initialized)
-		return;
-
 	b->legacy_io = kcalloc(2, sizeof(struct bin_attribute),
 			       GFP_ATOMIC);
 	if (!b->legacy_io)
@@ -998,6 +984,25 @@ void pci_create_legacy_files(struct pci_bus *b)
 	dev_warn(&b->dev, "could not create legacy I/O port and ISA memory resources in sysfs\n");
 }
 
+/**
+ * pci_create_legacy_files - create legacy I/O port and memory files
+ * @b: bus to create files under
+ *
+ * Some platforms allow access to legacy I/O port and ISA memory space on
+ * a per-bus basis.  This routine creates the files and ties them into
+ * their associated read, write and mmap files from pci-sysfs.c
+ *
+ * On error unwind, but don't propagate the error to the caller
+ * as it is ok to set up the PCI bus without these files.
+ */
+void pci_create_legacy_files(struct pci_bus *b)
+{
+	if (!sysfs_initialized)
+		return;
+
+	__pci_create_legacy_files(b);
+}
+
 void pci_remove_legacy_files(struct pci_bus *b)
 {
 	if (b->legacy_io) {
@@ -1006,6 +1011,8 @@ void pci_remove_legacy_files(struct pci_bus *b)
 		kfree(b->legacy_io); /* both are allocated here */
 	}
 }
+#else
+static void __pci_create_legacy_files(struct pci_bus *b) {}
 #endif /* HAVE_PCI_LEGACY */
 
 #if defined(HAVE_PCI_MMAP) || defined(ARCH_GENERIC_PCI_MMAP_RESOURCE)
@@ -1492,12 +1499,17 @@ static const struct attribute_group pci_dev_resource_resize_group = {
 	.is_visible = resource_resize_is_visible,
 };
 
+int __must_check __pci_create_sysfs_dev_files(struct pci_dev *pdev)
+{
+	return pci_create_resource_files(pdev);
+}
+
 int __must_check pci_create_sysfs_dev_files(struct pci_dev *pdev)
 {
 	if (!sysfs_initialized)
 		return -EACCES;
 
-	return pci_create_resource_files(pdev);
+	return __pci_create_sysfs_dev_files(pdev);
 }
 
 /**
-- 
2.34.1


  parent reply	other threads:[~2023-04-27 14:29 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-04-27 14:28 [PATCH 0/3] PCI: Fix race condition upon sysfs init Alexander Stein
2023-04-27 14:28 ` [PATCH 1/3] PCI/sysfs: sort headers alphabetically Alexander Stein
2023-04-27 14:29 ` Alexander Stein [this message]
2023-04-27 20:38   ` [PATCH 2/3] PCI/sysfs: create private functions for pci_create_legacy_files/pci_create_sysfs_dev_files kernel test robot
2023-05-07  9:05   ` kernel test robot
2023-04-27 14:29 ` [PATCH 3/3] PCI/sysfs: Fix sysfs init race condition Alexander Stein
2023-04-29  2:42   ` kernel test robot
2023-04-27 16:14 ` [PATCH 0/3] PCI: Fix race condition upon sysfs init Bjorn Helgaas

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20230427142901.3570536-3-alexander.stein@ew.tq-group.com \
    --to=alexander.stein@ew.tq-group.com \
    --cc=bhelgaas@google.com \
    --cc=korneliuszo@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pci@vger.kernel.org \
    --cc=oneukum@suse.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.