Commit 5d9428de authored by Eric Sesterhenn's avatar Eric Sesterhenn Committed by Adrian Bunk

BUG_ON() Conversion in drivers/net/

this changes if() BUG(); constructs to BUG_ON() which is
cleaner, contains unlikely() and can better optimized away.
Signed-off-by: default avatarEric Sesterhenn <snakebyte@gmx.de>
Signed-off-by: default avatarAdrian Bunk <bunk@stusta.de>
parent 7e99e9b6
...@@ -539,8 +539,7 @@ static int cp_rx_poll (struct net_device *dev, int *budget) ...@@ -539,8 +539,7 @@ static int cp_rx_poll (struct net_device *dev, int *budget)
unsigned buflen; unsigned buflen;
skb = cp->rx_skb[rx_tail].skb; skb = cp->rx_skb[rx_tail].skb;
if (!skb) BUG_ON(!skb);
BUG();
desc = &cp->rx_ring[rx_tail]; desc = &cp->rx_ring[rx_tail];
status = le32_to_cpu(desc->opts1); status = le32_to_cpu(desc->opts1);
...@@ -723,8 +722,7 @@ static void cp_tx (struct cp_private *cp) ...@@ -723,8 +722,7 @@ static void cp_tx (struct cp_private *cp)
break; break;
skb = cp->tx_skb[tx_tail].skb; skb = cp->tx_skb[tx_tail].skb;
if (!skb) BUG_ON(!skb);
BUG();
pci_unmap_single(cp->pdev, cp->tx_skb[tx_tail].mapping, pci_unmap_single(cp->pdev, cp->tx_skb[tx_tail].mapping,
cp->tx_skb[tx_tail].len, PCI_DMA_TODEVICE); cp->tx_skb[tx_tail].len, PCI_DMA_TODEVICE);
...@@ -1550,8 +1548,7 @@ static void cp_get_ethtool_stats (struct net_device *dev, ...@@ -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_abort);
tmp_stats[i++] = le16_to_cpu(nic_stats->tx_underrun); tmp_stats[i++] = le16_to_cpu(nic_stats->tx_underrun);
tmp_stats[i++] = cp->cp_stats.rx_frags; tmp_stats[i++] = cp->cp_stats.rx_frags;
if (i != CP_NUM_STATS) BUG_ON(i != CP_NUM_STATS);
BUG();
pci_free_consistent(cp->pdev, sizeof(*nic_stats), nic_stats, dma); pci_free_consistent(cp->pdev, sizeof(*nic_stats), nic_stats, dma);
} }
...@@ -1856,8 +1853,7 @@ static void cp_remove_one (struct pci_dev *pdev) ...@@ -1856,8 +1853,7 @@ static void cp_remove_one (struct pci_dev *pdev)
struct net_device *dev = pci_get_drvdata(pdev); struct net_device *dev = pci_get_drvdata(pdev);
struct cp_private *cp = netdev_priv(dev); struct cp_private *cp = netdev_priv(dev);
if (!dev) BUG_ON(!dev);
BUG();
unregister_netdev(dev); unregister_netdev(dev);
iounmap(cp->regs); iounmap(cp->regs);
if (cp->wol_enabled) pci_set_power_state (pdev, PCI_D0); if (cp->wol_enabled) pci_set_power_state (pdev, PCI_D0);
......
...@@ -765,8 +765,7 @@ irqreturn_t arcnet_interrupt(int irq, void *dev_id, struct pt_regs *regs) ...@@ -765,8 +765,7 @@ irqreturn_t arcnet_interrupt(int irq, void *dev_id, struct pt_regs *regs)
BUGMSG(D_DURING, "in arcnet_interrupt\n"); BUGMSG(D_DURING, "in arcnet_interrupt\n");
lp = dev->priv; lp = dev->priv;
if (!lp) BUG_ON(!lp);
BUG();
spin_lock(&lp->lock); spin_lock(&lp->lock);
......
...@@ -608,8 +608,7 @@ static void b44_tx(struct b44 *bp) ...@@ -608,8 +608,7 @@ static void b44_tx(struct b44 *bp)
struct ring_info *rp = &bp->tx_buffers[cons]; struct ring_info *rp = &bp->tx_buffers[cons];
struct sk_buff *skb = rp->skb; struct sk_buff *skb = rp->skb;
if (unlikely(skb == NULL)) BUG_ON(skb == NULL);
BUG();
pci_unmap_single(bp->pdev, pci_unmap_single(bp->pdev,
pci_unmap_addr(rp, mapping), pci_unmap_addr(rp, mapping),
......
...@@ -1093,8 +1093,7 @@ static int process_responses(struct adapter *adapter, int budget) ...@@ -1093,8 +1093,7 @@ static int process_responses(struct adapter *adapter, int budget)
if (likely(e->DataValid)) { if (likely(e->DataValid)) {
struct freelQ *fl = &sge->freelQ[e->FreelistQid]; struct freelQ *fl = &sge->freelQ[e->FreelistQid];
if (unlikely(!e->Sop || !e->Eop)) BUG_ON(!e->Sop || !e->Eop);
BUG();
if (unlikely(e->Offload)) if (unlikely(e->Offload))
unexpected_offload(adapter, fl); unexpected_offload(adapter, fl);
else else
......
...@@ -3308,8 +3308,7 @@ e1000_clean(struct net_device *poll_dev, int *budget) ...@@ -3308,8 +3308,7 @@ e1000_clean(struct net_device *poll_dev, int *budget)
while (poll_dev != &adapter->polling_netdev[i]) { while (poll_dev != &adapter->polling_netdev[i]) {
i++; i++;
if (unlikely(i == adapter->num_rx_queues)) BUG_ON(i == adapter->num_rx_queues);
BUG();
} }
if (likely(adapter->num_tx_queues == 1)) { if (likely(adapter->num_tx_queues == 1)) {
......
...@@ -203,8 +203,7 @@ static int eql_open(struct net_device *dev) ...@@ -203,8 +203,7 @@ static int eql_open(struct net_device *dev)
printk(KERN_INFO "%s: remember to turn off Van-Jacobson compression on " printk(KERN_INFO "%s: remember to turn off Van-Jacobson compression on "
"your slave devices.\n", dev->name); "your slave devices.\n", dev->name);
if (!list_empty(&eql->queue.all_slaves)) BUG_ON(!list_empty(&eql->queue.all_slaves));
BUG();
eql->min_slaves = 1; eql->min_slaves = 1;
eql->max_slaves = EQL_DEFAULT_MAX_SLAVES; /* 4 usually... */ eql->max_slaves = EQL_DEFAULT_MAX_SLAVES; /* 4 usually... */
......
...@@ -695,8 +695,7 @@ static int sa1100_irda_hard_xmit(struct sk_buff *skb, struct net_device *dev) ...@@ -695,8 +695,7 @@ static int sa1100_irda_hard_xmit(struct sk_buff *skb, struct net_device *dev)
/* /*
* We must not be transmitting... * We must not be transmitting...
*/ */
if (si->txskb) BUG_ON(si->txskb);
BUG();
netif_stop_queue(dev); netif_stop_queue(dev);
......
...@@ -645,9 +645,7 @@ static void __devexit ne2k_pci_remove_one (struct pci_dev *pdev) ...@@ -645,9 +645,7 @@ static void __devexit ne2k_pci_remove_one (struct pci_dev *pdev)
{ {
struct net_device *dev = pci_get_drvdata(pdev); struct net_device *dev = pci_get_drvdata(pdev);
if (!dev) BUG_ON(!dev);
BUG();
unregister_netdev(dev); unregister_netdev(dev);
release_region(dev->base_addr, NE_IO_EXTENT); release_region(dev->base_addr, NE_IO_EXTENT);
free_netdev(dev); free_netdev(dev);
......
...@@ -568,8 +568,7 @@ static inline int ns83820_add_rx_skb(struct ns83820 *dev, struct sk_buff *skb) ...@@ -568,8 +568,7 @@ static inline int ns83820_add_rx_skb(struct ns83820 *dev, struct sk_buff *skb)
#endif #endif
sg = dev->rx_info.descs + (next_empty * DESC_SIZE); sg = dev->rx_info.descs + (next_empty * DESC_SIZE);
if (unlikely(NULL != dev->rx_info.skbs[next_empty])) BUG_ON(NULL != dev->rx_info.skbs[next_empty]);
BUG();
dev->rx_info.skbs[next_empty] = skb; dev->rx_info.skbs[next_empty] = skb;
dev->rx_info.next_empty = (next_empty + 1) % NR_RX_DESC; dev->rx_info.next_empty = (next_empty + 1) % NR_RX_DESC;
......
...@@ -2122,8 +2122,7 @@ static void __devexit starfire_remove_one (struct pci_dev *pdev) ...@@ -2122,8 +2122,7 @@ static void __devexit starfire_remove_one (struct pci_dev *pdev)
struct net_device *dev = pci_get_drvdata(pdev); struct net_device *dev = pci_get_drvdata(pdev);
struct netdev_private *np = netdev_priv(dev); struct netdev_private *np = netdev_priv(dev);
if (!dev) BUG_ON(!dev);
BUG();
unregister_netdev(dev); unregister_netdev(dev);
......
...@@ -2966,9 +2966,7 @@ static void tg3_tx(struct tg3 *tp) ...@@ -2966,9 +2966,7 @@ static void tg3_tx(struct tg3 *tp)
struct sk_buff *skb = ri->skb; struct sk_buff *skb = ri->skb;
int i; int i;
if (unlikely(skb == NULL)) BUG_ON(skb == NULL);
BUG();
pci_unmap_single(tp->pdev, pci_unmap_single(tp->pdev,
pci_unmap_addr(ri, mapping), pci_unmap_addr(ri, mapping),
skb_headlen(skb), skb_headlen(skb),
...@@ -2979,12 +2977,10 @@ static void tg3_tx(struct tg3 *tp) ...@@ -2979,12 +2977,10 @@ static void tg3_tx(struct tg3 *tp)
sw_idx = NEXT_TX(sw_idx); sw_idx = NEXT_TX(sw_idx);
for (i = 0; i < skb_shinfo(skb)->nr_frags; i++) { for (i = 0; i < skb_shinfo(skb)->nr_frags; i++) {
if (unlikely(sw_idx == hw_idx)) BUG_ON(sw_idx == hw_idx);
BUG();
ri = &tp->tx_buffers[sw_idx]; ri = &tp->tx_buffers[sw_idx];
if (unlikely(ri->skb != NULL)) BUG_ON(ri->skb != NULL);
BUG();
pci_unmap_page(tp->pdev, pci_unmap_page(tp->pdev,
pci_unmap_addr(ri, mapping), pci_unmap_addr(ri, mapping),
...@@ -4935,9 +4931,8 @@ static int tg3_halt_cpu(struct tg3 *tp, u32 offset) ...@@ -4935,9 +4931,8 @@ static int tg3_halt_cpu(struct tg3 *tp, u32 offset)
{ {
int i; int i;
if (offset == TX_CPU_BASE && BUG_ON(offset == TX_CPU_BASE &&
(tp->tg3_flags2 & TG3_FLG2_5705_PLUS)) (tp->tg3_flags2 & TG3_FLG2_5705_PLUS));
BUG();
if (offset == RX_CPU_BASE) { if (offset == RX_CPU_BASE) {
for (i = 0; i < 10000; i++) { for (i = 0; i < 10000; i++) {
......
...@@ -438,8 +438,7 @@ static void __devexit abyss_detach (struct pci_dev *pdev) ...@@ -438,8 +438,7 @@ static void __devexit abyss_detach (struct pci_dev *pdev)
{ {
struct net_device *dev = pci_get_drvdata(pdev); struct net_device *dev = pci_get_drvdata(pdev);
if (!dev) BUG_ON(!dev);
BUG();
unregister_netdev(dev); unregister_netdev(dev);
release_region(dev->base_addr-0x10, ABYSS_IO_EXTENT); release_region(dev->base_addr-0x10, ABYSS_IO_EXTENT);
free_irq(dev->irq, dev); free_irq(dev->irq, dev);
......
...@@ -735,8 +735,7 @@ static int __devexit madgemc_remove(struct device *device) ...@@ -735,8 +735,7 @@ static int __devexit madgemc_remove(struct device *device)
struct net_local *tp; struct net_local *tp;
struct card_info *card; struct card_info *card;
if (!dev) BUG_ON(!dev);
BUG();
tp = dev->priv; tp = dev->priv;
card = tp->tmspriv; card = tp->tmspriv;
......
...@@ -5573,8 +5573,7 @@ static void ipw_adhoc_create(struct ipw_priv *priv, ...@@ -5573,8 +5573,7 @@ static void ipw_adhoc_create(struct ipw_priv *priv,
case IEEE80211_52GHZ_BAND: case IEEE80211_52GHZ_BAND:
network->mode = IEEE_A; network->mode = IEEE_A;
i = ieee80211_channel_to_index(priv->ieee, priv->channel); i = ieee80211_channel_to_index(priv->ieee, priv->channel);
if (i == -1) BUG_ON(i == -1);
BUG();
if (geo->a[i].flags & IEEE80211_CH_PASSIVE_ONLY) { if (geo->a[i].flags & IEEE80211_CH_PASSIVE_ONLY) {
IPW_WARNING("Overriding invalid channel\n"); IPW_WARNING("Overriding invalid channel\n");
priv->channel = geo->a[0].channel; priv->channel = geo->a[0].channel;
...@@ -5587,8 +5586,7 @@ static void ipw_adhoc_create(struct ipw_priv *priv, ...@@ -5587,8 +5586,7 @@ static void ipw_adhoc_create(struct ipw_priv *priv,
else else
network->mode = IEEE_B; network->mode = IEEE_B;
i = ieee80211_channel_to_index(priv->ieee, priv->channel); i = ieee80211_channel_to_index(priv->ieee, priv->channel);
if (i == -1) BUG_ON(i == -1);
BUG();
if (geo->bg[i].flags & IEEE80211_CH_PASSIVE_ONLY) { if (geo->bg[i].flags & IEEE80211_CH_PASSIVE_ONLY) {
IPW_WARNING("Overriding invalid channel\n"); IPW_WARNING("Overriding invalid channel\n");
priv->channel = geo->bg[0].channel; priv->channel = geo->bg[0].channel;
...@@ -6715,8 +6713,7 @@ static int ipw_qos_association(struct ipw_priv *priv, ...@@ -6715,8 +6713,7 @@ static int ipw_qos_association(struct ipw_priv *priv,
switch (priv->ieee->iw_mode) { switch (priv->ieee->iw_mode) {
case IW_MODE_ADHOC: case IW_MODE_ADHOC:
if (!(network->capability & WLAN_CAPABILITY_IBSS)) BUG_ON(!(network->capability & WLAN_CAPABILITY_IBSS));
BUG();
qos_data = &ibss_data; qos_data = &ibss_data;
break; break;
......
...@@ -1441,8 +1441,7 @@ static void __devexit yellowfin_remove_one (struct pci_dev *pdev) ...@@ -1441,8 +1441,7 @@ static void __devexit yellowfin_remove_one (struct pci_dev *pdev)
struct net_device *dev = pci_get_drvdata(pdev); struct net_device *dev = pci_get_drvdata(pdev);
struct yellowfin_private *np; struct yellowfin_private *np;
if (!dev) BUG_ON(!dev);
BUG();
np = netdev_priv(dev); np = netdev_priv(dev);
pci_free_consistent(pdev, STATUS_TOTAL_SIZE, np->tx_status, pci_free_consistent(pdev, STATUS_TOTAL_SIZE, np->tx_status,
......
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