BUG_ON() Conversion in drivers/net/
authorEric Sesterhenn <snakebyte@gmx.de>
Sun, 2 Apr 2006 11:52:48 +0000 (13:52 +0200)
committerAdrian Bunk <bunk@stusta.de>
Sun, 2 Apr 2006 11:52:48 +0000 (13:52 +0200)
this changes if() BUG(); constructs to BUG_ON() which is
cleaner, contains unlikely() and can better optimized away.

Signed-off-by: Eric Sesterhenn <snakebyte@gmx.de>
Signed-off-by: Adrian Bunk <bunk@stusta.de>
15 files changed:
drivers/net/8139cp.c
drivers/net/arcnet/arcnet.c
drivers/net/b44.c
drivers/net/chelsio/sge.c
drivers/net/e1000/e1000_main.c
drivers/net/eql.c
drivers/net/irda/sa1100_ir.c
drivers/net/ne2k-pci.c
drivers/net/ns83820.c
drivers/net/starfire.c
drivers/net/tg3.c
drivers/net/tokenring/abyss.c
drivers/net/tokenring/madgemc.c
drivers/net/wireless/ipw2200.c
drivers/net/yellowfin.c

index ce99845d8266a19371df7f1d52e813f6e6b52868..066e22b01a941ed90fcc3edf028ed217b8688da0 100644 (file)
@@ -539,8 +539,7 @@ rx_status_loop:
                unsigned buflen;
 
                skb = cp->rx_skb[rx_tail].skb;
-               if (!skb)
-                       BUG();
+               BUG_ON(!skb);
 
                desc = &cp->rx_ring[rx_tail];
                status = le32_to_cpu(desc->opts1);
@@ -723,8 +722,7 @@ static void cp_tx (struct cp_private *cp)
                        break;
 
                skb = cp->tx_skb[tx_tail].skb;
-               if (!skb)
-                       BUG();
+               BUG_ON(!skb);
 
                pci_unmap_single(cp->pdev, cp->tx_skb[tx_tail].mapping,
                                 cp->tx_skb[tx_tail].len, PCI_DMA_TODEVICE);
@@ -1550,8 +1548,7 @@ static void cp_get_ethtool_stats (struct net_device *dev,
        tmp_stats[i++] = le16_to_cpu(nic_stats->tx_abort);
        tmp_stats[i++] = le16_to_cpu(nic_stats->tx_underrun);
        tmp_stats[i++] = cp->cp_stats.rx_frags;
-       if (i != CP_NUM_STATS)
-               BUG();
+       BUG_ON(i != CP_NUM_STATS);
 
        pci_free_consistent(cp->pdev, sizeof(*nic_stats), nic_stats, dma);
 }
@@ -1856,8 +1853,7 @@ static void cp_remove_one (struct pci_dev *pdev)
        struct net_device *dev = pci_get_drvdata(pdev);
        struct cp_private *cp = netdev_priv(dev);
 
-       if (!dev)
-               BUG();
+       BUG_ON(!dev);
        unregister_netdev(dev);
        iounmap(cp->regs);
        if (cp->wol_enabled) pci_set_power_state (pdev, PCI_D0);
index 64e2caf3083df508775207e5346d4cd871bc9b6b..fabc0607b0f1d15a500b1abd6989507ac2777561 100644 (file)
@@ -765,8 +765,7 @@ irqreturn_t arcnet_interrupt(int irq, void *dev_id, struct pt_regs *regs)
        BUGMSG(D_DURING, "in arcnet_interrupt\n");
        
        lp = dev->priv;
-       if (!lp)
-               BUG();
+       BUG_ON(!lp);
                
        spin_lock(&lp->lock);
 
index 15032f2c78179f5564b32133b38f2989f3e9a3b4..c4e12b5cbb92c2f4cb2412e7ece8d22151c902df 100644 (file)
@@ -608,8 +608,7 @@ static void b44_tx(struct b44 *bp)
                struct ring_info *rp = &bp->tx_buffers[cons];
                struct sk_buff *skb = rp->skb;
 
-               if (unlikely(skb == NULL))
-                       BUG();
+               BUG_ON(skb == NULL);
 
                pci_unmap_single(bp->pdev,
                                 pci_unmap_addr(rp, mapping),
index 30ff8ea1a402602761bb75994a092b759c662835..4391bf4bf573ad61796033ded66c22668225c703 100644 (file)
@@ -1093,8 +1093,7 @@ static int process_responses(struct adapter *adapter, int budget)
                if (likely(e->DataValid)) {
                        struct freelQ *fl = &sge->freelQ[e->FreelistQid];
 
-                       if (unlikely(!e->Sop || !e->Eop))
-                               BUG();
+                       BUG_ON(!e->Sop || !e->Eop);
                        if (unlikely(e->Offload))
                                unexpected_offload(adapter, fl);
                        else
index 49cd096a3c3d03a92a2185265d77acfa599f4447..add8dc4aa7b04b1510b43a5c4860fe21fd011aea 100644 (file)
@@ -3308,8 +3308,7 @@ e1000_clean(struct net_device *poll_dev, int *budget)
 
        while (poll_dev != &adapter->polling_netdev[i]) {
                i++;
-               if (unlikely(i == adapter->num_rx_queues))
-                       BUG();
+               BUG_ON(i == adapter->num_rx_queues);
        }
 
        if (likely(adapter->num_tx_queues == 1)) {
index aa1569182fd62e86ae01a8f5cf7049d504cc6480..815436c6170f5d707caf8fd67029fa6469ac8fed 100644 (file)
@@ -203,8 +203,7 @@ static int eql_open(struct net_device *dev)
        printk(KERN_INFO "%s: remember to turn off Van-Jacobson compression on "
               "your slave devices.\n", dev->name);
 
-       if (!list_empty(&eql->queue.all_slaves))
-               BUG();
+       BUG_ON(!list_empty(&eql->queue.all_slaves));
 
        eql->min_slaves = 1;
        eql->max_slaves = EQL_DEFAULT_MAX_SLAVES; /* 4 usually... */
index 63d38fbbd04ecb59e6e42748d162af2c4968e4af..f530686bd09f80fc374a2d4c5d2bcb95e7c44a09 100644 (file)
@@ -695,8 +695,7 @@ static int sa1100_irda_hard_xmit(struct sk_buff *skb, struct net_device *dev)
                /*
                 * We must not be transmitting...
                 */
-               if (si->txskb)
-                       BUG();
+               BUG_ON(si->txskb);
 
                netif_stop_queue(dev);
 
index d11821dd86edbf94015c7143e048d4da5b5bfde7..ced9fdb8335cc4225639cf49d67612d066833a31 100644 (file)
@@ -645,9 +645,7 @@ static void __devexit ne2k_pci_remove_one (struct pci_dev *pdev)
 {
        struct net_device *dev = pci_get_drvdata(pdev);
 
-       if (!dev)
-               BUG();
-
+       BUG_ON(!dev);
        unregister_netdev(dev);
        release_region(dev->base_addr, NE_IO_EXTENT);
        free_netdev(dev);
index 8e9b1a537deeaca0dedf55337c5626cc0d55c556..706aed7d717f5ec5200a0287476c446cc7e8a901 100644 (file)
@@ -568,8 +568,7 @@ static inline int ns83820_add_rx_skb(struct ns83820 *dev, struct sk_buff *skb)
 #endif
 
        sg = dev->rx_info.descs + (next_empty * DESC_SIZE);
-       if (unlikely(NULL != dev->rx_info.skbs[next_empty]))
-               BUG();
+       BUG_ON(NULL != dev->rx_info.skbs[next_empty]);
        dev->rx_info.skbs[next_empty] = skb;
 
        dev->rx_info.next_empty = (next_empty + 1) % NR_RX_DESC;
index 35b18057fbdd4607481b2e5a2245976dc71fcb1a..45ad036733e2135986b05a985b687b60e8e4cca6 100644 (file)
@@ -2122,8 +2122,7 @@ static void __devexit starfire_remove_one (struct pci_dev *pdev)
        struct net_device *dev = pci_get_drvdata(pdev);
        struct netdev_private *np = netdev_priv(dev);
 
-       if (!dev)
-               BUG();
+       BUG_ON(!dev);
 
        unregister_netdev(dev);
 
index 964c0964483246f70bfd9bf5e04e9a26e38b931f..46f55fb9a053a1fdab97067100aa460d162c3900 100644 (file)
@@ -2966,9 +2966,7 @@ static void tg3_tx(struct tg3 *tp)
                struct sk_buff *skb = ri->skb;
                int i;
 
-               if (unlikely(skb == NULL))
-                       BUG();
-
+               BUG_ON(skb == NULL);
                pci_unmap_single(tp->pdev,
                                 pci_unmap_addr(ri, mapping),
                                 skb_headlen(skb),
@@ -2979,12 +2977,10 @@ static void tg3_tx(struct tg3 *tp)
                sw_idx = NEXT_TX(sw_idx);
 
                for (i = 0; i < skb_shinfo(skb)->nr_frags; i++) {
-                       if (unlikely(sw_idx == hw_idx))
-                               BUG();
+                       BUG_ON(sw_idx == hw_idx);
 
                        ri = &tp->tx_buffers[sw_idx];
-                       if (unlikely(ri->skb != NULL))
-                               BUG();
+                       BUG_ON(ri->skb != NULL);
 
                        pci_unmap_page(tp->pdev,
                                       pci_unmap_addr(ri, mapping),
@@ -4935,9 +4931,8 @@ static int tg3_halt_cpu(struct tg3 *tp, u32 offset)
 {
        int i;
 
-       if (offset == TX_CPU_BASE &&
-           (tp->tg3_flags2 & TG3_FLG2_5705_PLUS))
-               BUG();
+       BUG_ON(offset == TX_CPU_BASE &&
+           (tp->tg3_flags2 & TG3_FLG2_5705_PLUS));
 
        if (offset == RX_CPU_BASE) {
                for (i = 0; i < 10000; i++) {
index 9345e68c451eb4af5111f27ba40b5eb0bbd254d2..649d8ea354f553688a6a7bb4373e0a6c5e5210ad 100644 (file)
@@ -438,8 +438,7 @@ static void __devexit abyss_detach (struct pci_dev *pdev)
 {
        struct net_device *dev = pci_get_drvdata(pdev);
        
-       if (!dev)
-               BUG();
+       BUG_ON(!dev);
        unregister_netdev(dev);
        release_region(dev->base_addr-0x10, ABYSS_IO_EXTENT);
        free_irq(dev->irq, dev);
index 3a25d191ea4af322ae851edd38f5128afb40cd88..19e6f4dfd69ce8478a86c200f060dd97d529efa5 100644 (file)
@@ -735,8 +735,7 @@ static int __devexit madgemc_remove(struct device *device)
        struct net_local *tp;
         struct card_info *card;
 
-       if (!dev)
-               BUG();
+       BUG_ON(!dev);
 
        tp = dev->priv;
        card = tp->tmspriv;
index 9dce522526c5ca78f506d00249de59cdb57c9f55..bca89cff85a63ccaf0204b349b7ab700de369dbe 100644 (file)
@@ -5573,8 +5573,7 @@ static void ipw_adhoc_create(struct ipw_priv *priv,
        case IEEE80211_52GHZ_BAND:
                network->mode = IEEE_A;
                i = ieee80211_channel_to_index(priv->ieee, priv->channel);
-               if (i == -1)
-                       BUG();
+               BUG_ON(i == -1);
                if (geo->a[i].flags & IEEE80211_CH_PASSIVE_ONLY) {
                        IPW_WARNING("Overriding invalid channel\n");
                        priv->channel = geo->a[0].channel;
@@ -5587,8 +5586,7 @@ static void ipw_adhoc_create(struct ipw_priv *priv,
                else
                        network->mode = IEEE_B;
                i = ieee80211_channel_to_index(priv->ieee, priv->channel);
-               if (i == -1)
-                       BUG();
+               BUG_ON(i == -1);
                if (geo->bg[i].flags & IEEE80211_CH_PASSIVE_ONLY) {
                        IPW_WARNING("Overriding invalid channel\n");
                        priv->channel = geo->bg[0].channel;
@@ -6715,8 +6713,7 @@ static int ipw_qos_association(struct ipw_priv *priv,
 
        switch (priv->ieee->iw_mode) {
        case IW_MODE_ADHOC:
-               if (!(network->capability & WLAN_CAPABILITY_IBSS))
-                       BUG();
+               BUG_ON(!(network->capability & WLAN_CAPABILITY_IBSS));
 
                qos_data = &ibss_data;
                break;
index 75d56bfef0ee7475ed87e9ab51ac37f660506587..fd0f43b7db5b089248d27f90fe0851ee2b7b382c 100644 (file)
@@ -1441,8 +1441,7 @@ static void __devexit yellowfin_remove_one (struct pci_dev *pdev)
        struct net_device *dev = pci_get_drvdata(pdev);
        struct yellowfin_private *np;
 
-       if (!dev)
-               BUG();
+       BUG_ON(!dev);
        np = netdev_priv(dev);
 
         pci_free_consistent(pdev, STATUS_TOTAL_SIZE, np->tx_status,