mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: "Geyslan G. Bem" <geyslan@gmail.com>
To: unlisted-recipients:; (no To-header on input)
Cc: "Geyslan G. Bem" <geyslan@gmail.com>,
	linux-kernel@vger.kernel.org,
	Alan Stern <stern@rowland.harvard.edu>,
	Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	linux-usb@vger.kernel.org
Subject: [PATCH 17/17] usb: host: ehci-dbg: refactor fill_periodic_buffer function
Date: Mon,  4 Jan 2016 17:10:02 -0300	[thread overview]
Message-ID: <d212ee45c0a887c6f945edab61243e2539a11ca3.1451937845.git.geyslan@gmail.com> (raw)
In-Reply-To: <cover.1451937845.git.geyslan@gmail.com>
In-Reply-To: <cover.1451937845.git.geyslan@gmail.com>

This patch fixes a coding style issue reported by checkpatch related to
many leading tabs, removing a 'do while' loop and making use of goto tag instead.

Others changes in this patch are:
 - Some multiline statements are reduced (718, 729, 780, 786, 790).
 - A constant is moved to right on line 770.

Signed-off-by: Geyslan G. Bem <geyslan@gmail.com>
---

Notes:
    Tested by compilation only.

 drivers/usb/host/ehci-dbg.c | 180 ++++++++++++++++++++++----------------------
 1 file changed, 88 insertions(+), 92 deletions(-)

diff --git a/drivers/usb/host/ehci-dbg.c b/drivers/usb/host/ehci-dbg.c
index 2268756..278333d 100644
--- a/drivers/usb/host/ehci-dbg.c
+++ b/drivers/usb/host/ehci-dbg.c
@@ -698,6 +698,8 @@ static ssize_t fill_periodic_buffer(struct debug_buffer *buf)
 	 */
 	spin_lock_irqsave(&ehci->lock, flags);
 	for (i = 0; i < ehci->periodic_size; i++) {
+		struct ehci_qh_hw *hw;
+
 		p = ehci->pshadow[i];
 		if (likely(!p.ptr))
 			continue;
@@ -707,104 +709,98 @@ static ssize_t fill_periodic_buffer(struct debug_buffer *buf)
 		size -= temp;
 		next += temp;
 
-		do {
-			struct ehci_qh_hw *hw;
-
-			switch (hc32_to_cpu(ehci, tag)) {
-			case Q_TYPE_QH:
-				hw = p.qh->hw;
-				temp = scnprintf(next, size, " qh%d-%04x/%p",
-						p.qh->ps.period,
-						hc32_to_cpup(ehci,
-							&hw->hw_info2)
-							/* uframe masks */
-							& (QH_CMASK | QH_SMASK),
-						p.qh);
-				size -= temp;
-				next += temp;
-				/* don't repeat what follows this qh */
-				for (temp = 0; temp < seen_count; temp++) {
-					if (seen[temp].ptr != p.ptr)
+do_loop:
+		switch (hc32_to_cpu(ehci, tag)) {
+		case Q_TYPE_QH:
+			hw = p.qh->hw;
+			temp = scnprintf(next, size, " qh%d-%04x/%p",
+					p.qh->ps.period,
+					hc32_to_cpup(ehci, &hw->hw_info2)
+						/* uframe masks */
+						& (QH_CMASK | QH_SMASK),
+					p.qh);
+			size -= temp;
+			next += temp;
+			/* don't repeat what follows this qh */
+			for (temp = 0; temp < seen_count; temp++) {
+				if (seen[temp].ptr != p.ptr)
+					continue;
+				if (p.qh->qh_next.ptr) {
+					temp = scnprintf(next, size, " ...");
+					size -= temp;
+					next += temp;
+				}
+				break;
+			}
+			/* show more info the first time around */
+			if (temp == seen_count) {
+				u32	scratch = hc32_to_cpup(ehci,
+						&hw->hw_info1);
+				struct ehci_qtd	*qtd;
+				char		*type = "";
+
+				/* count tds, get ep direction */
+				temp = 0;
+				list_for_each_entry(qtd,
+						&p.qh->qtd_list,
+						qtd_list) {
+					temp++;
+					switch ((hc32_to_cpu(ehci,
+						qtd->hw_token) >> 8)
+							& 0x03) {
+					case 0:
+						type = "out";
+						continue;
+					case 1:
+						type = "in";
 						continue;
-					if (p.qh->qh_next.ptr) {
-						temp = scnprintf(next, size,
-							" ...");
-						size -= temp;
-						next += temp;
 					}
-					break;
 				}
-				/* show more info the first time around */
-				if (temp == seen_count) {
-					u32	scratch = hc32_to_cpup(ehci,
-							&hw->hw_info1);
-					struct ehci_qtd	*qtd;
-					char		*type = "";
-
-					/* count tds, get ep direction */
-					temp = 0;
-					list_for_each_entry(qtd,
-							&p.qh->qtd_list,
-							qtd_list) {
-						temp++;
-						switch ((hc32_to_cpu(ehci,
-							qtd->hw_token) >> 8)
-								& 0x03) {
-						case 0:
-							type = "out";
-							continue;
-						case 1:
-							type = "in";
-							continue;
-						}
-					}
 
-					temp = scnprintf(next, size,
-						" (%c%d ep%d%s "
-						"[%d/%d] q%d p%d)",
-						speed_char (scratch),
-						scratch & 0x007f,
-						(scratch >> 8) & 0x000f, type,
-						p.qh->ps.usecs,
-						p.qh->ps.c_usecs,
-						temp,
-						0x7ff & (scratch >> 16));
-
-					if (seen_count < DBG_SCHED_LIMIT)
-						seen[seen_count++].qh = p.qh;
-				} else {
-					temp = 0;
-				}
-				tag = Q_NEXT_TYPE(ehci, hw->hw_next);
-				p = p.qh->qh_next;
-				break;
-			case Q_TYPE_FSTN:
-				temp = scnprintf(next, size,
-					" fstn-%8x/%p", p.fstn->hw_prev,
-					p.fstn);
-				tag = Q_NEXT_TYPE(ehci, p.fstn->hw_next);
-				p = p.fstn->fstn_next;
-				break;
-			case Q_TYPE_ITD:
-				temp = scnprintf(next, size,
-					" itd/%p", p.itd);
-				tag = Q_NEXT_TYPE(ehci, p.itd->hw_next);
-				p = p.itd->itd_next;
-				break;
-			case Q_TYPE_SITD:
 				temp = scnprintf(next, size,
-					" sitd%d-%04x/%p",
-					p.sitd->stream->ps.period,
-					hc32_to_cpup(ehci, &p.sitd->hw_uframe)
-						& 0x0000ffff,
-					p.sitd);
-				tag = Q_NEXT_TYPE(ehci, p.sitd->hw_next);
-				p = p.sitd->sitd_next;
-				break;
+					" (%c%d ep%d%s "
+					"[%d/%d] q%d p%d)",
+					speed_char (scratch),
+					scratch & 0x007f,
+					(scratch >> 8) & 0x000f, type,
+					p.qh->ps.usecs,
+					p.qh->ps.c_usecs,
+					temp,
+					(scratch >> 16) & 0x7ff);
+
+				if (seen_count < DBG_SCHED_LIMIT)
+					seen[seen_count++].qh = p.qh;
+			} else {
+				temp = 0;
 			}
-			size -= temp;
-			next += temp;
-		} while (p.ptr);
+			tag = Q_NEXT_TYPE(ehci, hw->hw_next);
+			p = p.qh->qh_next;
+			break;
+		case Q_TYPE_FSTN:
+			temp = scnprintf(next, size, " fstn-%8x/%p",
+				p.fstn->hw_prev, p.fstn);
+			tag = Q_NEXT_TYPE(ehci, p.fstn->hw_next);
+			p = p.fstn->fstn_next;
+			break;
+		case Q_TYPE_ITD:
+			temp = scnprintf(next, size, " itd/%p", p.itd);
+			tag = Q_NEXT_TYPE(ehci, p.itd->hw_next);
+			p = p.itd->itd_next;
+			break;
+		case Q_TYPE_SITD:
+			temp = scnprintf(next, size, " sitd%d-%04x/%p",
+				p.sitd->stream->ps.period,
+				hc32_to_cpup(ehci, &p.sitd->hw_uframe)
+					& 0x0000ffff,
+				p.sitd);
+			tag = Q_NEXT_TYPE(ehci, p.sitd->hw_next);
+			p = p.sitd->sitd_next;
+			break;
+		}
+		size -= temp;
+		next += temp;
+		if (p.ptr)
+			goto do_loop;
 
 		temp = scnprintf(next, size, "\n");
 		size -= temp;
-- 
2.6.4


  parent reply	other threads:[~2016-01-04 20:12 UTC|newest]

Thread overview: 44+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-01-04 20:09 [PATCH 00/17] usb: host: ehci-dbg: cleanup and refactoring Geyslan G. Bem
2016-01-04 20:09 ` [PATCH 01/17] usb: host: ehci-dbg: remove space before open parenthesis Geyslan G. Bem
2016-01-04 20:09 ` [PATCH 02/17] usb: host: ehci-dbg: remove space before open square bracket Geyslan G. Bem
2016-01-04 20:09 ` [PATCH 03/17] usb: host: ehci-dbg: use C89-style comments Geyslan G. Bem
2016-01-04 20:09 ` [PATCH 04/17] usb: host: ehci-dbg: move trailing statements to next line Geyslan G. Bem
2016-01-04 20:09 ` [PATCH 05/17] usb: host: ehci-dbg: fix up closing parenthesis Geyslan G. Bem
2016-01-04 20:09 ` [PATCH 06/17] usb: host: ehci-dbg: put spaces around operators Geyslan G. Bem
2016-01-04 20:09 ` [PATCH 07/17] usb: host: ehci-dbg: fix unsigned comparison Geyslan G. Bem
2016-01-04 20:50   ` Alan Stern
2016-01-04 21:35     ` Geyslan G. Bem
2016-01-04 21:52       ` Alan Stern
2016-01-04 20:09 ` [PATCH 08/17] usb: host: ehci-dbg: remove unnecessary space after cast Geyslan G. Bem
2016-01-04 20:58   ` Alan Stern
2016-01-04 21:40     ` Geyslan G. Bem
2016-01-04 21:49       ` Greg Kroah-Hartman
2016-01-04 21:52         ` Sergei Shtylyov
2016-01-04 22:07           ` Geyslan G. Bem
2016-01-05  2:40             ` Joe Perches
2016-01-05 15:16               ` Geyslan G. Bem
2016-01-05 16:41               ` Alan Stern
2016-01-04 20:09 ` [PATCH 09/17] usb: host: ehci-dbg: fix up function definitions Geyslan G. Bem
2016-01-04 21:00   ` Alan Stern
2016-01-04 23:28     ` Geyslan G. Bem
2016-01-05 15:12       ` Alan Stern
2016-01-05 15:20         ` Joe Perches
2016-01-05 15:23         ` Joe Perches
2016-01-05 15:27           ` Geyslan G. Bem
2016-01-05 15:36             ` Geyslan G. Bem
2016-01-05 16:06           ` Alan Stern
2016-01-05 16:10             ` Joe Perches
2016-01-05 16:29               ` Alan Stern
2016-01-05 17:03                 ` Geyslan G. Bem
2016-01-04 20:09 ` [PATCH 10/17] usb: host: ehci-dbg: use a blank line after struct declarations Geyslan G. Bem
2016-01-04 20:09 ` [PATCH 11/17] usb: host: ehci-dbg: convert macro to inline function Geyslan G. Bem
2016-01-04 20:09 ` [PATCH 12/17] usb: host: ehci-dbg: add blank line after declarations Geyslan G. Bem
2016-01-04 20:09 ` [PATCH 13/17] usb: host: ehci-dbg: remove blank line before close brace Geyslan G. Bem
2016-01-04 20:09 ` [PATCH 14/17] usb: host: ehci-dbg: replace sizeof operand Geyslan G. Bem
2016-01-04 20:10 ` [PATCH 15/17] usb: host: ehci-dbg: enclose conditional blocks with braces Geyslan G. Bem
2016-01-04 20:10 ` [PATCH 16/17] usb: host: ehci-dbg: prefer kmalloc_array over kmalloc times size Geyslan G. Bem
2016-01-04 20:10 ` Geyslan G. Bem [this message]
2016-01-04 21:01   ` [PATCH 17/17] usb: host: ehci-dbg: refactor fill_periodic_buffer function Alan Stern
2016-01-05  1:19     ` Geyslan G. Bem
2016-01-05 15:15       ` Alan Stern
2016-01-05 15:41         ` Geyslan G. Bem

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=d212ee45c0a887c6f945edab61243e2539a11ca3.1451937845.git.geyslan@gmail.com \
    --to=geyslan@gmail.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-usb@vger.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

all inboxes | Powered by JetHome®