staging: cxt1e1: Removed assignments from if statements.
authorChi Pham <fempsci@gmail.com>
Wed, 12 Mar 2014 15:36:19 +0000 (16:36 +0100)
committerPeter P Waskiewicz Jr <peter.p.waskiewicz.jr@intel.com>
Fri, 14 Mar 2014 00:44:45 +0000 (17:44 -0700)
Assignments removed from if statements.
Fixed checkpatch warning such as indentation and negative error returns in
adjacent code.

Coccinelle was used for this patch. The following script found the match:
@simple@
expression E1, E2;
statement S1, S2;
@@

+ E1 = E2;
  if (
-     (E1 = E2)
+     E1
     )
  S1 else S2

@left@
expression E0, E1, E2;
statement S1, S2;
@@

+ E1 = E2;
  if (
-     (E1 = E2)
+     E1
         == E0
     )
  S1 else S2

Signed-off-by: Chi Pham <fempsci@gmail.com>
Signed-off-by: Peter P Waskiewicz Jr <peter.p.waskiewicz.jr@intel.com>
drivers/staging/cxt1e1/musycc.c
drivers/staging/cxt1e1/pmcc4_drv.c
drivers/staging/cxt1e1/sbeproc.c

index b5c798a85dccccc50df2bfe4c5002a5dcc980c6f..4b3aaafc10a4c6e8e3f059a3985e168a42977fc9 100644 (file)
@@ -1045,17 +1045,19 @@ musycc_bh_rx_eom(mpi_t *pi, int gchan)
 #endif                              /*** CONFIG_SBE_WAN256T3_NCOMM ***/
 
            {
-               if ((m2 = OS_mem_token_alloc(cxt1e1_max_mru))) {
-                   /* substitute the mbuf+cluster */
-                   md->mem_token = m2;
-                   md->data = cpu_to_le32(OS_vtophys(OS_mem_token_data(m2)));
-
-                   /* pass the received mbuf upward */
-                   sd_recv_consume(m, status & LENGTH_MASK, ch->user);
-                   ch->s.rx_packets++;
-                   ch->s.rx_bytes += status & LENGTH_MASK;
+               m2 = OS_mem_token_alloc(cxt1e1_max_mru);
+               if (m2) {
+                       /* substitute the mbuf+cluster */
+                       md->mem_token = m2;
+                       md->data = cpu_to_le32(OS_vtophys(
+                               OS_mem_token_data(m2)));
+
+                       /* pass the received mbuf upward */
+                       sd_recv_consume(m, status & LENGTH_MASK, ch->user);
+                       ch->s.rx_packets++;
+                       ch->s.rx_bytes += status & LENGTH_MASK;
                } else
-                   ch->s.rx_dropped++;
+                       ch->s.rx_dropped++;
            }
        } else if (error == ERR_FCS)
            ch->s.rx_crc_errors++;
index a9d95753be20479de7826eab83723ae95e945494..71702dbc98da111e3233ede15e55a4006244b581 100644 (file)
@@ -112,12 +112,12 @@ c4_find_chan (int channum)
         for (portnum = 0; portnum < ci->max_port; portnum++)
             for (gchan = 0; gchan < MUSYCC_NCHANS; gchan++)
             {
-                if ((ch = ci->port[portnum].chan[gchan]))
-                {
-                    if ((ch->state != UNASSIGNED) &&
-                        (ch->channum == channum))
-                        return ch;
-                }
+               ch = ci->port[portnum].chan[gchan];
+               if (ch) {
+                       if ((ch->state != UNASSIGNED) &&
+                          (ch->channum == channum))
+                               return ch;
+               }
             }
     return NULL;
 }
@@ -668,8 +668,9 @@ c4_init2 (ci_t *ci)
     status_t    ret;
 
     /* PORT POINT: this routine generates first interrupt */
-    if ((ret = musycc_init (ci)) != SBE_DRVR_SUCCESS)
-        return ret;
+       ret = musycc_init(ci);
+       if (ret != SBE_DRVR_SUCCESS)
+               return ret;
 
 #if 0
     ci->p.framing_type = FRAMING_CBP;
@@ -933,9 +934,9 @@ c4_set_port (ci_t *ci, int portnum)
     {
         status_t    ret;
 
-        if ((ret = c4_wq_port_init (pi)))       /* create/init
-                                                 * workqueue_struct */
-            return ret;
+       ret = c4_wq_port_init(pi);
+       if (ret)       /* create/init workqueue_struct */
+               return ret;
     }
 
     init_comet (ci, pi->cometbase, pp->port_mode, 1 /* clockmaster == true */ , pp->portP);
@@ -1055,8 +1056,9 @@ c4_new_chan (ci_t *ci, int portnum, int channum, void *user)
     {
         status_t    ret;
 
-        if ((ret = c4_wk_chan_init (pi, ch)))
-            return ret;
+       ret = c4_wk_chan_init(pi, ch);
+       if (ret)
+               return ret;
     }
 
     /* save off interface assignments which bound a board */
@@ -1079,8 +1081,9 @@ c4_del_chan (int channum)
 {
     mch_t      *ch;
 
-    if (!(ch = c4_find_chan (channum)))
-        return ENOENT;
+       ch = c4_find_chan(channum);
+       if (!ch)
+               return -ENOENT;
     if (ch->state == UP)
         musycc_chan_down ((ci_t *) 0, channum);
     ch->state = UNASSIGNED;
@@ -1095,8 +1098,9 @@ c4_del_chan_stats (int channum)
 {
     mch_t      *ch;
 
-    if (!(ch = c4_find_chan (channum)))
-        return ENOENT;
+       ch = c4_find_chan(channum);
+       if (!ch)
+               return -ENOENT;
 
     memset (&ch->s, 0, sizeof (struct sbecom_chan_stats));
     return 0;
@@ -1109,8 +1113,9 @@ c4_set_chan (int channum, struct sbecom_chan_param *p)
     mch_t      *ch;
     int         i, x = 0;
 
-    if (!(ch = c4_find_chan (channum)))
-        return ENOENT;
+       ch = c4_find_chan(channum);
+       if (!ch)
+               return -ENOENT;
 
 #if 1
     if (ch->p.card != p->card ||
@@ -1143,10 +1148,12 @@ c4_set_chan (int channum, struct sbecom_chan_param *p)
     {
         status_t    ret;
 
-        if ((ret = musycc_chan_down ((ci_t *) 0, channum)))
-            return ret;
-        if ((ret = c4_chan_up (ch->up->up, channum)))
-            return ret;
+       ret = musycc_chan_down((ci_t *)0, channum);
+       if (ret)
+               return ret;
+       ret = c4_chan_up(ch->up->up, channum);
+       if (ret)
+               return ret;
         sd_enable_xmit (ch->user);  /* re-enable to catch flow controlled
                                      * channel */
     }
@@ -1159,8 +1166,9 @@ c4_get_chan (int channum, struct sbecom_chan_param *p)
 {
     mch_t      *ch;
 
-    if (!(ch = c4_find_chan (channum)))
-        return ENOENT;
+       ch = c4_find_chan(channum);
+       if (!ch)
+               return -ENOENT;
     *p = ch->p;
     return 0;
 }
@@ -1170,8 +1178,9 @@ c4_get_chan_stats (int channum, struct sbecom_chan_stats *p)
 {
     mch_t      *ch;
 
-    if (!(ch = c4_find_chan (channum)))
-        return ENOENT;
+       ch = c4_find_chan(channum);
+       if (!ch)
+               return -ENOENT;
     *p = ch->s;
     p->tx_pending = atomic_read (&ch->tx_pending);
     return 0;
@@ -1240,8 +1249,9 @@ c4_chan_up (ci_t *ci, int channum)
     u_int32_t   tmp;            /* for optimizing conversion across BE
                                  * platform */
 
-    if (!(ch = c4_find_chan (channum)))
-        return ENOENT;
+       ch = c4_find_chan(channum);
+       if (!ch)
+               return -ENOENT;
     if (ch->state == UP)
     {
         if (cxt1e1_log_level >= LOG_MONITOR)
@@ -1372,12 +1382,13 @@ c4_chan_up (ci_t *ci, int channum)
         }
         md->next = cpu_to_le32 (OS_vtophys (md->snext));
 
-               if (!(m = OS_mem_token_alloc (cxt1e1_max_mru)))
-        {
-            if (cxt1e1_log_level >= LOG_MONITOR)
-                pr_info("%s: c4_chan_up[%d] - token alloc failure, size = %d.\n",
-                                               ci->devname, channum, cxt1e1_max_mru);
-            goto errfree;
+       m = OS_mem_token_alloc(cxt1e1_max_mru);
+       if (!m) {
+               if (cxt1e1_log_level >= LOG_MONITOR)
+                       pr_info(
+                       "%s: c4_chan_up[%d] - token alloc failure, size = %d.\n",
+                       ci->devname, channum, cxt1e1_max_mru);
+               goto errfree;
         }
         md->mem_token = m;
         md->data = cpu_to_le32 (OS_vtophys (OS_mem_token_data (m)));
@@ -1533,8 +1544,9 @@ c4_get_iidinfo (ci_t *ci, struct sbe_iid_info *iip)
     struct net_device *dev;
     char       *np;
 
-    if (!(dev = getuserbychan (iip->channum)))
-        return ENOENT;
+       dev = getuserbychan(iip->channum);
+       if (!dev)
+               return -ENOENT;
 
     np = dev->name;
     strncpy (iip->iname, np, CHNM_STRLEN - 1);
index e08f79b63f1be6ca3f2e859461f75279f5581041..840c647fbf410798588724b6e10ebeb612fa901d 100644 (file)
@@ -72,7 +72,8 @@ static int sbecom_proc_get_sbe_info(struct seq_file *m, void *v)
        char       *spd;
        struct sbe_brd_info *bip;
 
-       if (!(bip = OS_kmalloc(sizeof(struct sbe_brd_info))))
+       bip = OS_kmalloc(sizeof(struct sbe_brd_info));
+       if (!bip)
                return -ENOMEM;
 
        pr_devel(">> sbecom_proc_get_sbe_info: entered\n");