All of lore.kernel.org
 help / color / mirror / Atom feed
From: Alan Stern <stern@rowland.harvard.edu>
To: Li Jun <jun.li@nxp.com>
Cc: gregkh@linuxfoundation.org, mathias.nyman@intel.com,
	peter.chen@kernel.org, jackp@codeaurora.org,
	linux-usb@vger.kernel.org, linux-imx@nxp.com
Subject: Re: [PATCH v3 3/3] usb: core: hcd: use map_urb_for_dma for single step set feature urb
Date: Fri, 7 May 2021 11:42:29 -0400	[thread overview]
Message-ID: <20210507154229.GA776548@rowland.harvard.edu> (raw)
In-Reply-To: <1620370682-10199-3-git-send-email-jun.li@nxp.com>

On Fri, May 07, 2021 at 02:58:02PM +0800, Li Jun wrote:
> Use map_urb_for_dma() to improve the dma map code for single step
> set feature request urb in test mode.
> 
> Signed-off-by: Li Jun <jun.li@nxp.com>
> ---
> Change for v3:
> - Correct the error handling if map_urb_for_dma() fails.
> 
> change for v2:
> - Add this new patch to use map_urb_for_dma API to
>   replace both of dma_map_single() calls, suggested by
>   Jack Pham.
> 
>  drivers/usb/core/hcd.c | 15 +++++----------
>  1 file changed, 5 insertions(+), 10 deletions(-)
> 
> diff --git a/drivers/usb/core/hcd.c b/drivers/usb/core/hcd.c
> index d7eb9f179ca6..fa72697f4829 100644
> --- a/drivers/usb/core/hcd.c
> +++ b/drivers/usb/core/hcd.c
> @@ -2159,16 +2159,11 @@ static struct urb *request_single_step_set_feature_urb(
>  	usb_get_urb(urb);
>  	atomic_inc(&urb->use_count);
>  	atomic_inc(&urb->dev->urbnum);
> -	urb->setup_dma = dma_map_single(
> -			hcd->self.sysdev,
> -			urb->setup_packet,
> -			sizeof(struct usb_ctrlrequest),
> -			DMA_TO_DEVICE);
> -	urb->transfer_dma = dma_map_single(
> -			hcd->self.sysdev,
> -			urb->transfer_buffer,
> -			urb->transfer_buffer_length,
> -			DMA_FROM_DEVICE);
> +	if (map_urb_for_dma(hcd, urb, GFP_KERNEL)) {
> +		usb_put_urb(urb);

You need to call usb_free_urb() here.

Alan Stern

> +		return NULL;
> +	}
> +
>  	urb->context = done;
>  	return urb;
>  }
> -- 
> 2.25.1
> 

  reply	other threads:[~2021-05-07 15:42 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-05-07  6:58 [PATCH v3 1/3] usb: host: move EH SINGLE_STEP_SET_FEATURE implementation to core Li Jun
2021-05-07  6:58 ` [PATCH v3 2/3] usb: host: xhci: add EH SINGLE_STEP_SET_FEATURE Test for USB2 Li Jun
2021-06-11  9:18   ` Jun Li
2021-07-16  3:12     ` Jun Li
2021-07-16 14:35       ` Mathias Nyman
2021-08-21 10:34         ` Jun Li
2021-05-07  6:58 ` [PATCH v3 3/3] usb: core: hcd: use map_urb_for_dma for single step set feature urb Li Jun
2021-05-07 15:42   ` Alan Stern [this message]
2021-05-07 16:52     ` Jack Pham
2021-05-07 17:40       ` Alan Stern

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=20210507154229.GA776548@rowland.harvard.edu \
    --to=stern@rowland.harvard.edu \
    --cc=gregkh@linuxfoundation.org \
    --cc=jackp@codeaurora.org \
    --cc=jun.li@nxp.com \
    --cc=linux-imx@nxp.com \
    --cc=linux-usb@vger.kernel.org \
    --cc=mathias.nyman@intel.com \
    --cc=peter.chen@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.