usb: gadget: goku_udc: Remove uses of seq_<foo> return values
authorJoe Perches <joe@perches.com>
Mon, 16 Mar 2015 18:09:38 +0000 (11:09 -0700)
committerFelipe Balbi <balbi@ti.com>
Thu, 19 Mar 2015 16:28:15 +0000 (11:28 -0500)
The seq_printf/seq_puts/seq_putc return values, because they
are frequently misused, will eventually be converted to void.

See: commit 1f33c41c03da ("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: Joe Perches <joe@perches.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>
drivers/usb/gadget/udc/goku_udc.c

index 5b9176e7202a8fb30c4a07ff7bf8e55e56b740ab..9e8d842e8c08546ed1fe109a3586da6b3c4ee102 100644 (file)
@@ -1024,35 +1024,79 @@ static const char proc_node_name [] = "driver/udc";
 static void dump_intmask(struct seq_file *m, const char *label, u32 mask)
 {
        /* int_status is the same format ... */
-       seq_printf(m,
-               "%s %05X =" FOURBITS EIGHTBITS EIGHTBITS "\n",
-               label, mask,
-               (mask & INT_PWRDETECT) ? " power" : "",
-               (mask & INT_SYSERROR) ? " sys" : "",
-               (mask & INT_MSTRDEND) ? " in-dma" : "",
-               (mask & INT_MSTWRTMOUT) ? " wrtmo" : "",
-
-               (mask & INT_MSTWREND) ? " out-dma" : "",
-               (mask & INT_MSTWRSET) ? " wrset" : "",
-               (mask & INT_ERR) ? " err" : "",
-               (mask & INT_SOF) ? " sof" : "",
-
-               (mask & INT_EP3NAK) ? " ep3nak" : "",
-               (mask & INT_EP2NAK) ? " ep2nak" : "",
-               (mask & INT_EP1NAK) ? " ep1nak" : "",
-               (mask & INT_EP3DATASET) ? " ep3" : "",
-
-               (mask & INT_EP2DATASET) ? " ep2" : "",
-               (mask & INT_EP1DATASET) ? " ep1" : "",
-               (mask & INT_STATUSNAK) ? " ep0snak" : "",
-               (mask & INT_STATUS) ? " ep0status" : "",
-
-               (mask & INT_SETUP) ? " setup" : "",
-               (mask & INT_ENDPOINT0) ? " ep0" : "",
-               (mask & INT_USBRESET) ? " reset" : "",
-               (mask & INT_SUSPEND) ? " suspend" : "");
+       seq_printf(m, "%s %05X =" FOURBITS EIGHTBITS EIGHTBITS "\n",
+                  label, mask,
+                  (mask & INT_PWRDETECT) ? " power" : "",
+                  (mask & INT_SYSERROR) ? " sys" : "",
+                  (mask & INT_MSTRDEND) ? " in-dma" : "",
+                  (mask & INT_MSTWRTMOUT) ? " wrtmo" : "",
+
+                  (mask & INT_MSTWREND) ? " out-dma" : "",
+                  (mask & INT_MSTWRSET) ? " wrset" : "",
+                  (mask & INT_ERR) ? " err" : "",
+                  (mask & INT_SOF) ? " sof" : "",
+
+                  (mask & INT_EP3NAK) ? " ep3nak" : "",
+                  (mask & INT_EP2NAK) ? " ep2nak" : "",
+                  (mask & INT_EP1NAK) ? " ep1nak" : "",
+                  (mask & INT_EP3DATASET) ? " ep3" : "",
+
+                  (mask & INT_EP2DATASET) ? " ep2" : "",
+                  (mask & INT_EP1DATASET) ? " ep1" : "",
+                  (mask & INT_STATUSNAK) ? " ep0snak" : "",
+                  (mask & INT_STATUS) ? " ep0status" : "",
+
+                  (mask & INT_SETUP) ? " setup" : "",
+                  (mask & INT_ENDPOINT0) ? " ep0" : "",
+                  (mask & INT_USBRESET) ? " reset" : "",
+                  (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)
 {
@@ -1068,29 +1112,18 @@ static int udc_proc_read(struct seq_file *m, void *v)
        tmp = readl(&regs->power_detect);
        is_usb_connected = tmp & PW_DETECT;
        seq_printf(m,
-               "%s - %s\n"
-               "%s version: %s %s\n"
-               "Gadget driver: %s\n"
-               "Host %s, %s\n"
-               "\n",
-               pci_name(dev->pdev), driver_desc,
-               driver_name, DRIVER_VERSION, dmastr(),
-               dev->driver ? dev->driver->driver.name : "(none)",
-               is_usb_connected
-                       ? ((tmp & PW_PULLUP) ? "full speed" : "powered")
-                       : "disconnected",
-               ({const char *state;
-               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; })
-               );
+                  "%s - %s\n"
+                  "%s version: %s %s\n"
+                  "Gadget driver: %s\n"
+                  "Host %s, %s\n"
+                  "\n",
+                  pci_name(dev->pdev), driver_desc,
+                  driver_name, DRIVER_VERSION, dmastr(),
+                  dev->driver ? dev->driver->driver.name : "(none)",
+                  is_usb_connected
+                          ? ((tmp & PW_PULLUP) ? "full speed" : "powered")
+                          : "disconnected",
+                  udc_ep_state(dev->ep0state));
 
        dump_intmask(m, "int_status", readl(&regs->int_status));
        dump_intmask(m, "int_enable", readl(&regs->int_enable));
@@ -1099,31 +1132,30 @@ static int udc_proc_read(struct seq_file *m, void *v)
                goto done;
 
        /* registers for (active) device and ep0 */
-       if (seq_printf(m, "\nirqs %lu\ndataset %02x "
-                       "single.bcs %02x.%02x state %x addr %u\n",
-                       dev->irqs, readl(&regs->DataSet),
-                       readl(&regs->EPxSingle), readl(&regs->EPxBCS),
-                       readl(&regs->UsbState),
-                       readl(&regs->address)) < 0)
+       seq_printf(m, "\nirqs %lu\ndataset %02x single.bcs %02x.%02x state %x addr %u\n",
+                  dev->irqs, readl(&regs->DataSet),
+                  readl(&regs->EPxSingle), readl(&regs->EPxBCS),
+                  readl(&regs->UsbState),
+                  readl(&regs->address));
+       if (seq_has_overflowed(m))
                goto done;
 
        tmp = readl(&regs->dma_master);
-       if (seq_printf(m,
-               "dma %03X =" EIGHTBITS "%s %s\n", tmp,
-               (tmp & MST_EOPB_DIS) ? " eopb-" : "",
-               (tmp & MST_EOPB_ENA) ? " eopb+" : "",
-               (tmp & MST_TIMEOUT_DIS) ? " tmo-" : "",
-               (tmp & MST_TIMEOUT_ENA) ? " tmo+" : "",
-
-               (tmp & MST_RD_EOPB) ? " eopb" : "",
-               (tmp & MST_RD_RESET) ? " in_reset" : "",
-               (tmp & MST_WR_RESET) ? " out_reset" : "",
-               (tmp & MST_RD_ENA) ? " IN" : "",
-
-               (tmp & MST_WR_ENA) ? " OUT" : "",
-               (tmp & MST_CONNECTION)
-                       ? "ep1in/ep2out"
-                       : "ep1out/ep2in") < 0)
+       seq_printf(m, "dma %03X =" EIGHTBITS "%s %s\n",
+                  tmp,
+                  (tmp & MST_EOPB_DIS) ? " eopb-" : "",
+                  (tmp & MST_EOPB_ENA) ? " eopb+" : "",
+                  (tmp & MST_TIMEOUT_DIS) ? " tmo-" : "",
+                  (tmp & MST_TIMEOUT_ENA) ? " tmo+" : "",
+
+                  (tmp & MST_RD_EOPB) ? " eopb" : "",
+                  (tmp & MST_RD_RESET) ? " in_reset" : "",
+                  (tmp & MST_WR_RESET) ? " out_reset" : "",
+                  (tmp & MST_RD_ENA) ? " IN" : "",
+
+                  (tmp & MST_WR_ENA) ? " OUT" : "",
+                  (tmp & MST_CONNECTION) ? "ep1in/ep2out" : "ep1out/ep2in");
+       if (seq_has_overflowed(m))
                goto done;
 
        /* dump endpoint queues */
@@ -1135,44 +1167,23 @@ static int udc_proc_read(struct seq_file *m, void *v)
                        continue;
 
                tmp = readl(ep->reg_status);
-               if (seq_printf(m,
-                       "%s %s max %u %s, irqs %lu, "
-                       "status %02x (%s) " FOURBITS "\n",
-                       ep->ep.name,
-                       ep->is_in ? "in" : "out",
-                       ep->ep.maxpacket,
-                       ep->dma ? "dma" : "pio",
-                       ep->irqs,
-                       tmp, ({ char *s;
-                       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_SUSPEND) ? " suspend" : "",
-                       (tmp & EPxSTATUS_FIFO_DISABLE) ? " disable" : "",
-                       (tmp & EPxSTATUS_STAGE_ERROR) ? " ep0stat" : ""
-                       ) < 0)
+               seq_printf(m, "%s %s max %u %s, irqs %lu, status %02x (%s) " FOURBITS "\n",
+                          ep->ep.name,
+                          ep->is_in ? "in" : "out",
+                          ep->ep.maxpacket,
+                          ep->dma ? "dma" : "pio",
+                          ep->irqs,
+                          tmp, udc_ep_status(tmp),
+                          (tmp & EPxSTATUS_TOGGLE) ? "data1" : "data0",
+                          (tmp & EPxSTATUS_SUSPEND) ? " suspend" : "",
+                          (tmp & EPxSTATUS_FIFO_DISABLE) ? " disable" : "",
+                          (tmp & EPxSTATUS_STAGE_ERROR) ? " ep0stat" : "");
+               if (seq_has_overflowed(m))
                        goto done;
 
                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;
                        continue;
                }
@@ -1187,10 +1198,10 @@ static int udc_proc_read(struct seq_file *m, void *v)
                        } else
                                tmp = req->req.actual;
 
-                       if (seq_printf(m,
-                               "\treq %p len %u/%u buf %p\n",
-                               &req->req, tmp, req->req.length,
-                               req->req.buf) < 0)
+                       seq_printf(m, "\treq %p len %u/%u buf %p\n",
+                                  &req->req, tmp, req->req.length,
+                                  req->req.buf);
+                       if (seq_has_overflowed(m))
                                goto done;
                }
        }