diff options
author | Tomas Winkler <tomas.winkler@intel.com> | 2008-10-14 15:32:44 -0400 |
---|---|---|
committer | John W. Linville <linville@tuxdriver.com> | 2008-10-31 19:00:28 -0400 |
commit | 961ba60abe02517d0c8252f9befb1478f4e008a4 (patch) | |
tree | 60f254c6777aca236eff8cc06a34f11c213d5751 /drivers | |
parent | 3257e5d4eb418e4656542207720aef5f0f547701 (diff) |
iwlwifi: add iwl_cmd_queue_free for readability
This patch adds iwl_cmd_queue_free function and
separate cmd queue freeing from regular tx queue freeing.
This improves readability and adds one more step in
restructuring of cmd queue handling
Signed-off-by: Tomas Winkler <tomas.winkler@intel.com>
Reviewed-by: Zhu Yi <yi.zhu@intel.com>
Signed-off-by: Reinette Chatre <reinette.chatre@intel.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/net/wireless/iwlwifi/iwl-tx.c | 53 |
1 files changed, 40 insertions, 13 deletions
diff --git a/drivers/net/wireless/iwlwifi/iwl-tx.c b/drivers/net/wireless/iwlwifi/iwl-tx.c index 37ebcff409e2..87c955e88427 100644 --- a/drivers/net/wireless/iwlwifi/iwl-tx.c +++ b/drivers/net/wireless/iwlwifi/iwl-tx.c | |||
@@ -72,10 +72,6 @@ static int iwl_hw_txq_free_tfd(struct iwl_priv *priv, struct iwl_tx_queue *txq) | |||
72 | int counter = 0; | 72 | int counter = 0; |
73 | int index, is_odd; | 73 | int index, is_odd; |
74 | 74 | ||
75 | /* Host command buffers stay mapped in memory, nothing to clean */ | ||
76 | if (txq->q.id == IWL_CMD_QUEUE_NUM) | ||
77 | return 0; | ||
78 | |||
79 | /* Sanity check on number of chunks */ | 75 | /* Sanity check on number of chunks */ |
80 | counter = IWL_GET_BITS(*bd, num_tbs); | 76 | counter = IWL_GET_BITS(*bd, num_tbs); |
81 | if (counter > MAX_NUM_OF_TBS) { | 77 | if (counter > MAX_NUM_OF_TBS) { |
@@ -210,7 +206,7 @@ static void iwl_tx_queue_free(struct iwl_priv *priv, int txq_id) | |||
210 | struct iwl_tx_queue *txq = &priv->txq[txq_id]; | 206 | struct iwl_tx_queue *txq = &priv->txq[txq_id]; |
211 | struct iwl_queue *q = &txq->q; | 207 | struct iwl_queue *q = &txq->q; |
212 | struct pci_dev *dev = priv->pci_dev; | 208 | struct pci_dev *dev = priv->pci_dev; |
213 | int i, slots_num, len; | 209 | int i, len; |
214 | 210 | ||
215 | if (q->n_bd == 0) | 211 | if (q->n_bd == 0) |
216 | return; | 212 | return; |
@@ -221,16 +217,10 @@ static void iwl_tx_queue_free(struct iwl_priv *priv, int txq_id) | |||
221 | iwl_hw_txq_free_tfd(priv, txq); | 217 | iwl_hw_txq_free_tfd(priv, txq); |
222 | 218 | ||
223 | len = sizeof(struct iwl_cmd) * q->n_window; | 219 | len = sizeof(struct iwl_cmd) * q->n_window; |
224 | if (q->id == IWL_CMD_QUEUE_NUM) | ||
225 | len += IWL_MAX_SCAN_SIZE; | ||
226 | 220 | ||
227 | /* De-alloc array of command/tx buffers */ | 221 | /* De-alloc array of command/tx buffers */ |
228 | slots_num = (txq_id == IWL_CMD_QUEUE_NUM) ? | 222 | for (i = 0; i < TFD_TX_CMD_SLOTS; i++) |
229 | TFD_CMD_SLOTS : TFD_TX_CMD_SLOTS; | ||
230 | for (i = 0; i < slots_num; i++) | ||
231 | kfree(txq->cmd[i]); | 223 | kfree(txq->cmd[i]); |
232 | if (txq_id == IWL_CMD_QUEUE_NUM) | ||
233 | kfree(txq->cmd[slots_num]); | ||
234 | 224 | ||
235 | /* De-alloc circular buffer of TFDs */ | 225 | /* De-alloc circular buffer of TFDs */ |
236 | if (txq->q.n_bd) | 226 | if (txq->q.n_bd) |
@@ -245,6 +235,40 @@ static void iwl_tx_queue_free(struct iwl_priv *priv, int txq_id) | |||
245 | memset(txq, 0, sizeof(*txq)); | 235 | memset(txq, 0, sizeof(*txq)); |
246 | } | 236 | } |
247 | 237 | ||
238 | |||
239 | /** | ||
240 | * iwl_cmd_queue_free - Deallocate DMA queue. | ||
241 | * @txq: Transmit queue to deallocate. | ||
242 | * | ||
243 | * Empty queue by removing and destroying all BD's. | ||
244 | * Free all buffers. | ||
245 | * 0-fill, but do not free "txq" descriptor structure. | ||
246 | */ | ||
247 | static void iwl_cmd_queue_free(struct iwl_priv *priv) | ||
248 | { | ||
249 | struct iwl_tx_queue *txq = &priv->txq[IWL_CMD_QUEUE_NUM]; | ||
250 | struct iwl_queue *q = &txq->q; | ||
251 | struct pci_dev *dev = priv->pci_dev; | ||
252 | int i, len; | ||
253 | |||
254 | if (q->n_bd == 0) | ||
255 | return; | ||
256 | |||
257 | len = sizeof(struct iwl_cmd) * q->n_window; | ||
258 | len += IWL_MAX_SCAN_SIZE; | ||
259 | |||
260 | /* De-alloc array of command/tx buffers */ | ||
261 | for (i = 0; i <= TFD_CMD_SLOTS; i++) | ||
262 | kfree(txq->cmd[i]); | ||
263 | |||
264 | /* De-alloc circular buffer of TFDs */ | ||
265 | if (txq->q.n_bd) | ||
266 | pci_free_consistent(dev, sizeof(struct iwl_tfd_frame) * | ||
267 | txq->q.n_bd, txq->bd, txq->q.dma_addr); | ||
268 | |||
269 | /* 0-fill queue descriptor structure */ | ||
270 | memset(txq, 0, sizeof(*txq)); | ||
271 | } | ||
248 | /*************** DMA-QUEUE-GENERAL-FUNCTIONS ***** | 272 | /*************** DMA-QUEUE-GENERAL-FUNCTIONS ***** |
249 | * DMA services | 273 | * DMA services |
250 | * | 274 | * |
@@ -468,7 +492,10 @@ void iwl_hw_txq_ctx_free(struct iwl_priv *priv) | |||
468 | 492 | ||
469 | /* Tx queues */ | 493 | /* Tx queues */ |
470 | for (txq_id = 0; txq_id < priv->hw_params.max_txq_num; txq_id++) | 494 | for (txq_id = 0; txq_id < priv->hw_params.max_txq_num; txq_id++) |
471 | iwl_tx_queue_free(priv, txq_id); | 495 | if (txq_id == IWL_CMD_QUEUE_NUM) |
496 | iwl_cmd_queue_free(priv); | ||
497 | else | ||
498 | iwl_tx_queue_free(priv, txq_id); | ||
472 | 499 | ||
473 | /* Keep-warm buffer */ | 500 | /* Keep-warm buffer */ |
474 | iwl_kw_free(priv); | 501 | iwl_kw_free(priv); |