mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] PCIE: make bus_id for PCI Express devices unique
@ 2005-11-14 17:30 Sergey Vlasov
  0 siblings, 0 replies; only message in thread
From: Sergey Vlasov @ 2005-11-14 17:30 UTC (permalink / raw)
  To: linux-pci; +Cc: linux-kernel

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

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2005-11-14 17:30 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2005-11-14 17:30 [PATCH] PCIE: make bus_id for PCI Express devices unique Sergey Vlasov

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®