linux: Fix platform device PCI detection for complex bus topologies
Suppose you're in a Hyper-V guest and are trying to use PCI passthrough.
The ID_PATH that udev will construct for that looks something like
"acpi-VMBUS:00-pci-b8c8:00:00.0", and obviously looking for "pci-" in
the first four characters of that is going to not work.
Instead, strstr. I suppose it's possible you could have _multiple_ PCI
buses in the path, in which case you'd want strrstr, if that were a
thing.
(backported from commit 9acff30943
)
Signed-off-by: Adam Jackson <ajax@redhat.com>
Signed-off-by: Huacai Chen <chenhc@lemote.com>
This commit is contained in:
parent
74b7427c41
commit
5c96eb5f44
|
@ -470,7 +470,7 @@ config_udev_odev_setup_attribs(struct udev_device *udev_device, const char *path
|
||||||
config_odev_probe_proc_ptr probe_callback)
|
config_odev_probe_proc_ptr probe_callback)
|
||||||
{
|
{
|
||||||
struct OdevAttributes *attribs = config_odev_allocate_attributes();
|
struct OdevAttributes *attribs = config_odev_allocate_attributes();
|
||||||
const char *value;
|
const char *value, *str;
|
||||||
|
|
||||||
attribs->path = XNFstrdup(path);
|
attribs->path = XNFstrdup(path);
|
||||||
attribs->syspath = XNFstrdup(syspath);
|
attribs->syspath = XNFstrdup(syspath);
|
||||||
|
@ -478,8 +478,8 @@ config_udev_odev_setup_attribs(struct udev_device *udev_device, const char *path
|
||||||
attribs->minor = minor;
|
attribs->minor = minor;
|
||||||
|
|
||||||
value = udev_device_get_property_value(udev_device, "ID_PATH");
|
value = udev_device_get_property_value(udev_device, "ID_PATH");
|
||||||
if (value && !strncmp(value, "pci-", 4)) {
|
if (value && (str = strstr(value, "pci-"))) {
|
||||||
attribs->busid = XNFstrdup(value);
|
attribs->busid = XNFstrdup(str);
|
||||||
attribs->busid[3] = ':';
|
attribs->busid[3] = ':';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue