From: Gerd Hoffmann <kraxel@redhat.com>
To: qemu-devel@nongnu.org
Cc: Gerd Hoffmann <kraxel@redhat.com>
Subject: [Qemu-devel] [PATCH 3/3] usb-host: avoid libusb_set_configuration calls
Date: Wed, 22 May 2019 11:47:02 +0200 [thread overview]
Message-ID: <20190522094702.17619-4-kraxel@redhat.com> (raw)
In-Reply-To: <20190522094702.17619-1-kraxel@redhat.com>
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 <kraxel@redhat.com>
---
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
prev parent reply other threads:[~2019-05-22 9:50 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-05-22 9:46 [Qemu-devel] [PATCH 0/3] usb-host: some little tweaks to hopefully reduce usb pass-through problems Gerd Hoffmann
2019-05-22 9:47 ` [Qemu-devel] [PATCH 1/3] usb: call reset handler before updating state Gerd Hoffmann
2019-05-22 9:47 ` [Qemu-devel] [PATCH 2/3] usb-host: skip reset for untouched devices Gerd Hoffmann
2019-05-22 9:47 ` Gerd Hoffmann [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20190522094702.17619-4-kraxel@redhat.com \
--to=kraxel@redhat.com \
--cc=qemu-devel@nongnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).