drivers/net: replace BUG() with BUG_ON() if possible
authorAlexander Beregalov <a.beregalov@gmail.com>
Sat, 11 Apr 2009 14:50:23 +0000 (14:50 +0000)
committerDavid S. Miller <davem@davemloft.net>
Mon, 13 Apr 2009 22:44:36 +0000 (15:44 -0700)
Signed-off-by: Alexander Beregalov <a.beregalov@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
13 files changed:
drivers/net/atl1e/atl1e_main.c
drivers/net/atlx/atl1.c
drivers/net/chelsio/sge.c
drivers/net/fs_enet/mii-fec.c
drivers/net/ixgb/ixgb_osdep.h
drivers/net/pppol2tp.c
drivers/net/tulip/winbond-840.c
drivers/net/virtio_net.c
drivers/net/wireless/ath5k/reset.c
drivers/net/wireless/ath9k/ath9k.h
drivers/net/wireless/ipw2x00/ipw2200.c
drivers/net/wireless/libertas/if_usb.c
drivers/net/wireless/libertas_tf/if_usb.c

index fb57b750866bf53657ba680c7301b7fe683e9136..adac06195c8fc35977c2a3a71eef896c3a3f729f 100644 (file)
@@ -1794,8 +1794,7 @@ static void atl1e_tx_map(struct atl1e_adapter *adapter,
                        memcpy(use_tpd, tpd, sizeof(struct atl1e_tpd_desc));
 
                        tx_buffer = atl1e_get_tx_buffer(adapter, use_tpd);
-                       if (tx_buffer->skb)
-                               BUG();
+                       BUG_ON(tx_buffer->skb);
 
                        tx_buffer->skb = NULL;
                        tx_buffer->length =
index 0ab22540bf597a8ec6b97f8c4f54f2055608af0e..13f0bdc32449565e1e13966927f872281aa88550 100644 (file)
@@ -2207,8 +2207,7 @@ static void atl1_tx_map(struct atl1_adapter *adapter, struct sk_buff *skb,
        nr_frags = skb_shinfo(skb)->nr_frags;
        next_to_use = atomic_read(&tpd_ring->next_to_use);
        buffer_info = &tpd_ring->buffer_info[next_to_use];
-       if (unlikely(buffer_info->skb))
-               BUG();
+       BUG_ON(buffer_info->skb);
        /* put skb in last TPD */
        buffer_info->skb = NULL;
 
@@ -2274,8 +2273,8 @@ static void atl1_tx_map(struct atl1_adapter *adapter, struct sk_buff *skb,
                        ATL1_MAX_TX_BUF_LEN;
                for (i = 0; i < nseg; i++) {
                        buffer_info = &tpd_ring->buffer_info[next_to_use];
-                       if (unlikely(buffer_info->skb))
-                               BUG();
+                       BUG_ON(buffer_info->skb);
+
                        buffer_info->skb = NULL;
                        buffer_info->length = (buf_len > ATL1_MAX_TX_BUF_LEN) ?
                                ATL1_MAX_TX_BUF_LEN : buf_len;
index 58f6fc055f6a55cd1e9e3bc52af92b96cd31c9a4..5e97a1a71d887a92817d180aa8111f5a5034e098 100644 (file)
@@ -1149,8 +1149,8 @@ static inline void write_tx_desc(struct cmdQ_e *e, dma_addr_t mapping,
                                 unsigned int len, unsigned int gen,
                                 unsigned int eop)
 {
-       if (unlikely(len > SGE_TX_DESC_MAX_PLEN))
-               BUG();
+       BUG_ON(len > SGE_TX_DESC_MAX_PLEN);
+
        e->addr_lo = (u32)mapping;
        e->addr_hi = (u64)mapping >> 32;
        e->len_gen = V_CMD_LEN(len) | V_CMD_GEN1(gen);
index 28077cc1b9498e21932fd174e516cb303df95174..61aaae444b406d25d7957ab6d7f1f0633bf47b5e 100644 (file)
@@ -54,8 +54,7 @@ static int fs_enet_fec_mii_read(struct mii_bus *bus , int phy_id, int location)
        fec_t __iomem *fecp = fec->fecp;
        int i, ret = -1;
 
-       if ((in_be32(&fecp->fec_r_cntrl) & FEC_RCNTRL_MII_MODE) == 0)
-               BUG();
+       BUG_ON((in_be32(&fecp->fec_r_cntrl) & FEC_RCNTRL_MII_MODE) == 0);
 
        /* Add PHY address to register command.  */
        out_be32(&fecp->fec_mii_data, (phy_id << 23) | mk_mii_read(location));
@@ -79,8 +78,7 @@ static int fs_enet_fec_mii_write(struct mii_bus *bus, int phy_id, int location,
        int i;
 
        /* this must never happen */
-       if ((in_be32(&fecp->fec_r_cntrl) & FEC_RCNTRL_MII_MODE) == 0)
-               BUG();
+       BUG_ON((in_be32(&fecp->fec_r_cntrl) & FEC_RCNTRL_MII_MODE) == 0);
 
        /* Add PHY address to register command.  */
        out_be32(&fecp->fec_mii_data, (phy_id << 23) | mk_mii_write(location, val));
index d92e72bd627a08e91d8f4131fcda8d30ac762155..371a6be4d965b5a5cf0a852a9af8d71c0c614e7c 100644 (file)
@@ -40,7 +40,7 @@
 #include <linux/sched.h>
 
 #undef ASSERT
-#define ASSERT(x)      if (!(x)) BUG()
+#define ASSERT(x)      BUG_ON(!(x))
 #define MSGOUT(S, A, B)        printk(KERN_DEBUG S "\n", A, B)
 
 #ifdef DBG
index 5b07dd8e5c04e6b274e303b837c8243b31ba47dc..5981debcde5e4895fa1f787aa0baeb4bf5aba803 100644 (file)
@@ -1238,8 +1238,7 @@ static void pppol2tp_tunnel_closeall(struct pppol2tp_tunnel *tunnel)
        struct pppol2tp_session *session;
        struct sock *sk;
 
-       if (tunnel == NULL)
-               BUG();
+       BUG_ON(tunnel == NULL);
 
        PRINTK(tunnel->debug, PPPOL2TP_MSG_CONTROL, KERN_INFO,
               "%s: closing all sessions...\n", tunnel->name);
index 264e61404f345a8d36d9ee2cdabf2df4ec2a99f9..842b1a2c40d4abed18d9d241c8759f1daaaae8be 100644 (file)
@@ -1601,8 +1601,7 @@ static int w840_suspend (struct pci_dev *pdev, pm_message_t state)
 
                /* no more hardware accesses behind this line. */
 
-               BUG_ON(np->csr6);
-               if (ioread32(ioaddr + IntrEnable)) BUG();
+               BUG_ON(np->csr6 || ioread32(ioaddr + IntrEnable));
 
                /* pci_power_off(pdev, -1); */
 
index 9c82a39497e5f9f3aae73b8df04c78cbaf8311df..0718558715244a17ccaf8e20526653c9db912609 100644 (file)
@@ -621,12 +621,9 @@ static bool virtnet_send_command(struct virtnet_info *vi, u8 class, u8 cmd,
        virtio_net_ctrl_ack status = ~0;
        unsigned int tmp;
 
-       if (!virtio_has_feature(vi->vdev, VIRTIO_NET_F_CTRL_VQ)) {
-               BUG();  /* Caller should know better */
-               return false;
-       }
-
-       BUG_ON(out + in > VIRTNET_SEND_COMMAND_SG_MAX);
+       /* Caller should know better */
+       BUG_ON(!virtio_has_feature(vi->vdev, VIRTIO_NET_F_CTRL_VQ) ||
+               (out + in > VIRTNET_SEND_COMMAND_SG_MAX));
 
        out++; /* Add header */
        in++; /* Add return status */
@@ -640,8 +637,7 @@ static bool virtnet_send_command(struct virtnet_info *vi, u8 class, u8 cmd,
        memcpy(&sg[1], data, sizeof(struct scatterlist) * (out + in - 2));
        sg_set_buf(&sg[out + in - 1], &status, sizeof(status));
 
-       if (vi->cvq->vq_ops->add_buf(vi->cvq, sg, out, in, vi) != 0)
-               BUG();
+       BUG_ON(vi->cvq->vq_ops->add_buf(vi->cvq, sg, out, in, vi));
 
        vi->cvq->vq_ops->kick(vi->cvq);
 
index 7a17d31b2fd9f762a2bd8870639e7e0ed8b3723c..cb5e15f97095f654a4ece6d23741ee4abb4daee8 100644 (file)
@@ -54,9 +54,8 @@ static inline int ath5k_hw_write_ofdm_timings(struct ath5k_hw *ah,
        u32 coef_scaled, coef_exp, coef_man,
                ds_coef_exp, ds_coef_man, clock;
 
-       if (!(ah->ah_version == AR5K_AR5212) ||
-               !(channel->hw_value & CHANNEL_OFDM))
-               BUG();
+       BUG_ON(!(ah->ah_version == AR5K_AR5212) ||
+               !(channel->hw_value & CHANNEL_OFDM));
 
        /* Get coefficient
         * ALGO: coef = (5 * clock * carrier_freq) / 2)
index 2689a08a2844e045d97b67d2fbcf1f658bfe3e37..7b1b40aaf09d2c2e739a584eb4451000650a1db0 100644 (file)
@@ -53,11 +53,7 @@ struct ath_node;
 
 #define A_MAX(a, b) ((a) > (b) ? (a) : (b))
 
-#define ASSERT(exp) do {                       \
-               if (unlikely(!(exp))) {         \
-                       BUG();                  \
-               }                               \
-       } while (0)
+#define ASSERT(exp) BUG_ON(!(exp))
 
 #define TSF_TO_TU(_h,_l) \
        ((((u32)(_h)) << 22) | (((u32)(_l)) >> 10))
index bd4dbcfe1bbe9c54b675b07a8a9ed74004894a8f..9a123fbcc35997408127b9d4bad6aabae2630b26 100644 (file)
@@ -3176,11 +3176,8 @@ static int ipw_load_firmware(struct ipw_priv *priv, u8 * data, size_t len)
        /* Start the Dma */
        rc = ipw_fw_dma_enable(priv);
 
-       if (priv->sram_desc.last_cb_index > 0) {
-               /* the DMA is already ready this would be a bug. */
-               BUG();
-               goto out;
-       }
+       /* the DMA is already ready this would be a bug. */
+       BUG_ON(priv->sram_desc.last_cb_index > 0);
 
        do {
                chunk = (struct fw_chunk *)(data + offset);
index ea3dc038be76e3c88d89abb9e75328b993501b77..d649caebf08a1e93ffd9a136f7682340fe380f33 100644 (file)
@@ -686,8 +686,7 @@ static inline void process_cmdrequest(int recvlength, uint8_t *recvbuff,
                return;
        }
 
-       if (!in_interrupt())
-               BUG();
+       BUG_ON(!in_interrupt());
 
        spin_lock(&priv->driver_lock);
 
index 59634c33b1f9194f4e10ed8fc36e2d9aed30ef4e..392337b37b1ddcc728365eec9848cfc329e9d0f5 100644 (file)
@@ -461,8 +461,7 @@ static inline void process_cmdrequest(int recvlength, uint8_t *recvbuff,
                return;
        }
 
-       if (!in_interrupt())
-               BUG();
+       BUG_ON(!in_interrupt());
 
        spin_lock(&priv->driver_lock);
        memcpy(priv->cmd_resp_buff, recvbuff + MESSAGE_HEADER_LEN,