[PATCH] docs: usb: document USBDEVFS_BULK return value

Adeel Zahid posted 1 patch 2 months, 1 week ago
Documentation/driver-api/usb/usb.rst | 16 +++++++++++++---
1 file changed, 13 insertions(+), 3 deletions(-)
[PATCH] docs: usb: document USBDEVFS_BULK return value
Posted by Adeel Zahid 2 months, 1 week ago
Replace the FIXME in the usbfs bulk I/O documentation with the
current behavior.

Document that USBDEVFS_BULK returns the completed URB actual_length
on success, which may be smaller than the requested len. Also clarify
that for IN endpoints only the returned number of bytes is copied into
the userspace buffer, so a smaller return value indicates a short
read.

Signed-off-by: Adeel Zahid <adeel.m.zahid@gmail.com>
---
 Documentation/driver-api/usb/usb.rst | 16 +++++++++++++---
 1 file changed, 13 insertions(+), 3 deletions(-)

diff --git a/Documentation/driver-api/usb/usb.rst b/Documentation/driver-api/usb/usb.rst
index 7f2f41e80c1c..6b6a759c1f62 100644
--- a/Documentation/driver-api/usb/usb.rst
+++ b/Documentation/driver-api/usb/usb.rst
@@ -535,9 +535,19 @@ USBDEVFS_BULK
     The ``ep`` value identifies a bulk endpoint number (1 to 15, as
     identified in an endpoint descriptor), masked with USB_DIR_IN when
     referring to an endpoint which sends data to the host from the
-    device. The length of the data buffer is identified by ``len``; Recent
-    kernels support requests up to about 128KBytes. *FIXME say how read
-    length is returned, and how short reads are handled.*.
+    device. The length of the data buffer is identified by ``len``. Recent
+    kernels support requests up to about 128 KBytes.
+
+    On success, the ioctl returns the completed URB's ``actual_length``
+    value, that is, the number of bytes actually transferred for the
+    request. This may be less than the value requested in ``len``.
+
+    For an IN endpoint, the return value tells userspace how many bytes were
+    read and copied into ``data``. If the return value is smaller than
+    ``len``, the read completed as a short read, and only the returned
+    number of bytes is valid in the buffer.
+
+    Failures return a negative errno value.
 
 USBDEVFS_CLEAR_HALT
     Clears endpoint halt (stall) and resets the endpoint toggle. This is
-- 
2.43.0