Browse Source

drivers/net: replace BUG() with BUG_ON() if possible

Signed-off-by: Alexander Beregalov <a.beregalov@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Alexander Beregalov 16 years ago
parent
commit
0ee904c35c

+ 1 - 2
drivers/net/atl1e/atl1e_main.c

@@ -1794,8 +1794,7 @@ static void atl1e_tx_map(struct atl1e_adapter *adapter,
 			memcpy(use_tpd, tpd, sizeof(struct atl1e_tpd_desc));
 			memcpy(use_tpd, tpd, sizeof(struct atl1e_tpd_desc));
 
 
 			tx_buffer = atl1e_get_tx_buffer(adapter, use_tpd);
 			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->skb = NULL;
 			tx_buffer->length =
 			tx_buffer->length =

+ 3 - 4
drivers/net/atlx/atl1.c

@@ -2207,8 +2207,7 @@ static void atl1_tx_map(struct atl1_adapter *adapter, struct sk_buff *skb,
 	nr_frags = skb_shinfo(skb)->nr_frags;
 	nr_frags = skb_shinfo(skb)->nr_frags;
 	next_to_use = atomic_read(&tpd_ring->next_to_use);
 	next_to_use = atomic_read(&tpd_ring->next_to_use);
 	buffer_info = &tpd_ring->buffer_info[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 */
 	/* put skb in last TPD */
 	buffer_info->skb = NULL;
 	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;
 			ATL1_MAX_TX_BUF_LEN;
 		for (i = 0; i < nseg; i++) {
 		for (i = 0; i < nseg; i++) {
 			buffer_info = &tpd_ring->buffer_info[next_to_use];
 			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->skb = NULL;
 			buffer_info->length = (buf_len > ATL1_MAX_TX_BUF_LEN) ?
 			buffer_info->length = (buf_len > ATL1_MAX_TX_BUF_LEN) ?
 				ATL1_MAX_TX_BUF_LEN : buf_len;
 				ATL1_MAX_TX_BUF_LEN : buf_len;

+ 2 - 2
drivers/net/chelsio/sge.c

@@ -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 len, unsigned int gen,
 				 unsigned int eop)
 				 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_lo = (u32)mapping;
 	e->addr_hi = (u64)mapping >> 32;
 	e->addr_hi = (u64)mapping >> 32;
 	e->len_gen = V_CMD_LEN(len) | V_CMD_GEN1(gen);
 	e->len_gen = V_CMD_LEN(len) | V_CMD_GEN1(gen);

+ 2 - 4
drivers/net/fs_enet/mii-fec.c

@@ -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;
 	fec_t __iomem *fecp = fec->fecp;
 	int i, ret = -1;
 	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.  */
 	/* Add PHY address to register command.  */
 	out_be32(&fecp->fec_mii_data, (phy_id << 23) | mk_mii_read(location));
 	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;
 	int i;
 
 
 	/* this must never happen */
 	/* 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.  */
 	/* Add PHY address to register command.  */
 	out_be32(&fecp->fec_mii_data, (phy_id << 23) | mk_mii_write(location, val));
 	out_be32(&fecp->fec_mii_data, (phy_id << 23) | mk_mii_write(location, val));

+ 1 - 1
drivers/net/ixgb/ixgb_osdep.h

@@ -40,7 +40,7 @@
 #include <linux/sched.h>
 #include <linux/sched.h>
 
 
 #undef ASSERT
 #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)
 #define MSGOUT(S, A, B)	printk(KERN_DEBUG S "\n", A, B)
 
 
 #ifdef DBG
 #ifdef DBG

+ 1 - 2
drivers/net/pppol2tp.c

@@ -1238,8 +1238,7 @@ static void pppol2tp_tunnel_closeall(struct pppol2tp_tunnel *tunnel)
 	struct pppol2tp_session *session;
 	struct pppol2tp_session *session;
 	struct sock *sk;
 	struct sock *sk;
 
 
-	if (tunnel == NULL)
-		BUG();
+	BUG_ON(tunnel == NULL);
 
 
 	PRINTK(tunnel->debug, PPPOL2TP_MSG_CONTROL, KERN_INFO,
 	PRINTK(tunnel->debug, PPPOL2TP_MSG_CONTROL, KERN_INFO,
 	       "%s: closing all sessions...\n", tunnel->name);
 	       "%s: closing all sessions...\n", tunnel->name);

+ 1 - 2
drivers/net/tulip/winbond-840.c

@@ -1601,8 +1601,7 @@ static int w840_suspend (struct pci_dev *pdev, pm_message_t state)
 
 
 		/* no more hardware accesses behind this line. */
 		/* 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); */
 		/* pci_power_off(pdev, -1); */
 
 

+ 4 - 8
drivers/net/virtio_net.c

@@ -621,12 +621,9 @@ static bool virtnet_send_command(struct virtnet_info *vi, u8 class, u8 cmd,
 	virtio_net_ctrl_ack status = ~0;
 	virtio_net_ctrl_ack status = ~0;
 	unsigned int tmp;
 	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 */
 	out++; /* Add header */
 	in++; /* Add return status */
 	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));
 	memcpy(&sg[1], data, sizeof(struct scatterlist) * (out + in - 2));
 	sg_set_buf(&sg[out + in - 1], &status, sizeof(status));
 	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);
 	vi->cvq->vq_ops->kick(vi->cvq);
 
 

+ 2 - 3
drivers/net/wireless/ath5k/reset.c

@@ -54,9 +54,8 @@ static inline int ath5k_hw_write_ofdm_timings(struct ath5k_hw *ah,
 	u32 coef_scaled, coef_exp, coef_man,
 	u32 coef_scaled, coef_exp, coef_man,
 		ds_coef_exp, ds_coef_man, clock;
 		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
 	/* Get coefficient
 	 * ALGO: coef = (5 * clock * carrier_freq) / 2)
 	 * ALGO: coef = (5 * clock * carrier_freq) / 2)

+ 1 - 5
drivers/net/wireless/ath9k/ath9k.h

@@ -53,11 +53,7 @@ struct ath_node;
 
 
 #define A_MAX(a, b) ((a) > (b) ? (a) : (b))
 #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) \
 #define TSF_TO_TU(_h,_l) \
 	((((u32)(_h)) << 22) | (((u32)(_l)) >> 10))
 	((((u32)(_h)) << 22) | (((u32)(_l)) >> 10))

+ 2 - 5
drivers/net/wireless/ipw2x00/ipw2200.c

@@ -3176,11 +3176,8 @@ static int ipw_load_firmware(struct ipw_priv *priv, u8 * data, size_t len)
 	/* Start the Dma */
 	/* Start the Dma */
 	rc = ipw_fw_dma_enable(priv);
 	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 {
 	do {
 		chunk = (struct fw_chunk *)(data + offset);
 		chunk = (struct fw_chunk *)(data + offset);

+ 1 - 2
drivers/net/wireless/libertas/if_usb.c

@@ -686,8 +686,7 @@ static inline void process_cmdrequest(int recvlength, uint8_t *recvbuff,
 		return;
 		return;
 	}
 	}
 
 
-	if (!in_interrupt())
-		BUG();
+	BUG_ON(!in_interrupt());
 
 
 	spin_lock(&priv->driver_lock);
 	spin_lock(&priv->driver_lock);
 
 

+ 1 - 2
drivers/net/wireless/libertas_tf/if_usb.c

@@ -461,8 +461,7 @@ static inline void process_cmdrequest(int recvlength, uint8_t *recvbuff,
 		return;
 		return;
 	}
 	}
 
 
-	if (!in_interrupt())
-		BUG();
+	BUG_ON(!in_interrupt());
 
 
 	spin_lock(&priv->driver_lock);
 	spin_lock(&priv->driver_lock);
 	memcpy(priv->cmd_resp_buff, recvbuff + MESSAGE_HEADER_LEN,
 	memcpy(priv->cmd_resp_buff, recvbuff + MESSAGE_HEADER_LEN,