Commit 557f3586 authored by Joe Perches's avatar Joe Perches Committed by Felipe Balbi

usb: gadget: goku_udc: Remove uses of seq_<foo> return values

The seq_printf/seq_puts/seq_putc return values, because they
are frequently misused, will eventually be converted to void.

See: commit 1f33c41c ("seq_file: Rename seq_overflow() to
     seq_has_overflowed() and make public")

Miscellanea:

o Coalesce formats, realign arguments
o Create static functions for statement expression macros
o Use c90 style comments instead of c99
Signed-off-by: default avatarJoe Perches <joe@perches.com>
Signed-off-by: default avatarFelipe Balbi <balbi@ti.com>
parent 00f30d29
...@@ -1024,8 +1024,7 @@ static const char proc_node_name [] = "driver/udc"; ...@@ -1024,8 +1024,7 @@ static const char proc_node_name [] = "driver/udc";
static void dump_intmask(struct seq_file *m, const char *label, u32 mask) static void dump_intmask(struct seq_file *m, const char *label, u32 mask)
{ {
/* int_status is the same format ... */ /* int_status is the same format ... */
seq_printf(m, seq_printf(m, "%s %05X =" FOURBITS EIGHTBITS EIGHTBITS "\n",
"%s %05X =" FOURBITS EIGHTBITS EIGHTBITS "\n",
label, mask, label, mask,
(mask & INT_PWRDETECT) ? " power" : "", (mask & INT_PWRDETECT) ? " power" : "",
(mask & INT_SYSERROR) ? " sys" : "", (mask & INT_SYSERROR) ? " sys" : "",
...@@ -1053,6 +1052,51 @@ static void dump_intmask(struct seq_file *m, const char *label, u32 mask) ...@@ -1053,6 +1052,51 @@ static void dump_intmask(struct seq_file *m, const char *label, u32 mask)
(mask & INT_SUSPEND) ? " suspend" : ""); (mask & INT_SUSPEND) ? " suspend" : "");
} }
static const char *udc_ep_state(enum ep0state state)
{
switch (state) {
case EP0_DISCONNECT:
return "ep0_disconnect";
case EP0_IDLE:
return "ep0_idle";
case EP0_IN:
return "ep0_in";
case EP0_OUT:
return "ep0_out";
case EP0_STATUS:
return "ep0_status";
case EP0_STALL:
return "ep0_stall";
case EP0_SUSPEND:
return "ep0_suspend";
}
return "ep0_?";
}
static const char *udc_ep_status(u32 status)
{
switch (status & EPxSTATUS_EP_MASK) {
case EPxSTATUS_EP_READY:
return "ready";
case EPxSTATUS_EP_DATAIN:
return "packet";
case EPxSTATUS_EP_FULL:
return "full";
case EPxSTATUS_EP_TX_ERR: /* host will retry */
return "tx_err";
case EPxSTATUS_EP_RX_ERR:
return "rx_err";
case EPxSTATUS_EP_BUSY: /* ep0 only */
return "busy";
case EPxSTATUS_EP_STALL:
return "stall";
case EPxSTATUS_EP_INVALID: /* these "can't happen" */
return "invalid";
}
return "?";
}
static int udc_proc_read(struct seq_file *m, void *v) static int udc_proc_read(struct seq_file *m, void *v)
{ {
...@@ -1079,18 +1123,7 @@ static int udc_proc_read(struct seq_file *m, void *v) ...@@ -1079,18 +1123,7 @@ static int udc_proc_read(struct seq_file *m, void *v)
is_usb_connected is_usb_connected
? ((tmp & PW_PULLUP) ? "full speed" : "powered") ? ((tmp & PW_PULLUP) ? "full speed" : "powered")
: "disconnected", : "disconnected",
({const char *state; udc_ep_state(dev->ep0state));
switch(dev->ep0state){
case EP0_DISCONNECT: state = "ep0_disconnect"; break;
case EP0_IDLE: state = "ep0_idle"; break;
case EP0_IN: state = "ep0_in"; break;
case EP0_OUT: state = "ep0_out"; break;
case EP0_STATUS: state = "ep0_status"; break;
case EP0_STALL: state = "ep0_stall"; break;
case EP0_SUSPEND: state = "ep0_suspend"; break;
default: state = "ep0_?"; break;
} state; })
);
dump_intmask(m, "int_status", readl(&regs->int_status)); dump_intmask(m, "int_status", readl(&regs->int_status));
dump_intmask(m, "int_enable", readl(&regs->int_enable)); dump_intmask(m, "int_enable", readl(&regs->int_enable));
...@@ -1099,17 +1132,17 @@ static int udc_proc_read(struct seq_file *m, void *v) ...@@ -1099,17 +1132,17 @@ static int udc_proc_read(struct seq_file *m, void *v)
goto done; goto done;
/* registers for (active) device and ep0 */ /* registers for (active) device and ep0 */
if (seq_printf(m, "\nirqs %lu\ndataset %02x " seq_printf(m, "\nirqs %lu\ndataset %02x single.bcs %02x.%02x state %x addr %u\n",
"single.bcs %02x.%02x state %x addr %u\n",
dev->irqs, readl(&regs->DataSet), dev->irqs, readl(&regs->DataSet),
readl(&regs->EPxSingle), readl(&regs->EPxBCS), readl(&regs->EPxSingle), readl(&regs->EPxBCS),
readl(&regs->UsbState), readl(&regs->UsbState),
readl(&regs->address)) < 0) readl(&regs->address));
if (seq_has_overflowed(m))
goto done; goto done;
tmp = readl(&regs->dma_master); tmp = readl(&regs->dma_master);
if (seq_printf(m, seq_printf(m, "dma %03X =" EIGHTBITS "%s %s\n",
"dma %03X =" EIGHTBITS "%s %s\n", tmp, tmp,
(tmp & MST_EOPB_DIS) ? " eopb-" : "", (tmp & MST_EOPB_DIS) ? " eopb-" : "",
(tmp & MST_EOPB_ENA) ? " eopb+" : "", (tmp & MST_EOPB_ENA) ? " eopb+" : "",
(tmp & MST_TIMEOUT_DIS) ? " tmo-" : "", (tmp & MST_TIMEOUT_DIS) ? " tmo-" : "",
...@@ -1121,9 +1154,8 @@ static int udc_proc_read(struct seq_file *m, void *v) ...@@ -1121,9 +1154,8 @@ static int udc_proc_read(struct seq_file *m, void *v)
(tmp & MST_RD_ENA) ? " IN" : "", (tmp & MST_RD_ENA) ? " IN" : "",
(tmp & MST_WR_ENA) ? " OUT" : "", (tmp & MST_WR_ENA) ? " OUT" : "",
(tmp & MST_CONNECTION) (tmp & MST_CONNECTION) ? "ep1in/ep2out" : "ep1out/ep2in");
? "ep1in/ep2out" if (seq_has_overflowed(m))
: "ep1out/ep2in") < 0)
goto done; goto done;
/* dump endpoint queues */ /* dump endpoint queues */
...@@ -1135,44 +1167,23 @@ static int udc_proc_read(struct seq_file *m, void *v) ...@@ -1135,44 +1167,23 @@ static int udc_proc_read(struct seq_file *m, void *v)
continue; continue;
tmp = readl(ep->reg_status); tmp = readl(ep->reg_status);
if (seq_printf(m, seq_printf(m, "%s %s max %u %s, irqs %lu, status %02x (%s) " FOURBITS "\n",
"%s %s max %u %s, irqs %lu, "
"status %02x (%s) " FOURBITS "\n",
ep->ep.name, ep->ep.name,
ep->is_in ? "in" : "out", ep->is_in ? "in" : "out",
ep->ep.maxpacket, ep->ep.maxpacket,
ep->dma ? "dma" : "pio", ep->dma ? "dma" : "pio",
ep->irqs, ep->irqs,
tmp, ({ char *s; tmp, udc_ep_status(tmp),
switch (tmp & EPxSTATUS_EP_MASK) {
case EPxSTATUS_EP_READY:
s = "ready"; break;
case EPxSTATUS_EP_DATAIN:
s = "packet"; break;
case EPxSTATUS_EP_FULL:
s = "full"; break;
case EPxSTATUS_EP_TX_ERR: // host will retry
s = "tx_err"; break;
case EPxSTATUS_EP_RX_ERR:
s = "rx_err"; break;
case EPxSTATUS_EP_BUSY: /* ep0 only */
s = "busy"; break;
case EPxSTATUS_EP_STALL:
s = "stall"; break;
case EPxSTATUS_EP_INVALID: // these "can't happen"
s = "invalid"; break;
default:
s = "?"; break;
} s; }),
(tmp & EPxSTATUS_TOGGLE) ? "data1" : "data0", (tmp & EPxSTATUS_TOGGLE) ? "data1" : "data0",
(tmp & EPxSTATUS_SUSPEND) ? " suspend" : "", (tmp & EPxSTATUS_SUSPEND) ? " suspend" : "",
(tmp & EPxSTATUS_FIFO_DISABLE) ? " disable" : "", (tmp & EPxSTATUS_FIFO_DISABLE) ? " disable" : "",
(tmp & EPxSTATUS_STAGE_ERROR) ? " ep0stat" : "" (tmp & EPxSTATUS_STAGE_ERROR) ? " ep0stat" : "");
) < 0) if (seq_has_overflowed(m))
goto done; goto done;
if (list_empty(&ep->queue)) { if (list_empty(&ep->queue)) {
if (seq_puts(m, "\t(nothing queued)\n") < 0) seq_puts(m, "\t(nothing queued)\n");
if (seq_has_overflowed(m))
goto done; goto done;
continue; continue;
} }
...@@ -1187,10 +1198,10 @@ static int udc_proc_read(struct seq_file *m, void *v) ...@@ -1187,10 +1198,10 @@ static int udc_proc_read(struct seq_file *m, void *v)
} else } else
tmp = req->req.actual; tmp = req->req.actual;
if (seq_printf(m, seq_printf(m, "\treq %p len %u/%u buf %p\n",
"\treq %p len %u/%u buf %p\n",
&req->req, tmp, req->req.length, &req->req, tmp, req->req.length,
req->req.buf) < 0) req->req.buf);
if (seq_has_overflowed(m))
goto done; goto done;
} }
} }
......
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