Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 3e41ace5 authored by Johannes Berg's avatar Johannes Berg Committed by Wey-Yi Guy
Browse files

iwlagn: remove most BUG_ON instances



There are a number of things in the driver that
may result in a BUG(), which is suboptimal since
it's hard to get debugging information out of
the driver in that case and the user experience
is also not good :-)

Almost all BUG_ON instances can be converted to
WARN_ON with a few lines of appropriate error
handling, so do that instead.

Signed-off-by: default avatarJohannes Berg <johannes.berg@intel.com>
Signed-off-by: default avatarWey-Yi Guy <wey-yi.w.guy@intel.com>
parent e79b1ca7
Loading
Loading
Loading
Loading
+7 −2
Original line number Diff line number Diff line
@@ -394,7 +394,9 @@ int iwl_hw_txq_attach_buf_to_tfd(struct iwl_priv *priv,
		return -EINVAL;
	}

	BUG_ON(addr & ~DMA_BIT_MASK(36));
	if (WARN_ON(addr & ~DMA_BIT_MASK(36)))
		return -EINVAL;

	if (unlikely(addr & ~IWL_TX_DMA_MASK))
		IWL_ERR(priv, "Unaligned address = %llx\n",
			  (unsigned long long)addr);
@@ -718,7 +720,10 @@ static void iwl_rx_handle(struct iwl_priv *priv)
		/* If an RXB doesn't have a Rx queue slot associated with it,
		 * then a bug has been introduced in the queue refilling
		 * routines -- catch it here */
		BUG_ON(rxb == NULL);
		if (WARN_ON(rxb == NULL)) {
			i = (i + 1) & RX_QUEUE_MASK;
			continue;
		}

		rxq->queue[i] = NULL;

+0 −6
Original line number Diff line number Diff line
@@ -215,12 +215,6 @@ static int iwlcore_get_nvm_type(struct iwl_priv *priv, u32 hw_rev)
	return  nvm_type;
}

const u8 *iwlcore_eeprom_query_addr(const struct iwl_priv *priv, size_t offset)
{
	BUG_ON(offset >= priv->cfg->base_params->eeprom_size);
	return &priv->eeprom[offset];
}

static int iwl_init_otp_access(struct iwl_priv *priv)
{
	int ret;
+0 −1
Original line number Diff line number Diff line
@@ -309,7 +309,6 @@ int iwl_eeprom_check_sku(struct iwl_priv *priv);
const u8 *iwl_eeprom_query_addr(const struct iwl_priv *priv, size_t offset);
int iwlcore_eeprom_verify_signature(struct iwl_priv *priv);
u16 iwl_eeprom_query16(const struct iwl_priv *priv, size_t offset);
const u8 *iwlcore_eeprom_query_addr(const struct iwl_priv *priv, size_t offset);
int iwl_init_channel_map(struct iwl_priv *priv);
void iwl_free_channel_map(struct iwl_priv *priv);
const struct iwl_channel_info *iwl_get_channel_info(
+8 −4
Original line number Diff line number Diff line
@@ -143,10 +143,12 @@ static int iwl_send_cmd_async(struct iwl_priv *priv, struct iwl_host_cmd *cmd)
{
	int ret;

	BUG_ON(!(cmd->flags & CMD_ASYNC));
	if (WARN_ON(!(cmd->flags & CMD_ASYNC)))
		return -EINVAL;

	/* An asynchronous command can not expect an SKB to be set. */
	BUG_ON(cmd->flags & CMD_WANT_SKB);
	if (WARN_ON(cmd->flags & CMD_WANT_SKB))
		return -EINVAL;

	/* Assign a generic callback if one is not provided */
	if (!cmd->callback)
@@ -169,10 +171,12 @@ int iwl_send_cmd_sync(struct iwl_priv *priv, struct iwl_host_cmd *cmd)
	int cmd_idx;
	int ret;

	lockdep_assert_held(&priv->mutex);
	if (WARN_ON(cmd->flags & CMD_ASYNC))
		return -EINVAL;

	 /* A synchronous command can not have a callback set. */
	BUG_ON((cmd->flags & CMD_ASYNC) || cmd->callback);
	if (WARN_ON(cmd->callback))
		return -EINVAL;

	IWL_DEBUG_INFO(priv, "Attempting to send sync command %s\n",
			get_cmd_string(cmd->id));
+4 −3
Original line number Diff line number Diff line
@@ -188,8 +188,9 @@ static void iwl_static_sleep_cmd(struct iwl_priv *priv,
			table = range_0;
	}

	BUG_ON(lvl < 0 || lvl >= IWL_POWER_NUM);

	if (WARN_ON(lvl < 0 || lvl >= IWL_POWER_NUM))
		memset(cmd, 0, sizeof(*cmd));
	else
		*cmd = table[lvl].cmd;

	if (period == 0) {
Loading