[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PULL 1/8] hw/usb/host-libusb.c: fix build with kernel < 5.0
From: |
Gerd Hoffmann |
Subject: |
[PULL 1/8] hw/usb/host-libusb.c: fix build with kernel < 5.0 |
Date: |
Fri, 22 Jan 2021 18:48:42 +0100 |
From: Fabrice Fontaine <fontaine.fabrice@gmail.com>
USBDEVFS_GET_SPEED is used since version 5.2.0 and
https://gitlab.com/qemu-project/qemu/-/commit/202d69a715a4b1824dcd7ec1683d027ed2bae6d3
resulting in the following build failure with kernel < 5.0:
../hw/usb/host-libusb.c: In function 'usb_host_open':
../hw/usb/host-libusb.c:953:32: error: 'USBDEVFS_GET_SPEED' undeclared (first
use in this function); did you mean 'USBDEVFS_GETDRIVER'?
int rc = ioctl(hostfd, USBDEVFS_GET_SPEED, NULL);
^~~~~~~~~~~~~~~~~~
USBDEVFS_GETDRIVER
A tentative was made to fix this build failure with
https://gitlab.com/qemu-project/qemu/-/commit/4969e697c15ac536d5c0700381d5d026ef7f0588
However, the assumption that distros with old kernels also have old
libusb is just wrong so also add a check for defined(USBDEVFS_GET_SPEED)
Signed-off-by: Fabrice Fontaine <fontaine.fabrice@gmail.com>
Message-id: 20201213213016.457350-1-fontaine.fabrice@gmail.com
[ kraxel: codestyle whitespace fixup ]
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
---
hw/usb/host-libusb.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/hw/usb/host-libusb.c b/hw/usb/host-libusb.c
index b950501d100f..295d20227ad3 100644
--- a/hw/usb/host-libusb.c
+++ b/hw/usb/host-libusb.c
@@ -941,7 +941,8 @@ static int usb_host_open(USBHostDevice *s, libusb_device
*dev, int hostfd)
usb_host_ep_update(s);
libusb_speed = libusb_get_device_speed(dev);
-#if LIBUSB_API_VERSION >= 0x01000107 && defined(CONFIG_LINUX)
+#if LIBUSB_API_VERSION >= 0x01000107 && defined(CONFIG_LINUX) && \
+ defined(USBDEVFS_GET_SPEED)
if (hostfd && libusb_speed == 0) {
/*
* Workaround libusb bug: libusb_get_device_speed() does not
--
2.29.2
- [PULL 0/8] Usb 20210122 patches, Gerd Hoffmann, 2021/01/22
- [PULL 4/8] hw/usb/hcd-xhci: Fix extraneous format-truncation error on 32-bit hosts, Gerd Hoffmann, 2021/01/22
- [PULL 1/8] hw/usb/host-libusb.c: fix build with kernel < 5.0,
Gerd Hoffmann <=
- [PULL 3/8] hw/usb: Convert to qdev_realize(), Gerd Hoffmann, 2021/01/22
- [PULL 2/8] hw/usb: Fix bad printf format specifiers, Gerd Hoffmann, 2021/01/22
- [PULL 5/8] scsi/utils: Add INVALID_PARAM_VALUE sense code definition, Gerd Hoffmann, 2021/01/22
- [PULL 8/8] usb-host: map LIBUSB_SPEED_SUPER_PLUS to USB_SPEED_SUPER, Gerd Hoffmann, 2021/01/22
- [PULL 6/8] hw/usb/dev-uas: Report command additional adb length as unsupported, Gerd Hoffmann, 2021/01/22
- [PULL 7/8] usb: add pcap support., Gerd Hoffmann, 2021/01/22
- Re: [PULL 0/8] Usb 20210122 patches, Peter Maydell, 2021/01/23