Commit 50bdb123 authored by Peter Senna Tschudin's avatar Peter Senna Tschudin Committed by Greg Kroah-Hartman

usb/host/fotg210: Add function scan_frame_queue()

checkpatch complains about too many leading tabs because the if
statement starts after 6 tabs:

scan_iosoc() -> for() -> while() -> switch() -> if() -> for() -> if()

There is also a goto statement going backwards in case of failure. This
patch creates a new inline function named scan_frame_queue() containing
the last 4 nesting levels, and removes the need of backwards goto,
making the code easier to read. After the patch it becomes:

scan_iosoc() -> for() -> while() -> scan_frame_queue()
Signed-off-by: default avatarPeter Senna Tschudin <peter.senna@gmail.com>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent 32fb1939
...@@ -4609,35 +4609,14 @@ static int itd_submit(struct fotg210_hcd *fotg210, struct urb *urb, ...@@ -4609,35 +4609,14 @@ static int itd_submit(struct fotg210_hcd *fotg210, struct urb *urb,
return status; return status;
} }
/*-------------------------------------------------------------------------*/ static inline int scan_frame_queue(struct fotg210_hcd *fotg210, unsigned frame,
unsigned now_frame, bool live)
static void scan_isoc(struct fotg210_hcd *fotg210)
{ {
unsigned uf, now_frame, frame; unsigned uf;
unsigned fmask = fotg210->periodic_size - 1; bool modified;
bool modified, live;
/*
* When running, scan from last scan point up to "now"
* else clean up by scanning everything that's left.
* Touches as few pages as possible: cache-friendly.
*/
if (fotg210->rh_state >= FOTG210_RH_RUNNING) {
uf = fotg210_read_frame_index(fotg210);
now_frame = (uf >> 3) & fmask;
live = true;
} else {
now_frame = (fotg210->next_frame - 1) & fmask;
live = false;
}
fotg210->now_frame = now_frame;
frame = fotg210->next_frame;
for (;;) {
union fotg210_shadow q, *q_p; union fotg210_shadow q, *q_p;
__hc32 type, *hw_p; __hc32 type, *hw_p;
restart:
/* scan each element in frame's queue for completions */ /* scan each element in frame's queue for completions */
q_p = &fotg210->pshadow[frame]; q_p = &fotg210->pshadow[frame];
hw_p = &fotg210->periodic[frame]; hw_p = &fotg210->periodic[frame];
...@@ -4645,7 +4624,7 @@ static void scan_isoc(struct fotg210_hcd *fotg210) ...@@ -4645,7 +4624,7 @@ static void scan_isoc(struct fotg210_hcd *fotg210)
type = Q_NEXT_TYPE(fotg210, *hw_p); type = Q_NEXT_TYPE(fotg210, *hw_p);
modified = false; modified = false;
while (q.ptr != NULL) { while (q.ptr) {
switch (hc32_to_cpu(fotg210, type)) { switch (hc32_to_cpu(fotg210, type)) {
case Q_TYPE_ITD: case Q_TYPE_ITD:
/* If this ITD is still active, leave it for /* If this ITD is still active, leave it for
...@@ -4695,8 +4674,38 @@ static void scan_isoc(struct fotg210_hcd *fotg210) ...@@ -4695,8 +4674,38 @@ static void scan_isoc(struct fotg210_hcd *fotg210)
/* assume completion callbacks modify the queue */ /* assume completion callbacks modify the queue */
if (unlikely(modified && fotg210->isoc_count > 0)) if (unlikely(modified && fotg210->isoc_count > 0))
goto restart; return -EINVAL;
} }
return 0;
}
static void scan_isoc(struct fotg210_hcd *fotg210)
{
unsigned uf, now_frame, frame, ret;
unsigned fmask = fotg210->periodic_size - 1;
bool live;
/*
* When running, scan from last scan point up to "now"
* else clean up by scanning everything that's left.
* Touches as few pages as possible: cache-friendly.
*/
if (fotg210->rh_state >= FOTG210_RH_RUNNING) {
uf = fotg210_read_frame_index(fotg210);
now_frame = (uf >> 3) & fmask;
live = true;
} else {
now_frame = (fotg210->next_frame - 1) & fmask;
live = false;
}
fotg210->now_frame = now_frame;
frame = fotg210->next_frame;
for (;;) {
ret = 1;
while (ret != 0)
ret = scan_frame_queue(fotg210, frame,
now_frame, live);
/* Stop when we have reached the current frame */ /* Stop when we have reached the current frame */
if (frame == now_frame) if (frame == now_frame)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment