diff mbox

usb/core: remove "always" from usb_unlink_urb() kernel doc entry

Message ID 20120222194510.GA6964@linutronix.de
State Not Applicable, archived
Delegated to: David Miller
Headers show

Commit Message

Sebastian Andrzej Siewior Feb. 22, 2012, 7:45 p.m. UTC
The kernel doc entry for usb_unlink_urb() contains the phrase "This
request is always asynchronous.". The "always" leads to the assumption
that the ->complete() callback is not called from within
usb_unlink_urb(). This is not true. The HCD is allowed to call the
->complete() from within ->urb_dequeue() if it is appropriate for the
hardware.
This patch updates the kernel doc so usb-device driver authors make sure
to drop all locks (and make sure it is okay to drop them) which are
acquired by the complete callback before calling usb_unlink_urb().

Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
---
 drivers/usb/core/urb.c |    9 +++++----
 1 files changed, 5 insertions(+), 4 deletions(-)

Comments

Alan Stern Feb. 22, 2012, 8:28 p.m. UTC | #1
On Wed, 22 Feb 2012, Sebastian Andrzej Siewior wrote:

> The kernel doc entry for usb_unlink_urb() contains the phrase "This
> request is always asynchronous.". The "always" leads to the assumption
> that the ->complete() callback is not called from within
> usb_unlink_urb(). This is not true. The HCD is allowed to call the
> ->complete() from within ->urb_dequeue() if it is appropriate for the
> hardware.
> This patch updates the kernel doc so usb-device driver authors make sure
> to drop all locks (and make sure it is okay to drop them) which are
> acquired by the complete callback before calling usb_unlink_urb().
> 
> Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
> ---
>  drivers/usb/core/urb.c |    9 +++++----
>  1 files changed, 5 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/usb/core/urb.c b/drivers/usb/core/urb.c
> index f4f20c7..d72b376 100644
> --- a/drivers/usb/core/urb.c
> +++ b/drivers/usb/core/urb.c
> @@ -527,10 +527,11 @@ EXPORT_SYMBOL_GPL(usb_submit_urb);
>   * a driver's I/O routines to insure that all URB-related activity has
>   * completed before it returns.
>   *
> - * This request is always asynchronous.  Success is indicated by
> - * returning -EINPROGRESS, at which time the URB will probably not yet
> - * have been given back to the device driver.  When it is eventually
> - * called, the completion function will see @urb->status == -ECONNRESET.
> + * This request is asynchronous, however the hcd might call the ->complete()
> + * callback during unlink.

"Therefore when drivers call usb_unlink_urb(), they must not hold any
locks that may be taken by the completion function."

Also, we write "HCD" in capital letters.

>  Success is indicated by returning -EINPROGRESS, at
> + * which time the URB will probably not yet have been given back to the device
> + * driver. When it is eventually called, the completion function will see
> + * @urb->status == -ECONNRESET.
>   * Failure is indicated by usb_unlink_urb() returning any other value.
>   * Unlinking will fail when @urb is not currently "linked" (i.e., it was
>   * never submitted, or it was unlinked before, or the hardware is already

Alan Stern

--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

diff --git a/drivers/usb/core/urb.c b/drivers/usb/core/urb.c
index f4f20c7..d72b376 100644
--- a/drivers/usb/core/urb.c
+++ b/drivers/usb/core/urb.c
@@ -527,10 +527,11 @@  EXPORT_SYMBOL_GPL(usb_submit_urb);
  * a driver's I/O routines to insure that all URB-related activity has
  * completed before it returns.
  *
- * This request is always asynchronous.  Success is indicated by
- * returning -EINPROGRESS, at which time the URB will probably not yet
- * have been given back to the device driver.  When it is eventually
- * called, the completion function will see @urb->status == -ECONNRESET.
+ * This request is asynchronous, however the hcd might call the ->complete()
+ * callback during unlink. Success is indicated by returning -EINPROGRESS, at
+ * which time the URB will probably not yet have been given back to the device
+ * driver. When it is eventually called, the completion function will see
+ * @urb->status == -ECONNRESET.
  * Failure is indicated by usb_unlink_urb() returning any other value.
  * Unlinking will fail when @urb is not currently "linked" (i.e., it was
  * never submitted, or it was unlinked before, or the hardware is already