USB: usbfs: compute urb->actual_length for isochronous
authorAlan Stern <stern@rowland.harvard.edu>
Wed, 8 Nov 2017 17:23:17 +0000 (12:23 -0500)
committerBen Hutchings <ben@decadent.org.uk>
Tue, 13 Feb 2018 18:32:14 +0000 (18:32 +0000)
commite0ec55a69450becef296d2abae2476e2db81f336
tree5a0865f7386c905bf2555a6f8e6e6fac111e52df
parent49a4d6bd43f056aad372f8315ce7cd50e131d909
USB: usbfs: compute urb->actual_length for isochronous

commit 2ef47001b3ee3ded579b7532ebdcf8680e4d8c54 upstream.

The USB kerneldoc says that the actual_length field "is read in
non-iso completion functions", but the usbfs driver uses it for all
URB types in processcompl().  Since not all of the host controller
drivers set actual_length for isochronous URBs, programs using usbfs
with some host controllers don't work properly.  For example, Minas
reports that a USB camera controlled by libusb doesn't work properly
with a dwc2 controller.

It doesn't seem worthwhile to change the HCDs and the documentation,
since the in-kernel USB class drivers evidently don't rely on
actual_length for isochronous transfers.  The easiest solution is for
usbfs to calculate the actual_length value for itself, by adding up
the lengths of the individual packets in an isochronous transfer.

Signed-off-by: Alan Stern <stern@rowland.harvard.edu>
CC: Minas Harutyunyan <Minas.Harutyunyan@synopsys.com>
Reported-and-tested-by: wlf <wulf@rock-chips.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Ben Hutchings <ben@decadent.org.uk>
drivers/usb/core/devio.c