public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Matthias Brugger <matthias.bgg@gmail.com>
To: min.guo@mediatek.com, Bin Liu <b-liu@ti.com>,
	Rob Herring <robh+dt@kernel.org>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	Mark Rutland <mark.rutland@arm.com>,
	Alan Stern <stern@rowland.harvard.edu>,
	chunfeng.yun@mediatek.com, linux-usb@vger.kernel.org,
	devicetree@vger.kernel.org, linux-kernel@vger.kernel.org,
	linux-arm-kernel@lists.infradead.org,
	linux-mediatek@lists.infradead.org
Subject: Re: [PATCH v2 3/4] usb: musb: Extract set toggle as a separate interface
Date: Tue, 15 Jan 2019 16:19:42 +0100	[thread overview]
Message-ID: <a4e71c59-8e25-b3e9-797f-46d918121dd4@gmail.com> (raw)
In-Reply-To: <1547516626-5084-4-git-send-email-min.guo@mediatek.com>



On 15/01/2019 02:43, min.guo@mediatek.com wrote:
> From: Min Guo <min.guo@mediatek.com>
> 
> Add a common interface for set data toggle
> 
> Signed-off-by: Min Guo <min.guo@mediatek.com>
> ---
>  drivers/usb/musb/musb_host.c | 37 +++++++++++++++++++++++--------------
>  1 file changed, 23 insertions(+), 14 deletions(-)
> 
> diff --git a/drivers/usb/musb/musb_host.c b/drivers/usb/musb/musb_host.c
> index b59ce9a..16d0ba4 100644
> --- a/drivers/usb/musb/musb_host.c
> +++ b/drivers/usb/musb/musb_host.c
> @@ -306,6 +306,25 @@ static inline void musb_save_toggle(struct musb_qh *qh, int is_in,
>  	usb_settoggle(urb->dev, qh->epnum, !is_in, csr ? 1 : 0);
>  }
>  
> +static inline u16 musb_set_toggle(struct musb_qh *qh, int is_in,
> +	struct urb *urb)
> +{
> +	u16 csr = 0;
> +	u16 toggle = 0;
> +
> +	toggle = usb_gettoggle(urb->dev, qh->epnum, !is_in);
> +
> +	if (is_in)
> +		csr = toggle ? (MUSB_RXCSR_H_WR_DATATOGGLE
> +				| MUSB_RXCSR_H_DATATOGGLE) : 0;
> +	else
> +		csr = toggle ? (MUSB_TXCSR_H_WR_DATATOGGLE
> +				| MUSB_TXCSR_H_DATATOGGLE)
> +				: MUSB_TXCSR_CLRDATATOG;

Can we switch the if and use is_out logic as function parameter. This would make
the code easier to understand.

Regards,
Matthias

> +
> +	return csr;
> +}
> +
>  /*
>   * Advance this hardware endpoint's queue, completing the specified URB and
>   * advancing to either the next URB queued to that qh, or else invalidating
> @@ -772,13 +791,8 @@ static void musb_ep_program(struct musb *musb, u8 epnum,
>  					);
>  			csr |= MUSB_TXCSR_MODE;
>  
> -			if (!hw_ep->tx_double_buffered) {
> -				if (usb_gettoggle(urb->dev, qh->epnum, 1))
> -					csr |= MUSB_TXCSR_H_WR_DATATOGGLE
> -						| MUSB_TXCSR_H_DATATOGGLE;
> -				else
> -					csr |= MUSB_TXCSR_CLRDATATOG;
> -			}
> +			if (!hw_ep->tx_double_buffered)
> +				csr |= musb_set_toggle(qh, !is_out, urb);
>  
>  			musb_writew(epio, MUSB_TXCSR, csr);
>  			/* REVISIT may need to clear FLUSHFIFO ... */
> @@ -860,17 +874,12 @@ static void musb_ep_program(struct musb *musb, u8 epnum,
>  
>  	/* IN/receive */
>  	} else {
> -		u16	csr;
> +		u16 csr = 0;
>  
>  		if (hw_ep->rx_reinit) {
>  			musb_rx_reinit(musb, qh, epnum);
> +			csr |= musb_set_toggle(qh, !is_out, urb);
>  
> -			/* init new state: toggle and NYET, maybe DMA later */
> -			if (usb_gettoggle(urb->dev, qh->epnum, 0))
> -				csr = MUSB_RXCSR_H_WR_DATATOGGLE
> -					| MUSB_RXCSR_H_DATATOGGLE;
> -			else
> -				csr = 0;
>  			if (qh->type == USB_ENDPOINT_XFER_INT)
>  				csr |= MUSB_RXCSR_DISNYET;
>  
> 

  reply	other threads:[~2019-01-15 15:19 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-01-15  1:43 [PATCH v2 0/4] Add MediaTek MUSB Controller Driver min.guo
2019-01-15  1:43 ` [PATCH v2 1/4] dt-bindings: usb: musb: Add support for MediaTek musb controller min.guo
2019-01-15  1:43 ` [PATCH v2 2/4] arm: dts: mt2701: Add usb2 device nodes min.guo
2019-01-15  1:43 ` [PATCH v2 3/4] usb: musb: Extract set toggle as a separate interface min.guo
2019-01-15 15:19   ` Matthias Brugger [this message]
2019-01-15 20:40     ` Bin Liu
2019-01-16  2:43       ` Min Guo
2019-01-16  2:44     ` Min Guo
2019-01-15  1:43 ` [PATCH v2 4/4] usb: musb: Add support for MediaTek musb controller min.guo
2019-01-15 20:38   ` Bin Liu
2019-01-16  2:43     ` Min Guo
2019-01-16  9:39     ` Min Guo
2019-01-16 13:59       ` Bin Liu
2019-01-17  3:34         ` Min Guo

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=a4e71c59-8e25-b3e9-797f-46d918121dd4@gmail.com \
    --to=matthias.bgg@gmail.com \
    --cc=b-liu@ti.com \
    --cc=chunfeng.yun@mediatek.com \
    --cc=devicetree@vger.kernel.org \
    --cc=gregkh@linuxfoundation.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mediatek@lists.infradead.org \
    --cc=linux-usb@vger.kernel.org \
    --cc=mark.rutland@arm.com \
    --cc=min.guo@mediatek.com \
    --cc=robh+dt@kernel.org \
    --cc=stern@rowland.harvard.edu \
    /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