Skip to content

Commit 0ee904c

Browse files
alexb0davem330
authored andcommitted
drivers/net: replace BUG() with BUG_ON() if possible
Signed-off-by: Alexander Beregalov <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 710b523 commit 0ee904c

File tree

13 files changed

+22
-42
lines changed

13 files changed

+22
-42
lines changed

drivers/net/atl1e/atl1e_main.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1794,8 +1794,7 @@ static void atl1e_tx_map(struct atl1e_adapter *adapter,
17941794
memcpy(use_tpd, tpd, sizeof(struct atl1e_tpd_desc));
17951795

17961796
tx_buffer = atl1e_get_tx_buffer(adapter, use_tpd);
1797-
if (tx_buffer->skb)
1798-
BUG();
1797+
BUG_ON(tx_buffer->skb);
17991798

18001799
tx_buffer->skb = NULL;
18011800
tx_buffer->length =

drivers/net/atlx/atl1.c

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2207,8 +2207,7 @@ static void atl1_tx_map(struct atl1_adapter *adapter, struct sk_buff *skb,
22072207
nr_frags = skb_shinfo(skb)->nr_frags;
22082208
next_to_use = atomic_read(&tpd_ring->next_to_use);
22092209
buffer_info = &tpd_ring->buffer_info[next_to_use];
2210-
if (unlikely(buffer_info->skb))
2211-
BUG();
2210+
BUG_ON(buffer_info->skb);
22122211
/* put skb in last TPD */
22132212
buffer_info->skb = NULL;
22142213

@@ -2274,8 +2273,8 @@ static void atl1_tx_map(struct atl1_adapter *adapter, struct sk_buff *skb,
22742273
ATL1_MAX_TX_BUF_LEN;
22752274
for (i = 0; i < nseg; i++) {
22762275
buffer_info = &tpd_ring->buffer_info[next_to_use];
2277-
if (unlikely(buffer_info->skb))
2278-
BUG();
2276+
BUG_ON(buffer_info->skb);
2277+
22792278
buffer_info->skb = NULL;
22802279
buffer_info->length = (buf_len > ATL1_MAX_TX_BUF_LEN) ?
22812280
ATL1_MAX_TX_BUF_LEN : buf_len;

drivers/net/chelsio/sge.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1149,8 +1149,8 @@ static inline void write_tx_desc(struct cmdQ_e *e, dma_addr_t mapping,
11491149
unsigned int len, unsigned int gen,
11501150
unsigned int eop)
11511151
{
1152-
if (unlikely(len > SGE_TX_DESC_MAX_PLEN))
1153-
BUG();
1152+
BUG_ON(len > SGE_TX_DESC_MAX_PLEN);
1153+
11541154
e->addr_lo = (u32)mapping;
11551155
e->addr_hi = (u64)mapping >> 32;
11561156
e->len_gen = V_CMD_LEN(len) | V_CMD_GEN1(gen);

drivers/net/fs_enet/mii-fec.c

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -54,8 +54,7 @@ static int fs_enet_fec_mii_read(struct mii_bus *bus , int phy_id, int location)
5454
fec_t __iomem *fecp = fec->fecp;
5555
int i, ret = -1;
5656

57-
if ((in_be32(&fecp->fec_r_cntrl) & FEC_RCNTRL_MII_MODE) == 0)
58-
BUG();
57+
BUG_ON((in_be32(&fecp->fec_r_cntrl) & FEC_RCNTRL_MII_MODE) == 0);
5958

6059
/* Add PHY address to register command. */
6160
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,
7978
int i;
8079

8180
/* this must never happen */
82-
if ((in_be32(&fecp->fec_r_cntrl) & FEC_RCNTRL_MII_MODE) == 0)
83-
BUG();
81+
BUG_ON((in_be32(&fecp->fec_r_cntrl) & FEC_RCNTRL_MII_MODE) == 0);
8482

8583
/* Add PHY address to register command. */
8684
out_be32(&fecp->fec_mii_data, (phy_id << 23) | mk_mii_write(location, val));

drivers/net/ixgb/ixgb_osdep.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@
4040
#include <linux/sched.h>
4141

4242
#undef ASSERT
43-
#define ASSERT(x) if (!(x)) BUG()
43+
#define ASSERT(x) BUG_ON(!(x))
4444
#define MSGOUT(S, A, B) printk(KERN_DEBUG S "\n", A, B)
4545

4646
#ifdef DBG

drivers/net/pppol2tp.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1238,8 +1238,7 @@ static void pppol2tp_tunnel_closeall(struct pppol2tp_tunnel *tunnel)
12381238
struct pppol2tp_session *session;
12391239
struct sock *sk;
12401240

1241-
if (tunnel == NULL)
1242-
BUG();
1241+
BUG_ON(tunnel == NULL);
12431242

12441243
PRINTK(tunnel->debug, PPPOL2TP_MSG_CONTROL, KERN_INFO,
12451244
"%s: closing all sessions...\n", tunnel->name);

drivers/net/tulip/winbond-840.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1601,8 +1601,7 @@ static int w840_suspend (struct pci_dev *pdev, pm_message_t state)
16011601

16021602
/* no more hardware accesses behind this line. */
16031603

1604-
BUG_ON(np->csr6);
1605-
if (ioread32(ioaddr + IntrEnable)) BUG();
1604+
BUG_ON(np->csr6 || ioread32(ioaddr + IntrEnable));
16061605

16071606
/* pci_power_off(pdev, -1); */
16081607

drivers/net/virtio_net.c

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -621,12 +621,9 @@ static bool virtnet_send_command(struct virtnet_info *vi, u8 class, u8 cmd,
621621
virtio_net_ctrl_ack status = ~0;
622622
unsigned int tmp;
623623

624-
if (!virtio_has_feature(vi->vdev, VIRTIO_NET_F_CTRL_VQ)) {
625-
BUG(); /* Caller should know better */
626-
return false;
627-
}
628-
629-
BUG_ON(out + in > VIRTNET_SEND_COMMAND_SG_MAX);
624+
/* Caller should know better */
625+
BUG_ON(!virtio_has_feature(vi->vdev, VIRTIO_NET_F_CTRL_VQ) ||
626+
(out + in > VIRTNET_SEND_COMMAND_SG_MAX));
630627

631628
out++; /* Add header */
632629
in++; /* Add return status */
@@ -640,8 +637,7 @@ static bool virtnet_send_command(struct virtnet_info *vi, u8 class, u8 cmd,
640637
memcpy(&sg[1], data, sizeof(struct scatterlist) * (out + in - 2));
641638
sg_set_buf(&sg[out + in - 1], &status, sizeof(status));
642639

643-
if (vi->cvq->vq_ops->add_buf(vi->cvq, sg, out, in, vi) != 0)
644-
BUG();
640+
BUG_ON(vi->cvq->vq_ops->add_buf(vi->cvq, sg, out, in, vi));
645641

646642
vi->cvq->vq_ops->kick(vi->cvq);
647643

drivers/net/wireless/ath5k/reset.c

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -54,9 +54,8 @@ static inline int ath5k_hw_write_ofdm_timings(struct ath5k_hw *ah,
5454
u32 coef_scaled, coef_exp, coef_man,
5555
ds_coef_exp, ds_coef_man, clock;
5656

57-
if (!(ah->ah_version == AR5K_AR5212) ||
58-
!(channel->hw_value & CHANNEL_OFDM))
59-
BUG();
57+
BUG_ON(!(ah->ah_version == AR5K_AR5212) ||
58+
!(channel->hw_value & CHANNEL_OFDM));
6059

6160
/* Get coefficient
6261
* ALGO: coef = (5 * clock * carrier_freq) / 2)

drivers/net/wireless/ath9k/ath9k.h

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -53,11 +53,7 @@ struct ath_node;
5353

5454
#define A_MAX(a, b) ((a) > (b) ? (a) : (b))
5555

56-
#define ASSERT(exp) do { \
57-
if (unlikely(!(exp))) { \
58-
BUG(); \
59-
} \
60-
} while (0)
56+
#define ASSERT(exp) BUG_ON(!(exp))
6157

6258
#define TSF_TO_TU(_h,_l) \
6359
((((u32)(_h)) << 22) | (((u32)(_l)) >> 10))

drivers/net/wireless/ipw2x00/ipw2200.c

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3176,11 +3176,8 @@ static int ipw_load_firmware(struct ipw_priv *priv, u8 * data, size_t len)
31763176
/* Start the Dma */
31773177
rc = ipw_fw_dma_enable(priv);
31783178

3179-
if (priv->sram_desc.last_cb_index > 0) {
3180-
/* the DMA is already ready this would be a bug. */
3181-
BUG();
3182-
goto out;
3183-
}
3179+
/* the DMA is already ready this would be a bug. */
3180+
BUG_ON(priv->sram_desc.last_cb_index > 0);
31843181

31853182
do {
31863183
chunk = (struct fw_chunk *)(data + offset);

drivers/net/wireless/libertas/if_usb.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -686,8 +686,7 @@ static inline void process_cmdrequest(int recvlength, uint8_t *recvbuff,
686686
return;
687687
}
688688

689-
if (!in_interrupt())
690-
BUG();
689+
BUG_ON(!in_interrupt());
691690

692691
spin_lock(&priv->driver_lock);
693692

drivers/net/wireless/libertas_tf/if_usb.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -461,8 +461,7 @@ static inline void process_cmdrequest(int recvlength, uint8_t *recvbuff,
461461
return;
462462
}
463463

464-
if (!in_interrupt())
465-
BUG();
464+
BUG_ON(!in_interrupt());
466465

467466
spin_lock(&priv->driver_lock);
468467
memcpy(priv->cmd_resp_buff, recvbuff + MESSAGE_HEADER_LEN,

0 commit comments

Comments
 (0)