bus/pci: fix hardware IDs parsing on Windows
authorTal Shnaiderman <talshn@mellanox.com>
Sun, 23 Aug 2020 13:06:04 +0000 (16:06 +0300)
committerThomas Monjalon <thomas@monjalon.net>
Fri, 11 Sep 2020 00:01:38 +0000 (02:01 +0200)
Swap subsystem vendor id and subsystem device id.
Parse the SPDRP_HARDWAREID string with correct type values.

Fixes: b762221ac24 ("bus/pci: support Windows with bifurcated drivers")
Cc: stable@dpdk.org
Signed-off-by: Tal Shnaiderman <talshn@mellanox.com>
Acked-by: Narcisa Vasile <navasile@linux.microsoft.com>
drivers/bus/pci/windows/pci.c

index 489aa79..c80bd55 100644 (file)
@@ -270,17 +270,18 @@ static int
 parse_pci_hardware_id(const char *buf, struct rte_pci_id *pci_id)
 {
        int ids = 0;
-       uint16_t vendor_id, device_id, subvendor_id = 0;
+       uint16_t vendor_id, device_id;
+       uint32_t subvendor_id = 0;
 
-       ids = sscanf_s(buf, "PCI\\VEN_%x&DEV_%x&SUBSYS_%x", &vendor_id,
-               &device_id, &subvendor_id);
+       ids = sscanf_s(buf, "PCI\\VEN_%" PRIx16 "&DEV_%" PRIx16 "&SUBSYS_%"
+               PRIx32, &vendor_id, &device_id, &subvendor_id);
        if (ids != 3)
                return -1;
 
        pci_id->vendor_id = vendor_id;
        pci_id->device_id = device_id;
-       pci_id->subsystem_vendor_id = subvendor_id >> 16;
-       pci_id->subsystem_device_id = subvendor_id & 0xffff;
+       pci_id->subsystem_device_id = subvendor_id >> 16;
+       pci_id->subsystem_vendor_id = subvendor_id & 0xffff;
        return 0;
 }