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

@@ -272,6 +272,16 @@ usb_dev_path(struct usb_devpath *path)
return output;
}
bool
usb_dev_path_cmp(struct usb_devpath *p1, struct usb_devpath *p2)
{
if (!p1 || !p2)
return false;
return (p1->bus == p2->bus && p1->depth == p2->depth &&
memcmp(p1->path, p2->path, p1->depth) == 0);
}
int
usb_get_hub_port_num(struct usb_devpath *path)
{