diff options
author | Mike Lockwood <lockwood@android.com> | 2010-05-27 10:12:03 -0400 |
---|---|---|
committer | Mike Lockwood <lockwood@android.com> | 2010-06-01 22:18:04 -0400 |
commit | 203f102028c4df33c191d8cd610775eba8d5366d (patch) | |
tree | 1184940e086a665f41694fd076cbf26d86ff8204 /libusbhost/usbhost.c | |
parent | f4dd883389585aaf8fad2e586bc451295b668191 (diff) | |
download | system_core-203f102028c4df33c191d8cd610775eba8d5366d.tar.gz system_core-203f102028c4df33c191d8cd610775eba8d5366d.tar.bz2 system_core-203f102028c4df33c191d8cd610775eba8d5366d.zip |
libusbhost: Added usb_device_get_unique_id
Signed-off-by: Mike Lockwood <lockwood@android.com>
Diffstat (limited to 'libusbhost/usbhost.c')
-rw-r--r-- | libusbhost/usbhost.c | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/libusbhost/usbhost.c b/libusbhost/usbhost.c index 1084236ed..a6b086710 100644 --- a/libusbhost/usbhost.c +++ b/libusbhost/usbhost.c @@ -41,6 +41,7 @@ #include "usbhost/usbhost.h" #define USB_FS_DIR "/dev/bus/usb" +#define USB_FS_ID_SCANNER "/dev/bus/usb/%d/%d" #if 0 #define D printf @@ -243,6 +244,13 @@ const char* usb_device_get_name(struct usb_device *device) return device->dev_name; } +int usb_device_get_unique_id(struct usb_device *device) +{ + int bus = 0, dev = 0; + sscanf(device->dev_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; |