[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PULL 3/9] usb-host: avoid libusb_set_configuration calls
From: |
Gerd Hoffmann |
Subject: |
[Qemu-devel] [PULL 3/9] usb-host: avoid libusb_set_configuration calls |
Date: |
Wed, 29 May 2019 08:28:26 +0200 |
Seems some devices become confused when we call
libusb_set_configuration(). So before calling the function check
whenever the device has multiple configurations in the first place, and
in case it hasn't (which is the case for the majority of devices) simply
skip the call as it will have no effect anyway.
Signed-off-by: Gerd Hoffmann <address@hidden>
Message-id: address@hidden
---
hw/usb/host-libusb.c | 18 ++++++++++--------
1 file changed, 10 insertions(+), 8 deletions(-)
diff --git a/hw/usb/host-libusb.c b/hw/usb/host-libusb.c
index 4e9a45a5d26f..4f765d7f9a2f 100644
--- a/hw/usb/host-libusb.c
+++ b/hw/usb/host-libusb.c
@@ -1225,19 +1225,21 @@ static void usb_host_set_address(USBHostDevice *s, int
addr)
static void usb_host_set_config(USBHostDevice *s, int config, USBPacket *p)
{
- int rc;
+ int rc = 0;
trace_usb_host_set_config(s->bus_num, s->addr, config);
usb_host_release_interfaces(s);
- rc = libusb_set_configuration(s->dh, config);
- if (rc != 0) {
- usb_host_libusb_error("libusb_set_configuration", rc);
- p->status = USB_RET_STALL;
- if (rc == LIBUSB_ERROR_NO_DEVICE) {
- usb_host_nodev(s);
+ if (s->ddesc.bNumConfigurations != 1) {
+ rc = libusb_set_configuration(s->dh, config);
+ if (rc != 0) {
+ usb_host_libusb_error("libusb_set_configuration", rc);
+ p->status = USB_RET_STALL;
+ if (rc == LIBUSB_ERROR_NO_DEVICE) {
+ usb_host_nodev(s);
+ }
+ return;
}
- return;
}
p->status = usb_host_claim_interfaces(s, config);
if (p->status != USB_RET_SUCCESS) {
--
2.18.1
- [Qemu-devel] [PULL 0/9] Usb 20190529 patches, Gerd Hoffmann, 2019/05/29
- [Qemu-devel] [PULL 1/9] usb: call reset handler before updating state, Gerd Hoffmann, 2019/05/29
- [Qemu-devel] [PULL 2/9] usb-host: skip reset for untouched devices, Gerd Hoffmann, 2019/05/29
- [Qemu-devel] [PULL 4/9] usb-hub: tweak feature names, Gerd Hoffmann, 2019/05/29
- [Qemu-devel] [PULL 6/9] usb-hub: add helpers to update port state, Gerd Hoffmann, 2019/05/29
- [Qemu-devel] [PULL 3/9] usb-host: avoid libusb_set_configuration calls,
Gerd Hoffmann <=
- [Qemu-devel] [PULL 7/9] usb-hub: add usb_hub_port_update(), Gerd Hoffmann, 2019/05/29
- [Qemu-devel] [PULL 8/9] usb-hub: emulate per port power switching, Gerd Hoffmann, 2019/05/29
- [Qemu-devel] [PULL 5/9] usb-hub: make number of ports runtime-configurable, Gerd Hoffmann, 2019/05/29
- [Qemu-devel] [PULL 9/9] usb-tablet: fix serial compat property, Gerd Hoffmann, 2019/05/29
- Re: [Qemu-devel] [PULL 0/9] Usb 20190529 patches, Peter Maydell, 2019/05/30