libusbhost: add usb_device_get_unique_id_from_name()

Change-Id: Idce54fc26d0432d4dc46f605623c4960c0e8690f
Signed-off-by: Mike Lockwood <lockwood@android.com>
This commit is contained in:
Mike Lockwood 2010-07-27 19:05:33 -04:00
parent cb0d07b0e0
commit 07eb4af174
2 changed files with 9 additions and 0 deletions

View File

@ -84,6 +84,8 @@ const char* usb_device_get_name(struct usb_device *device);
*/
int usb_device_get_unique_id(struct usb_device *device);
int usb_device_get_unique_id_from_name(const char* name);
/* Returns the USB vendor ID from the device descriptor for the USB device */
uint16_t usb_device_get_vendor_id(struct usb_device *device);

View File

@ -270,6 +270,13 @@ int usb_device_get_unique_id(struct usb_device *device)
return bus * 1000 + dev;
}
int usb_device_get_unique_id_from_name(const char* name)
{
int bus = 0, dev = 0;
sscanf(name, USB_FS_ID_SCANNER, &bus, &dev);
return bus * 1000 + dev;
}
uint16_t usb_device_get_vendor_id(struct usb_device *device)
{
struct usb_device_descriptor* desc = (struct usb_device_descriptor*)device->desc;