linux: Fix platform device probe for DT-based PCI
On a DT-base PCI platform, the sysfs path of vga device is like this: /sys/devices/platform/bus@10000000/1a000000.pci/pci0000:00/0000:00:11.0/0000:04:00.0. Then the ID_PATH from udev is platform-1a000000.pci-pci-0000:04:00.0 and the BusID will be pci-0000:04:00.0, which causes Xorg start fail. This is because config_udev_odev_setup_attribs() use strstr() to search the first "pci-" in ID_PATH. To fix this, we implement a strrstr() function and use it to search the last "pci-" in ID_PATH, which can get a correct BusID. Signed-off-by: Huacai Chen <chenhc@lemote.com>
This commit is contained in:
parent
591916ea9e
commit
9fbd3e43dd
|
@ -477,6 +477,31 @@ config_udev_fini(void)
|
|||
|
||||
#ifdef CONFIG_UDEV_KMS
|
||||
|
||||
/* Find the last occurrence of the needle in haystack */
|
||||
static char *strrstr(const char *haystack, const char *needle)
|
||||
{
|
||||
char *prev, *last, *tmp;
|
||||
|
||||
prev = strstr(haystack, needle);
|
||||
if (!prev)
|
||||
return NULL;
|
||||
|
||||
last = prev;
|
||||
tmp = prev + 1;
|
||||
|
||||
while (tmp) {
|
||||
last = strstr(tmp, needle);
|
||||
if (!last)
|
||||
return prev;
|
||||
else {
|
||||
prev = last;
|
||||
tmp = prev + 1;
|
||||
}
|
||||
}
|
||||
|
||||
return last;
|
||||
}
|
||||
|
||||
static void
|
||||
config_udev_odev_setup_attribs(struct udev_device *udev_device, const char *path, const char *syspath,
|
||||
int major, int minor,
|
||||
|
@ -491,7 +516,7 @@ config_udev_odev_setup_attribs(struct udev_device *udev_device, const char *path
|
|||
attribs->minor = minor;
|
||||
|
||||
value = udev_device_get_property_value(udev_device, "ID_PATH");
|
||||
if (value && (str = strstr(value, "pci-"))) {
|
||||
if (value && (str = strrstr(value, "pci-"))) {
|
||||
attribs->busid = XNFstrdup(str);
|
||||
attribs->busid[3] = ':';
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user