Commit 0ee904c3 authored by Alexander Beregalov's avatar Alexander Beregalov Committed by David S. Miller

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

Signed-off-by: default avatarAlexander Beregalov <a.beregalov@gmail.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 710b523a
...@@ -1794,8 +1794,7 @@ static void atl1e_tx_map(struct atl1e_adapter *adapter, ...@@ -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_ON(tx_buffer->skb);
BUG();
tx_buffer->skb = NULL; tx_buffer->skb = NULL;
tx_buffer->length = tx_buffer->length =
......
...@@ -2207,8 +2207,7 @@ static void atl1_tx_map(struct atl1_adapter *adapter, struct sk_buff *skb, ...@@ -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_ON(buffer_info->skb);
BUG();
/* 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, ...@@ -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_ON(buffer_info->skb);
BUG();
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;
......
...@@ -1149,8 +1149,8 @@ static inline void write_tx_desc(struct cmdQ_e *e, dma_addr_t mapping, ...@@ -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_ON(len > SGE_TX_DESC_MAX_PLEN);
BUG();
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);
......
...@@ -54,8 +54,7 @@ static int fs_enet_fec_mii_read(struct mii_bus *bus , int phy_id, int location) ...@@ -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_ON((in_be32(&fecp->fec_r_cntrl) & FEC_RCNTRL_MII_MODE) == 0);
BUG();
/* 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, ...@@ -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_ON((in_be32(&fecp->fec_r_cntrl) & FEC_RCNTRL_MII_MODE) == 0);
BUG();
/* 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));
......
...@@ -40,7 +40,7 @@ ...@@ -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
......
...@@ -1238,8 +1238,7 @@ static void pppol2tp_tunnel_closeall(struct pppol2tp_tunnel *tunnel) ...@@ -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_ON(tunnel == NULL);
BUG();
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);
......
...@@ -1601,8 +1601,7 @@ static int w840_suspend (struct pci_dev *pdev, pm_message_t state) ...@@ -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); BUG_ON(np->csr6 || ioread32(ioaddr + IntrEnable));
if (ioread32(ioaddr + IntrEnable)) BUG();
/* pci_power_off(pdev, -1); */ /* pci_power_off(pdev, -1); */
......
...@@ -621,12 +621,9 @@ static bool virtnet_send_command(struct virtnet_info *vi, u8 class, u8 cmd, ...@@ -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)) { /* Caller should know better */
BUG(); /* Caller should know better */ BUG_ON(!virtio_has_feature(vi->vdev, VIRTIO_NET_F_CTRL_VQ) ||
return false; (out + in > VIRTNET_SEND_COMMAND_SG_MAX));
}
BUG_ON(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, ...@@ -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_ON(vi->cvq->vq_ops->add_buf(vi->cvq, sg, out, in, vi));
BUG();
vi->cvq->vq_ops->kick(vi->cvq); vi->cvq->vq_ops->kick(vi->cvq);
......
...@@ -54,9 +54,8 @@ static inline int ath5k_hw_write_ofdm_timings(struct ath5k_hw *ah, ...@@ -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) || BUG_ON(!(ah->ah_version == AR5K_AR5212) ||
!(channel->hw_value & CHANNEL_OFDM)) !(channel->hw_value & CHANNEL_OFDM));
BUG();
/* Get coefficient /* Get coefficient
* ALGO: coef = (5 * clock * carrier_freq) / 2) * ALGO: coef = (5 * clock * carrier_freq) / 2)
......
...@@ -53,11 +53,7 @@ struct ath_node; ...@@ -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 { \ #define ASSERT(exp) BUG_ON(!(exp))
if (unlikely(!(exp))) { \
BUG(); \
} \
} while (0)
#define TSF_TO_TU(_h,_l) \ #define TSF_TO_TU(_h,_l) \
((((u32)(_h)) << 22) | (((u32)(_l)) >> 10)) ((((u32)(_h)) << 22) | (((u32)(_l)) >> 10))
......
...@@ -3176,11 +3176,8 @@ static int ipw_load_firmware(struct ipw_priv *priv, u8 * data, size_t len) ...@@ -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. */
/* the DMA is already ready this would be a bug. */ BUG_ON(priv->sram_desc.last_cb_index > 0);
BUG();
goto out;
}
do { do {
chunk = (struct fw_chunk *)(data + offset); chunk = (struct fw_chunk *)(data + offset);
......
...@@ -686,8 +686,7 @@ static inline void process_cmdrequest(int recvlength, uint8_t *recvbuff, ...@@ -686,8 +686,7 @@ static inline void process_cmdrequest(int recvlength, uint8_t *recvbuff,
return; return;
} }
if (!in_interrupt()) BUG_ON(!in_interrupt());
BUG();
spin_lock(&priv->driver_lock); spin_lock(&priv->driver_lock);
......
...@@ -461,8 +461,7 @@ static inline void process_cmdrequest(int recvlength, uint8_t *recvbuff, ...@@ -461,8 +461,7 @@ static inline void process_cmdrequest(int recvlength, uint8_t *recvbuff,
return; return;
} }
if (!in_interrupt()) BUG_ON(!in_interrupt());
BUG();
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,
......
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