- if (func == 0 && is_pci_singlefunction(names->pcidev))
- snprintf(names->pci_path, sizeof(names->pci_path), "p%ds%d", bus, slot);
- else
- snprintf(names->pci_path, sizeof(names->pci_path), "p%ds%df%d", bus, slot, func);
+
+ /* kernel provided multi-device index */
+ attr = udev_device_get_sysattr_value(dev, "dev_id");
+ if (attr)
+ dev_id = strtol(attr, NULL, 16);
+
+ /* compose a name based on the raw kernel's PCI bus, slot numbers */
+ s = names->pci_path;
+ l = sizeof(names->pci_path);
+ if (domain > 0)
+ l = strpcpyf(&s, l, "P%d", domain);
+ l = strpcpyf(&s, l, "p%ds%d", bus, slot);
+ if (func > 0 || is_pci_multifunction(names->pcidev))
+ l = strpcpyf(&s, l, "f%d", func);
+ if (dev_id > 0)
+ l = strpcpyf(&s, l, "d%d", dev_id);
+ if (l == 0)
+ names->pci_path[0] = '\0';