PCIE: make bus_id for PCI Express devices unique
PATCH 1/1 PCIE: make bus_id for PCI Express devices unique
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 <[email protected]>
---
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
drivers/pci/pcie/portdrv_core.c +2 -2
@@ -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