diff options
author | Johannes Berg <johannes.berg@intel.com> | 2011-04-18 12:12:37 -0400 |
---|---|---|
committer | Wey-Yi Guy <wey-yi.w.guy@intel.com> | 2011-04-18 12:14:30 -0400 |
commit | 3e41ace5deef7af16dd277d9d17f9d36dca0a10e (patch) | |
tree | 213bf23ffeaede74cddd033ccd45a1d45e9d3f3b /drivers/net/wireless/iwlwifi/iwl-tx.c | |
parent | e79b1ca75bb48111e8d93fc576f50e24671f5f9d (diff) |
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: Johannes Berg <johannes.berg@intel.com>
Signed-off-by: Wey-Yi Guy <wey-yi.w.guy@intel.com>
Diffstat (limited to 'drivers/net/wireless/iwlwifi/iwl-tx.c')
-rw-r--r-- | drivers/net/wireless/iwlwifi/iwl-tx.c | 25 |
1 files changed, 17 insertions, 8 deletions
diff --git a/drivers/net/wireless/iwlwifi/iwl-tx.c b/drivers/net/wireless/iwlwifi/iwl-tx.c index 3732380c4ffe..e7faba57b6e3 100644 --- a/drivers/net/wireless/iwlwifi/iwl-tx.c +++ b/drivers/net/wireless/iwlwifi/iwl-tx.c | |||
@@ -263,11 +263,13 @@ static int iwl_queue_init(struct iwl_priv *priv, struct iwl_queue *q, | |||
263 | 263 | ||
264 | /* count must be power-of-two size, otherwise iwl_queue_inc_wrap | 264 | /* count must be power-of-two size, otherwise iwl_queue_inc_wrap |
265 | * and iwl_queue_dec_wrap are broken. */ | 265 | * and iwl_queue_dec_wrap are broken. */ |
266 | BUG_ON(!is_power_of_2(count)); | 266 | if (WARN_ON(!is_power_of_2(count))) |
267 | return -EINVAL; | ||
267 | 268 | ||
268 | /* slots_num must be power-of-two size, otherwise | 269 | /* slots_num must be power-of-two size, otherwise |
269 | * get_cmd_index is broken. */ | 270 | * get_cmd_index is broken. */ |
270 | BUG_ON(!is_power_of_2(slots_num)); | 271 | if (WARN_ON(!is_power_of_2(slots_num))) |
272 | return -EINVAL; | ||
271 | 273 | ||
272 | q->low_mark = q->n_window / 4; | 274 | q->low_mark = q->n_window / 4; |
273 | if (q->low_mark < 4) | 275 | if (q->low_mark < 4) |
@@ -384,7 +386,9 @@ int iwl_tx_queue_init(struct iwl_priv *priv, struct iwl_tx_queue *txq, | |||
384 | BUILD_BUG_ON(TFD_QUEUE_SIZE_MAX & (TFD_QUEUE_SIZE_MAX - 1)); | 386 | BUILD_BUG_ON(TFD_QUEUE_SIZE_MAX & (TFD_QUEUE_SIZE_MAX - 1)); |
385 | 387 | ||
386 | /* Initialize queue's high/low-water marks, and head/tail indexes */ | 388 | /* Initialize queue's high/low-water marks, and head/tail indexes */ |
387 | iwl_queue_init(priv, &txq->q, TFD_QUEUE_SIZE_MAX, slots_num, txq_id); | 389 | ret = iwl_queue_init(priv, &txq->q, TFD_QUEUE_SIZE_MAX, slots_num, txq_id); |
390 | if (ret) | ||
391 | return ret; | ||
388 | 392 | ||
389 | /* Tell device where to find queue */ | 393 | /* Tell device where to find queue */ |
390 | priv->cfg->ops->lib->txq_init(priv, txq); | 394 | priv->cfg->ops->lib->txq_init(priv, txq); |
@@ -446,14 +450,19 @@ int iwl_enqueue_hcmd(struct iwl_priv *priv, struct iwl_host_cmd *cmd) | |||
446 | cmd->len = priv->cfg->ops->utils->get_hcmd_size(cmd->id, cmd->len); | 450 | cmd->len = priv->cfg->ops->utils->get_hcmd_size(cmd->id, cmd->len); |
447 | fix_size = (u16)(cmd->len + sizeof(out_cmd->hdr)); | 451 | fix_size = (u16)(cmd->len + sizeof(out_cmd->hdr)); |
448 | 452 | ||
449 | /* If any of the command structures end up being larger than | 453 | /* |
454 | * If any of the command structures end up being larger than | ||
450 | * the TFD_MAX_PAYLOAD_SIZE, and it sent as a 'small' command then | 455 | * the TFD_MAX_PAYLOAD_SIZE, and it sent as a 'small' command then |
451 | * we will need to increase the size of the TFD entries | 456 | * we will need to increase the size of the TFD entries |
452 | * Also, check to see if command buffer should not exceed the size | 457 | * Also, check to see if command buffer should not exceed the size |
453 | * of device_cmd and max_cmd_size. */ | 458 | * of device_cmd and max_cmd_size. |
454 | BUG_ON((fix_size > TFD_MAX_PAYLOAD_SIZE) && | 459 | */ |
455 | !(cmd->flags & CMD_SIZE_HUGE)); | 460 | if (WARN_ON((fix_size > TFD_MAX_PAYLOAD_SIZE) && |
456 | BUG_ON(fix_size > IWL_MAX_CMD_SIZE); | 461 | !(cmd->flags & CMD_SIZE_HUGE))) |
462 | return -EINVAL; | ||
463 | |||
464 | if (WARN_ON(fix_size > IWL_MAX_CMD_SIZE)) | ||
465 | return -EINVAL; | ||
457 | 466 | ||
458 | if (iwl_is_rfkill(priv) || iwl_is_ctkill(priv)) { | 467 | if (iwl_is_rfkill(priv) || iwl_is_ctkill(priv)) { |
459 | IWL_WARN(priv, "Not sending command - %s KILL\n", | 468 | IWL_WARN(priv, "Not sending command - %s KILL\n", |