|
|
383d26 |
From 1ae7aca2d3a283cf75f1cdf2df404ecb97423236 Mon Sep 17 00:00:00 2001
|
|
|
383d26 |
From: Gerd Hoffmann <kraxel@redhat.com>
|
|
|
383d26 |
Date: Mon, 3 Jun 2019 13:45:50 +0200
|
|
|
383d26 |
Subject: [PATCH 7/9] usb-host: avoid libusb_set_configuration calls
|
|
|
383d26 |
MIME-Version: 1.0
|
|
|
383d26 |
Content-Type: text/plain; charset=UTF-8
|
|
|
383d26 |
Content-Transfer-Encoding: 8bit
|
|
|
383d26 |
|
|
|
383d26 |
RH-Author: Gerd Hoffmann <kraxel@redhat.com>
|
|
|
383d26 |
Message-id: <20190603134550.30153-5-kraxel@redhat.com>
|
|
|
383d26 |
Patchwork-id: 88450
|
|
|
383d26 |
O-Subject: [RHEL-7.7 qemu-kvm-rhev PATCH 4/4] usb-host: avoid libusb_set_configuration calls
|
|
|
383d26 |
Bugzilla: 1710861
|
|
|
383d26 |
RH-Acked-by: Philippe Mathieu-Daudé <philmd@redhat.com>
|
|
|
383d26 |
RH-Acked-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
|
|
|
383d26 |
RH-Acked-by: Max Reitz <mreitz@redhat.com>
|
|
|
383d26 |
RH-Acked-by: Miroslav Rezanina <mrezanin@redhat.com>
|
|
|
383d26 |
|
|
|
383d26 |
Seems some devices become confused when we call
|
|
|
383d26 |
libusb_set_configuration(). So before calling the function check
|
|
|
383d26 |
whenever the device has multiple configurations in the first place, and
|
|
|
383d26 |
in case it hasn't (which is the case for the majority of devices) simply
|
|
|
383d26 |
skip the call as it will have no effect anyway.
|
|
|
383d26 |
|
|
|
383d26 |
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
|
|
|
383d26 |
Message-id: 20190522094702.17619-4-kraxel@redhat.com
|
|
|
383d26 |
(cherry picked from commit bfe44898848614cfcb3a269bc965afbe1f0f331c)
|
|
|
383d26 |
Signed-off-by: Miroslav Rezanina <mrezanin@redhat.com>
|
|
|
383d26 |
---
|
|
|
383d26 |
hw/usb/host-libusb.c | 18 ++++++++++--------
|
|
|
383d26 |
1 file changed, 10 insertions(+), 8 deletions(-)
|
|
|
383d26 |
|
|
|
383d26 |
diff --git a/hw/usb/host-libusb.c b/hw/usb/host-libusb.c
|
|
|
383d26 |
index 1d7e386..878c515 100644
|
|
|
383d26 |
--- a/hw/usb/host-libusb.c
|
|
|
383d26 |
+++ b/hw/usb/host-libusb.c
|
|
|
383d26 |
@@ -1216,19 +1216,21 @@ static void usb_host_set_address(USBHostDevice *s, int addr)
|
|
|
383d26 |
|
|
|
383d26 |
static void usb_host_set_config(USBHostDevice *s, int config, USBPacket *p)
|
|
|
383d26 |
{
|
|
|
383d26 |
- int rc;
|
|
|
383d26 |
+ int rc = 0;
|
|
|
383d26 |
|
|
|
383d26 |
trace_usb_host_set_config(s->bus_num, s->addr, config);
|
|
|
383d26 |
|
|
|
383d26 |
usb_host_release_interfaces(s);
|
|
|
383d26 |
- rc = libusb_set_configuration(s->dh, config);
|
|
|
383d26 |
- if (rc != 0) {
|
|
|
383d26 |
- usb_host_libusb_error("libusb_set_configuration", rc);
|
|
|
383d26 |
- p->status = USB_RET_STALL;
|
|
|
383d26 |
- if (rc == LIBUSB_ERROR_NO_DEVICE) {
|
|
|
383d26 |
- usb_host_nodev(s);
|
|
|
383d26 |
+ if (s->ddesc.bNumConfigurations != 1) {
|
|
|
383d26 |
+ rc = libusb_set_configuration(s->dh, config);
|
|
|
383d26 |
+ if (rc != 0) {
|
|
|
383d26 |
+ usb_host_libusb_error("libusb_set_configuration", rc);
|
|
|
383d26 |
+ p->status = USB_RET_STALL;
|
|
|
383d26 |
+ if (rc == LIBUSB_ERROR_NO_DEVICE) {
|
|
|
383d26 |
+ usb_host_nodev(s);
|
|
|
383d26 |
+ }
|
|
|
383d26 |
+ return;
|
|
|
383d26 |
}
|
|
|
383d26 |
- return;
|
|
|
383d26 |
}
|
|
|
383d26 |
p->status = usb_host_claim_interfaces(s, config);
|
|
|
383d26 |
if (p->status != USB_RET_SUCCESS) {
|
|
|
383d26 |
--
|
|
|
383d26 |
1.8.3.1
|
|
|
383d26 |
|