diff options
author | Philipp Hortmann <philipp.g.hortmann@gmail.com> | 2021-10-30 14:25:10 +0300 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2021-11-17 16:54:58 +0300 |
commit | 6352f24ba40f4ebbb21cfa660ebb7a430c4fbdc5 (patch) | |
tree | 046da71d5a91d6160a08ab452d37627905a4e82d /Documentation/driver-api/usb | |
parent | 925ed163abcfa0e27787a9989c12a5e98b7a12fd (diff) | |
download | linux-6352f24ba40f4ebbb21cfa660ebb7a430c4fbdc5.tar.xz |
Docs: usb: update writesize, copy_from_user, usb_fill_bulk_urb, usb_submit_urb
update code examples writesize, copy_from_user, usb_fill_bulk_urb,
usb_submit_urb in skel_write() according to usb-skeleton.c
Signed-off-by: Philipp Hortmann <philipp.g.hortmann@gmail.com>
Link: https://lore.kernel.org/r/0c581a83dfc1a8c37e97dfa7279d333f367a9787.1635591623.git.philipp.g.hortmann@gmail.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'Documentation/driver-api/usb')
-rw-r--r-- | Documentation/driver-api/usb/writing_usb_driver.rst | 24 |
1 files changed, 13 insertions, 11 deletions
diff --git a/Documentation/driver-api/usb/writing_usb_driver.rst b/Documentation/driver-api/usb/writing_usb_driver.rst index a6b11bf107c6..95c4f5d14052 100644 --- a/Documentation/driver-api/usb/writing_usb_driver.rst +++ b/Documentation/driver-api/usb/writing_usb_driver.rst @@ -188,24 +188,26 @@ space, points the urb to the data and submits the urb to the USB subsystem. This can be seen in the following code:: /* we can only write as much as 1 urb will hold */ - bytes_written = (count > skel->bulk_out_size) ? skel->bulk_out_size : count; + size_t writesize = min_t(size_t, count, MAX_TRANSFER); /* copy the data from user space into our urb */ - copy_from_user(skel->write_urb->transfer_buffer, buffer, bytes_written); + copy_from_user(buf, user_buffer, writesize); /* set up our urb */ - usb_fill_bulk_urb(skel->write_urb, - skel->dev, - usb_sndbulkpipe(skel->dev, skel->bulk_out_endpointAddr), - skel->write_urb->transfer_buffer, - bytes_written, + usb_fill_bulk_urb(urb, + dev->udev, + usb_sndbulkpipe(dev->udev, dev->bulk_out_endpointAddr), + buf, + writesize, skel_write_bulk_callback, - skel); + dev); /* send the data out the bulk port */ - result = usb_submit_urb(skel->write_urb); - if (result) { - err("Failed submitting write urb, error %d", result); + retval = usb_submit_urb(urb, GFP_KERNEL); + if (retval) { + dev_err(&dev->interface->dev, + "%s - failed submitting write urb, error %d\n", + __func__, retval); } |