From: Philipp Hortmann <philipp.g.hortmann@gmail.com>
To: corbet@lwn.net, linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org
Cc: linux-usb@vger.kernel.org
Subject: [PATCH 3/3] Docs: usb: update writesize, copy_from_user, usb_fill_bulk_urb, usb_submit_urb
Date: Fri, 29 Oct 2021 21:40:04 +0200 [thread overview]
Message-ID: <939d9e91d1ac12003a08d7694b6d6bd29ba2a57d.1635533924.git.philipp.g.hortmann@gmail.com> (raw)
In-Reply-To: <cover.1635533924.git.philipp.g.hortmann@gmail.com>
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>
---
.../driver-api/usb/writing_usb_driver.rst | 24 ++++++++++---------
1 file 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 14eda0342649..02c28ee10b91 100644
--- a/Documentation/driver-api/usb/writing_usb_driver.rst
+++ b/Documentation/driver-api/usb/writing_usb_driver.rst
@@ -185,24 +185,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);
}
--
2.25.1
prev parent reply other threads:[~2021-10-29 19:40 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-10-29 19:39 [PATCH 0/3] Docs: usb: Example code updates from usb-skeleton Philipp Hortmann
2021-10-29 19:39 ` [PATCH 1/3] Docs: usb: update err() to pr_err() and replace __FILE__ Philipp Hortmann
2021-10-29 20:33 ` Sergey Shtylyov
2021-10-30 9:32 ` Sergey Shtylyov
2021-10-29 19:39 ` [PATCH 2/3] Docs: usb: update comment and code near increment usage count Philipp Hortmann
2021-10-29 19:40 ` Philipp Hortmann [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=939d9e91d1ac12003a08d7694b6d6bd29ba2a57d.1635533924.git.philipp.g.hortmann@gmail.com \
--to=philipp.g.hortmann@gmail.com \
--cc=corbet@lwn.net \
--cc=linux-doc@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-usb@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).