mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
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, gregkh@linuxfoundation.org
Subject: [PATCH v3 1/5] Docs: usb: update usb_bulk_msg receiving example
Date: Mon, 6 Dec 2021 21:57:52 +0100	[thread overview]
Message-ID: <3b794ef1936eb410b60cb536e47a0a00e36611d4.1638771720.git.philipp.g.hortmann@gmail.com> (raw)
In-Reply-To: <cover.1638771720.git.philipp.g.hortmann@gmail.com>

Clarification that this example is not in the driver template anymore.
Update code example so that it fits best to usb-skeleton.c

Signed-off-by: Philipp Hortmann <philipp.g.hortmann@gmail.com>
---
V1 -> V2: Added "Update format of function names" to patch description
          Corrected format of function names like the following example:
          "`usb_bulk_msg` function" to "usb_bulk_msg()"
V2 -> V3: Moved corrections of the function name to an own patch in this
          patch series
          Took back change of variable from retval to rv
---
 .../driver-api/usb/writing_usb_driver.rst     | 20 +++++++++----------
 1 file changed, 10 insertions(+), 10 deletions(-)

diff --git a/Documentation/driver-api/usb/writing_usb_driver.rst b/Documentation/driver-api/usb/writing_usb_driver.rst
index b43e1ce49f0e..1fd7bf1dbdb0 100644
--- a/Documentation/driver-api/usb/writing_usb_driver.rst
+++ b/Documentation/driver-api/usb/writing_usb_driver.rst
@@ -218,7 +218,7 @@ do very much processing at that time. Our implementation of
 ``skel_write_bulk_callback`` merely reports if the urb was completed
 successfully or not and then returns.
 
-The read function works a bit differently from the write function in
+This read function works a bit differently from the write function in
 that we do not use an urb to transfer data from the device to the
 driver. Instead we call the :c:func:`usb_bulk_msg` function, which can be used
 to send or receive data from a device without having to create urbs and
@@ -229,25 +229,25 @@ receiving any data from the device, the function will fail and return an
 error message. This can be shown with the following code::
 
     /* do an immediate bulk read to get data from the device */
-    retval = usb_bulk_msg (skel->dev,
-			   usb_rcvbulkpipe (skel->dev,
-			   skel->bulk_in_endpointAddr),
-			   skel->bulk_in_buffer,
-			   skel->bulk_in_size,
-			   &count, 5000);
+    retval = usb_bulk_msg(dev->udev,
+			 usb_rcvbulkpipe (dev->udev,
+			 dev->bulk_in_endpointAddr),
+			 dev->bulk_in_buffer,
+			 dev->bulk_in_size,
+			 &len, 5000);
     /* if the read was successful, copy the data to user space */
     if (!retval) {
-	    if (copy_to_user (buffer, skel->bulk_in_buffer, count))
+	    if (copy_to_user (buffer, dev->bulk_in_buffer, len))
 		    retval = -EFAULT;
 	    else
-		    retval = count;
+		    retval = len;
     }
 
 
 The :c:func:`usb_bulk_msg` function can be very useful for doing single reads
 or writes to a device; however, if you need to read or write constantly to
 a device, it is recommended to set up your own urbs and submit them to
-the USB subsystem.
+the USB subsystem. The template uses urbs for read and write.
 
 When the user program releases the file handle that it has been using to
 talk to the device, the release function in the driver is called. In
-- 
2.25.1


  reply	other threads:[~2021-12-06 20:58 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-12-06 20:57 [PATCH v3 0/5] Docs: usb: Code and text updates from usb-skeleton Philipp Hortmann
2021-12-06 20:57 ` Philipp Hortmann [this message]
2021-12-07  8:55   ` [PATCH v3 1/5] Docs: usb: update usb_bulk_msg receiving example Oliver Neukum
2021-12-13  5:06     ` Philipp Hortmann
2021-12-06 20:57 ` [PATCH v3 2/5] Docs: usb: update comment and code near decrement our usage count for the device Philipp Hortmann
2021-12-07  9:30   ` Oliver Neukum
2021-12-12  1:25     ` Philipp Hortmann
2021-12-06 20:58 ` [PATCH v3 3/5] Docs: usb: update comment and code of function skel_delete Philipp Hortmann
2021-12-06 20:58 ` [PATCH v3 4/5] Docs: usb: update explanation for device_present to disconnected Philipp Hortmann
2021-12-06 20:58 ` [PATCH v3 5/5] Docs: usb: correct format of function names in the explanations Philipp Hortmann

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=3b794ef1936eb410b60cb536e47a0a00e36611d4.1638771720.git.philipp.g.hortmann@gmail.com \
    --to=philipp.g.hortmann@gmail.com \
    --cc=corbet@lwn.net \
    --cc=gregkh@linuxfoundation.org \
    --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

all inboxes | Powered by JetHome®