DM USB: add usb_dev_path_cmp function for convenience

Comparing two USB devices' path is frequently used operation, abstract
it as an seperated function for convenience.

Tracked-On: #1893
Signed-off-by: Xiaoguang Wu <xiaoguang.wu@intel.com>
Reviewed-by: Liang Yang <liang3.yang@intel.com>
Acked-by: Yu Wang <yu1.wang@intel.com>
This commit is contained in:
Xiaoguang Wu
2018-12-12 11:50:51 +08:00
committed by wenlingz
parent 6c1ca13767
commit e5c98e6d9a
3 changed files with 13 additions and 12 deletions

View File

@@ -542,23 +542,13 @@ pci_xhci_get_native_port_index_by_path(struct pci_xhci_vdev *xdev,
struct usb_devpath *path)
{
int i;
struct usb_devpath *p;
assert(xdev);
assert(path);
for (i = 0; i < XHCI_MAX_VIRT_PORTS; i++) {
p = &xdev->native_ports[i].info.path;
if (p->bus != path->bus)
continue;
if (p->depth != path->depth)
continue;
if (memcmp(p->path, path->path, path->depth) == 0)
for (i = 0; i < XHCI_MAX_VIRT_PORTS; i++)
if (usb_dev_path_cmp(&xdev->native_ports[i].info.path, path))
return i;
}
return -1;
}