0003-hw-usb-host-libusb.c-fix-build-with-kernel-5.0.patch 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. From ecd615dfe328e3ab551cea3ba243d908936ed382 Mon Sep 17 00:00:00 2001
  2. From: Fabrice Fontaine <fontaine.fabrice@gmail.com>
  3. Date: Sun, 13 Dec 2020 21:27:31 +0100
  4. Subject: [PATCH] hw/usb/host-libusb.c: fix build with kernel < 5.0
  5. USBDEVFS_GET_SPEED is used since version 5.2.0 and
  6. https://gitlab.com/qemu-project/qemu/-/commit/202d69a715a4b1824dcd7ec1683d027ed2bae6d3
  7. resulting in the following build failure with kernel < 5.0:
  8. ../hw/usb/host-libusb.c: In function 'usb_host_open':
  9. ../hw/usb/host-libusb.c:953:32: error: 'USBDEVFS_GET_SPEED' undeclared (first use in this function); did you mean 'USBDEVFS_GETDRIVER'?
  10. int rc = ioctl(hostfd, USBDEVFS_GET_SPEED, NULL);
  11. ^~~~~~~~~~~~~~~~~~
  12. USBDEVFS_GETDRIVER
  13. A tentative was made to fix this build failure with
  14. https://gitlab.com/qemu-project/qemu/-/commit/4969e697c15ac536d5c0700381d5d026ef7f0588
  15. However, the assumtion that distros with old kernels also have old
  16. libusb is just wrong so also add a check for defined(USBDEVFS_GET_SPEED)
  17. Signed-off-by: Fabrice Fontaine <fontaine.fabrice@gmail.com>
  18. [Upstream status: sent to qemu-devel@nongnu.org]
  19. ---
  20. hw/usb/host-libusb.c | 2 +-
  21. 1 file changed, 1 insertion(+), 1 deletion(-)
  22. diff --git a/hw/usb/host-libusb.c b/hw/usb/host-libusb.c
  23. index b950501d10..0343300d3e 100644
  24. --- a/hw/usb/host-libusb.c
  25. +++ b/hw/usb/host-libusb.c
  26. @@ -941,7 +941,7 @@ static int usb_host_open(USBHostDevice *s, libusb_device *dev, int hostfd)
  27. usb_host_ep_update(s);
  28. libusb_speed = libusb_get_device_speed(dev);
  29. -#if LIBUSB_API_VERSION >= 0x01000107 && defined(CONFIG_LINUX)
  30. +#if LIBUSB_API_VERSION >= 0x01000107 && defined(CONFIG_LINUX) && defined(USBDEVFS_GET_SPEED)
  31. if (hostfd && libusb_speed == 0) {
  32. /*
  33. * Workaround libusb bug: libusb_get_device_speed() does not
  34. --
  35. 2.29.2