mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: "Randy.Dunlap" <rdunlap@xenotime.net>
To: lkml <linux-kernel@vger.kernel.org>
Cc: gregkh <greg@kroah.com>, akpm <akpm@osdl.org>, davej@codemonkey.org.uk
Subject: [PATCH] PCIE: create sysfs directory on first use
Date: Fri, 7 Jul 2006 16:52:38 -0700	[thread overview]
Message-ID: <20060707165238.337c7a4a.rdunlap@xenotime.net> (raw)

From: Randy Dunlap <rdunlap@xenotime.net>

Dave Jones had a question about why /sys/bus/pci_express/devices
shows up even when there are no PCI-Express devices in a system
(if the config option is enabled).
Greg KH said that it could be added on its first use.

This patch creates that directory only when a device is discovered
and added to the directory.  On my ancient P-III test system,
the directory is never added, but on my Dell D610 notebook and
other dual-core system, it is added during boot discovery.

Does the "drivers" directory need some special handling also?

Signed-off-by: Randy Dunlap <rdunlap@xenotime.net>
---
 drivers/pci/pcie/portdrv_core.c |   11 ++++++++++-
 drivers/pci/pcie/portdrv_pci.c  |    1 -
 2 files changed, 10 insertions(+), 2 deletions(-)

--- linux-2618-rc1.orig/drivers/pci/pcie/portdrv_core.c
+++ linux-2618-rc1/drivers/pci/pcie/portdrv_core.c
@@ -274,6 +274,8 @@ int pcie_port_device_probe(struct pci_de
 	return -ENODEV;
 }
 
+static int pcie_dev_registered;	/* register on first use */
+
 int pcie_port_device_register(struct pci_dev *dev)
 {
 	struct pcie_port_device_ext *p_ext;
@@ -303,6 +305,9 @@ int pcie_port_device_register(struct pci
 		struct pcie_device *child;
 
 		if (capabilities & (1 << i)) {
+			if (!pcie_dev_registered)
+				pcie_port_bus_register();
+
 			child = alloc_pcie_device(
 				dev, 		/* parent */
 				type,		/* port type */
@@ -405,11 +410,15 @@ void pcie_port_device_remove(struct pci_
 void pcie_port_bus_register(void)
 {
 	bus_register(&pcie_port_bus_type);
+	pcie_dev_registered = 1;
 }
 
 void pcie_port_bus_unregister(void)
 {
-	bus_unregister(&pcie_port_bus_type);
+	if (pcie_dev_registered) {
+		bus_unregister(&pcie_port_bus_type);
+		pcie_dev_registered = 0;
+	}
 }
 
 int pcie_port_service_register(struct pcie_port_service_driver *new)
--- linux-2618-rc1.orig/drivers/pci/pcie/portdrv_pci.c
+++ linux-2618-rc1/drivers/pci/pcie/portdrv_pci.c
@@ -129,7 +129,6 @@ static int __init pcie_portdrv_init(void
 {
 	int retval = 0;
 
-	pcie_port_bus_register();
 	retval = pci_register_driver(&pcie_portdrv);
 	if (retval)
 		pcie_port_bus_unregister();


---

             reply	other threads:[~2006-07-07 23:49 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-07-07 23:52 Randy.Dunlap [this message]
2006-07-08  0:07 ` Valdis.Kletnieks
2006-07-08  0:10 ` Andrew Morton
2006-07-08  0:17   ` Randy.Dunlap
2006-07-09  5:58   ` [PATCH] PCIE: check and return bus_register errors Randy.Dunlap

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=20060707165238.337c7a4a.rdunlap@xenotime.net \
    --to=rdunlap@xenotime.net \
    --cc=akpm@osdl.org \
    --cc=davej@codemonkey.org.uk \
    --cc=greg@kroah.com \
    --cc=linux-kernel@vger.kernel.org \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®