Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp938277imu; Wed, 16 Jan 2019 09:57:31 -0800 (PST) X-Google-Smtp-Source: ALg8bN4TlqCDXtdarijYvRcwxsuKjcyi3403wO02WPJjG/9lIvbTdLpCF4bsN4hO3fGbynFUY6wM X-Received: by 2002:a17:902:981:: with SMTP id 1mr10837795pln.142.1547661451384; Wed, 16 Jan 2019 09:57:31 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1547661451; cv=none; d=google.com; s=arc-20160816; b=S1LbLRutEbypIcCS8CCjMnTXrJC235O8qaChMhGFF3yhyr1QxadMFw5IHopZjr3Gfa 09bo8/Vdjvld0/KK/7XhBg2J7TIdT8h6ytwek/c7Nx2TdokHy8EQkZYjMbKlpcQSzS5T s58Haa4sQloUQB6SzQRLkq3ABOP0Mq74dzn8qLIJS6H7dB6yUzoovcEkGtpRjrjbcv9F vX94FtcJSLvzEUEgsxj3eb7Z5X8lt2pLdWZF/vVPj7XAJTecvCcVFJ7/LIjvlvszY5+j UN9JxlgrKcKvEEOklebeKdPN6g/EkbPlVOcSyqsBuuGfK4clFXxmTt8iTt38vhDY+kex J0Ng== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:content-transfer-encoding :references:in-reply-to:date:cc:to:from:subject:message-id; bh=eQFUolHNmamoNCEeqIyWUmz0fWUjhYNG3l/lKFeETWI=; b=vRTDXWN2SdS2phIR2P9g+2cr21QdDHC7KLYYHNOXPtzSZYLWflupfbOkzlsYVKvTjH x8I/+hQpjo47relBktQ6SGO7WU5cJ3507Ug57mwBBDf0ufr+EaeV/GsdY6HwLoRC0Py5 Sf1JCYJrlOh1EHhMRLIBKguXo59BK8RqWzW1dJlwtXwXn7+ACblA1stYIXw5plGeiOP3 EMsR8WponUrk4KopUuJoGyVYE695hrdMw4NlEkQDXGU2zWwy1lxXvGygioBEf92Vnwt/ zwqkjfwSgp2np4Z55F6kh+jEF/AKHC9vxwpbUh9pvBekKkBFd6K4BlD9CZVKGD3oThg7 NN0Q== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id i5si6703659pgg.279.2019.01.16.09.57.12; Wed, 16 Jan 2019 09:57:31 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729360AbfAPCoQ (ORCPT + 99 others); Tue, 15 Jan 2019 21:44:16 -0500 Received: from Mailgw01.mediatek.com ([1.203.163.78]:33985 "EHLO mailgw01.mediatek.com" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S1728309AbfAPCoP (ORCPT ); Tue, 15 Jan 2019 21:44:15 -0500 X-UUID: af8c322969e444708d0ffa7c17f045fa-20190116 X-UUID: af8c322969e444708d0ffa7c17f045fa-20190116 Received: from mtkcas35.mediatek.inc [(172.27.4.250)] by mailgw01.mediatek.com (envelope-from ) (mailgw01.mediatek.com ESMTP with TLS) with ESMTP id 68905317; Wed, 16 Jan 2019 10:44:09 +0800 Received: from MTKCAS36.mediatek.inc (172.27.4.186) by MTKMBS31N1.mediatek.inc (172.27.4.69) with Microsoft SMTP Server (TLS) id 15.0.1395.4; Wed, 16 Jan 2019 10:44:08 +0800 Received: from [10.17.3.153] (10.17.3.153) by MTKCAS36.mediatek.inc (172.27.4.170) with Microsoft SMTP Server id 15.0.1395.4 via Frontend Transport; Wed, 16 Jan 2019 10:44:07 +0800 Message-ID: <1547606647.4433.180.camel@mhfsdcap03> Subject: Re: [PATCH v2 3/4] usb: musb: Extract set toggle as a separate interface From: Min Guo To: Matthias Brugger CC: Bin Liu , Rob Herring , "Greg Kroah-Hartman" , Mark Rutland , Alan Stern , , , , , , Date: Wed, 16 Jan 2019 10:44:07 +0800 In-Reply-To: References: <1547516626-5084-1-git-send-email-min.guo@mediatek.com> <1547516626-5084-4-git-send-email-min.guo@mediatek.com> Content-Type: text/plain; charset="UTF-8" X-Mailer: Evolution 3.2.3-0ubuntu6 Content-Transfer-Encoding: 7bit MIME-Version: 1.0 X-MTK: N Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Matthias, On Tue, 2019-01-15 at 16:19 +0100, Matthias Brugger wrote: > > On 15/01/2019 02:43, min.guo@mediatek.com wrote: > > From: Min Guo > > > > Add a common interface for set data toggle > > > > Signed-off-by: Min Guo > > --- > > 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. Okay. > 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; > > > >