From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1757133AbbIUTP2 (ORCPT ); Mon, 21 Sep 2015 15:15:28 -0400 Received: from mail-lb0-f179.google.com ([209.85.217.179]:36354 "EHLO mail-lb0-f179.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752695AbbIUTPY (ORCPT ); Mon, 21 Sep 2015 15:15:24 -0400 Subject: Re: [PATCH 09/14] RFC: usb/host/fotg210: Add function: output_buf_tds_dir() To: Peter Senna Tschudin , balbi@ti.com, stern@rowland.harvard.edu, standby24x7@gmail.com, pmladek@suse.cz, linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org, gregkh@linuxfoundation.org References: <20150915165002.GP19948@saruman.tx.rr.com> <1442847678-7970-1-git-send-email-peter.senna@gmail.com> <1442847678-7970-10-git-send-email-peter.senna@gmail.com> From: Sergei Shtylyov Organization: Cogent Embedded Message-ID: <56005749.9020805@cogentembedded.com> Date: Mon, 21 Sep 2015 22:15:21 +0300 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.1.0 MIME-Version: 1.0 In-Reply-To: <1442847678-7970-10-git-send-email-peter.senna@gmail.com> Content-Type: text/plain; charset=windows-1252; format=flowed Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 09/21/2015 06:01 PM, Peter Senna Tschudin wrote: > checkpatch complains about too many leading tabs because the switch > statement starts after 6 tabs. > > fill_periodic_buffer() -> for() -> do -> switch() -> if() -> > list_for_each_entry() and finally the last switch(). > > This patch moves the list_for_each_entry() and the last switch() to a > new inline function named output_buf_tds_dir(). This change makes the > code easier to read and calm down checkpatch. This patch changes it to: > > fill_periodic_buffer() -> for() -> do -> switch() -> if() -> > output_buf_tds_dir() > > Signed-off-by: Peter Senna Tschudin > --- > drivers/usb/host/fotg210-hcd.c | 64 ++++++++++++++++++++++-------------------- > 1 file changed, 33 insertions(+), 31 deletions(-) > > diff --git a/drivers/usb/host/fotg210-hcd.c b/drivers/usb/host/fotg210-hcd.c > index 82cd5da..13cca41 100644 > --- a/drivers/usb/host/fotg210-hcd.c > +++ b/drivers/usb/host/fotg210-hcd.c > @@ -497,6 +497,36 @@ static ssize_t fill_async_buffer(struct debug_buffer *buf) > return strlen(buf->output_buf); > } > > +/* count tds, get ep direction */ > +static inline unsigned output_buf_tds_dir(char *buf, Please drop *inline*, let gcc figure it out. > + struct fotg210_hcd *fotg210, > + struct fotg210_qh_hw *hw, > + struct fotg210_qh *qh, unsigned size) > +{ > + u32 scratch = hc32_to_cpup(fotg210, &hw->hw_info1); > + struct fotg210_qtd *qtd; > + char *type = ""; > + unsigned temp = 0; > + > + /* count tds, get ep direction */ > + list_for_each_entry(qtd, &qh->qtd_list, qtd_list) { > + temp++; > + switch (0x03 & (hc32_to_cpu(fotg210, qtd->hw_token) >> 8)) { I think the preference is to place immediate value after &. > + case 0: > + type = "out"; > + continue; > + case 1: > + type = "in"; > + continue; > + } > + } > + > + return scnprintf(buf, size, "(%c%d ep%d%s [%d/%d] q%d p%d)", > + speed_char(scratch), scratch & 0x007f, > + (scratch >> 8) & 0x000f, type, qh->usecs, > + qh->c_usecs, temp, 0x7ff & (scratch >> 16)); Likewise. [...] MBR, Sergei