mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Sergey Vlasov <vsu@altlinux.ru>
To: linux-pci@atrey.karlin.mff.cuni.cz
Cc: linux-kernel@vger.kernel.org
Subject: [PATCH] PCIE: make bus_id for PCI Express devices unique
Date: Mon, 14 Nov 2005 20:30:50 +0300	[thread overview]
Message-ID: <20051114173050.GB24496@master.mivlgu.local> (raw)

The bus_id string must be unique for all devices of that bus in the
system, not just for devices with the same parent - otherwise multiple
symlinks with identical names appear in /sys/bus/pci_express/devices.

Signed-off-by: Sergey Vlasov <vsu@altlinux.ru>


---

 drivers/pci/pcie/portdrv_core.c |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)

 Here is the example of brokenness (observed with 2.6.15-rc1, 2.6.14 and
 even some earlier versions):

 /sys/bus/pci_express/devices:
 total 0
 lrwxrwxrwx  1 root root 0 Nov 14 08:45 pcie00 -> ../../../devices/pci0000:00/0000:00:0e.0/pcie00
 lrwxrwxrwx  1 root root 0 Nov 14 08:45 pcie00 -> ../../../devices/pci0000:00/0000:00:0e.0/pcie00
 lrwxrwxrwx  1 root root 0 Nov 14 08:45 pcie00 -> ../../../devices/pci0000:00/0000:00:0e.0/pcie00
 lrwxrwxrwx  1 root root 0 Nov 14 08:45 pcie00 -> ../../../devices/pci0000:00/0000:00:0e.0/pcie00
 lrwxrwxrwx  1 root root 0 Nov 14 08:45 pcie03 -> ../../../devices/pci0000:00/0000:00:0e.0/pcie03
 lrwxrwxrwx  1 root root 0 Nov 14 08:45 pcie03 -> ../../../devices/pci0000:00/0000:00:0e.0/pcie03
 lrwxrwxrwx  1 root root 0 Nov 14 08:45 pcie03 -> ../../../devices/pci0000:00/0000:00:0e.0/pcie03
 lrwxrwxrwx  1 root root 0 Nov 14 08:45 pcie03 -> ../../../devices/pci0000:00/0000:00:0e.0/pcie03

 After applying the patch this becomes:

 /sys/bus/pci_express/devices:
 total 0
 lrwxrwxrwx  1 root root 0 Nov 14 09:45 0000:00:0b.0:pcie00 -> ../../../devices/pci0000:00/0000:00:0b.0/0000:00:0b.0:pcie00
 lrwxrwxrwx  1 root root 0 Nov 14 09:45 0000:00:0b.0:pcie03 -> ../../../devices/pci0000:00/0000:00:0b.0/0000:00:0b.0:pcie03
 lrwxrwxrwx  1 root root 0 Nov 14 09:45 0000:00:0c.0:pcie00 -> ../../../devices/pci0000:00/0000:00:0c.0/0000:00:0c.0:pcie00
 lrwxrwxrwx  1 root root 0 Nov 14 09:45 0000:00:0c.0:pcie03 -> ../../../devices/pci0000:00/0000:00:0c.0/0000:00:0c.0:pcie03
 lrwxrwxrwx  1 root root 0 Nov 14 09:45 0000:00:0d.0:pcie00 -> ../../../devices/pci0000:00/0000:00:0d.0/0000:00:0d.0:pcie00
 lrwxrwxrwx  1 root root 0 Nov 14 09:45 0000:00:0d.0:pcie03 -> ../../../devices/pci0000:00/0000:00:0d.0/0000:00:0d.0:pcie03
 lrwxrwxrwx  1 root root 0 Nov 14 09:45 0000:00:0e.0:pcie00 -> ../../../devices/pci0000:00/0000:00:0e.0/0000:00:0e.0:pcie00
 lrwxrwxrwx  1 root root 0 Nov 14 09:45 0000:00:0e.0:pcie03 -> ../../../devices/pci0000:00/0000:00:0e.0/0000:00:0e.0:pcie03

applies-to: c4c2d62da01963dd519b8a16c3959fe9531614b0
2a1f8b84baa4447b7cf091f59f5d921a47ce5f59
diff --git a/drivers/pci/pcie/portdrv_core.c b/drivers/pci/pcie/portdrv_core.c
index 467a4ce..e4e5f1e 100644
--- a/drivers/pci/pcie/portdrv_core.c
+++ b/drivers/pci/pcie/portdrv_core.c
@@ -238,8 +238,8 @@ static void pcie_device_init(struct pci_
 	device->driver = NULL;
 	device->driver_data = NULL;
 	device->release = release_pcie_device;	/* callback to free pcie dev */
-	sprintf(&device->bus_id[0], "pcie%02x",
-		get_descriptor_id(port_type, service_type));
+	snprintf(device->bus_id, sizeof(device->bus_id), "%s:pcie%02x",
+		 pci_name(parent), get_descriptor_id(port_type, service_type));
 	device->parent = &parent->dev;
 }
 
---
0.99.9.GIT

                 reply	other threads:[~2005-11-14 17:30 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=20051114173050.GB24496@master.mivlgu.local \
    --to=vsu@altlinux.ru \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pci@atrey.karlin.mff.cuni.cz \
    /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®