[Spice-devel] [PATCH usbredir v2] usbredirserver: show bus:device of the USB device if specifying vid:pid
Chen Hanxiao
chen_han_xiao at 126.com
Thu Nov 23 14:27:55 UTC 2017
At 2017-11-23 19:28:42, "Frediano Ziglio" <fziglio at redhat.com> wrote:
>>
>> From: Chen Hanxiao <chenhanxiao at gmail.com>
>>
>> We use libusb_open_device_with_vid_pid, if multiple devices
>> have the same vid:pid, it will only the first one.
>>
>> This patch will show the bus:device of the chosen one.
>>
>> Signed-off-by: Chen Hanxiao <chenhanxiao at gmail.com>
>> ---
>> v2: control output messages by verbose
>>
>> usbredirserver/usbredirserver.c | 9 +++++++++
>> 1 file changed, 9 insertions(+)
>>
>> diff --git a/usbredirserver/usbredirserver.c
>> b/usbredirserver/usbredirserver.c
>> index 13965dc..4685e0d 100644
>> --- a/usbredirserver/usbredirserver.c
>> +++ b/usbredirserver/usbredirserver.c
>> @@ -321,6 +321,7 @@ int main(int argc, char *argv[])
>>
>> /* Try to find the specified usb device */
>> if (usbvendor != -1) {
>> + libusb_device *dev;
>> handle = libusb_open_device_with_vid_pid(ctx, usbvendor,
>> usbproduct);
>> if (!handle) {
>> @@ -328,6 +329,14 @@ int main(int argc, char *argv[])
>> "Could not open an usb-device with vid:pid %04x:%04x\n",
>> usbvendor, usbproduct);
>> }
>> + if (verbose >= usbredirparser_info) {
>> + dev = libusb_get_device(handle);
>> + fprintf(stderr, "Open a usb-device with vid:pid %04x:%04x on
>> "
>> + "bus %03x device %03x\n",
>> + usbvendor, usbproduct,
>> + libusb_get_bus_number(dev),
>> + libusb_get_device_address(dev));
>> + }
>> } else {
>> libusb_device **list = NULL;
>> ssize_t i, n;
>
>Patch is good for me.
>I would just move the "dev" declaration inside the if so to have
>a single hunk change and reduce variable visibility.
>
Sure, I'll fix this in v3
Regards,
- Chen
More information about the Spice-devel
mailing list