aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/wireless/intel
diff options
context:
space:
mode:
authorJohannes Berg <johannes.berg@intel.com>2016-09-09 03:34:46 -0400
committerLuca Coelho <luciano.coelho@intel.com>2016-09-22 16:23:49 -0400
commitcc2f41f84fdc68074e228397247acd32ad06440a (patch)
tree5d3d1be28e908b9f8bec59e6458488dc27bda533 /drivers/net/wireless/intel
parent191167160c1380e59156dff0c2d7e74aa0ba5770 (diff)
iwlwifi: pcie: avoid variable shadowing in TFD helpers
The various TFD/TB helpers have two code paths depending on the type of TFD supported, with variable shadowing due to the new if branches. Move the fall-through code into else branches to avoid variable shadowing. While doing so, rename some of the variables and do some other cleanups (like removing void * casts of void * pointers.) Signed-off-by: Johannes Berg <johannes.berg@intel.com> Signed-off-by: Luca Coelho <luciano.coelho@intel.com>
Diffstat (limited to 'drivers/net/wireless/intel')
-rw-r--r--drivers/net/wireless/intel/iwlwifi/pcie/internal.h19
-rw-r--r--drivers/net/wireless/intel/iwlwifi/pcie/tx.c47
2 files changed, 33 insertions, 33 deletions
diff --git a/drivers/net/wireless/intel/iwlwifi/pcie/internal.h b/drivers/net/wireless/intel/iwlwifi/pcie/internal.h
index 2d81630fba0f..cac6d99012b3 100644
--- a/drivers/net/wireless/intel/iwlwifi/pcie/internal.h
+++ b/drivers/net/wireless/intel/iwlwifi/pcie/internal.h
@@ -497,23 +497,20 @@ void iwl_trans_pcie_reclaim(struct iwl_trans *trans, int txq_id, int ssn,
497 struct sk_buff_head *skbs); 497 struct sk_buff_head *skbs);
498void iwl_trans_pcie_tx_reset(struct iwl_trans *trans); 498void iwl_trans_pcie_tx_reset(struct iwl_trans *trans);
499 499
500static inline u16 iwl_pcie_tfd_tb_get_len(struct iwl_trans *trans, void *tfd, 500static inline u16 iwl_pcie_tfd_tb_get_len(struct iwl_trans *trans, void *_tfd,
501 u8 idx) 501 u8 idx)
502{ 502{
503 struct iwl_tfd *tfd_fh;
504 struct iwl_tfd_tb *tb;
505
506 if (trans->cfg->use_tfh) { 503 if (trans->cfg->use_tfh) {
507 struct iwl_tfh_tfd *tfd_fh = (void *)tfd; 504 struct iwl_tfh_tfd *tfd = _tfd;
508 struct iwl_tfh_tb *tb = &tfd_fh->tbs[idx]; 505 struct iwl_tfh_tb *tb = &tfd->tbs[idx];
509 506
510 return le16_to_cpu(tb->tb_len); 507 return le16_to_cpu(tb->tb_len);
511 } 508 } else {
512 509 struct iwl_tfd *tfd = _tfd;
513 tfd_fh = (void *)tfd; 510 struct iwl_tfd_tb *tb = &tfd->tbs[idx];
514 tb = &tfd_fh->tbs[idx];
515 511
516 return le16_to_cpu(tb->hi_n_len) >> 4; 512 return le16_to_cpu(tb->hi_n_len) >> 4;
513 }
517} 514}
518 515
519/***************************************************** 516/*****************************************************
diff --git a/drivers/net/wireless/intel/iwlwifi/pcie/tx.c b/drivers/net/wireless/intel/iwlwifi/pcie/tx.c
index e00e7d8f197a..e9a278b60dfd 100644
--- a/drivers/net/wireless/intel/iwlwifi/pcie/tx.c
+++ b/drivers/net/wireless/intel/iwlwifi/pcie/tx.c
@@ -337,28 +337,32 @@ static inline void *iwl_pcie_get_tfd(struct iwl_trans_pcie *trans_pcie,
337} 337}
338 338
339static inline dma_addr_t iwl_pcie_tfd_tb_get_addr(struct iwl_trans *trans, 339static inline dma_addr_t iwl_pcie_tfd_tb_get_addr(struct iwl_trans *trans,
340 void *tfd, u8 idx) 340 void *_tfd, u8 idx)
341{ 341{
342 struct iwl_tfd *tfd_fh;
343 struct iwl_tfd_tb *tb;
344 dma_addr_t addr;
345 342
346 if (trans->cfg->use_tfh) { 343 if (trans->cfg->use_tfh) {
347 struct iwl_tfh_tfd *tfd_fh = (void *)tfd; 344 struct iwl_tfh_tfd *tfd = _tfd;
348 struct iwl_tfh_tb *tb = &tfd_fh->tbs[idx]; 345 struct iwl_tfh_tb *tb = &tfd->tbs[idx];
349 346
350 return (dma_addr_t)(le64_to_cpu(tb->addr)); 347 return (dma_addr_t)(le64_to_cpu(tb->addr));
351 } 348 } else {
349 struct iwl_tfd *tfd = _tfd;
350 struct iwl_tfd_tb *tb = &tfd->tbs[idx];
351 dma_addr_t addr = get_unaligned_le32(&tb->lo);
352 dma_addr_t hi_len;
352 353
353 tfd_fh = (void *)tfd; 354 if (sizeof(dma_addr_t) <= sizeof(u32))
354 tb = &tfd_fh->tbs[idx]; 355 return addr;
355 addr = get_unaligned_le32(&tb->lo);
356 356
357 if (sizeof(dma_addr_t) > sizeof(u32)) 357 hi_len = le16_to_cpu(tb->hi_n_len) & 0xF;
358 addr |=
359 ((dma_addr_t)(le16_to_cpu(tb->hi_n_len) & 0xF) << 16) << 16;
360 358
361 return addr; 359 /*
360 * shift by 16 twice to avoid warnings on 32-bit
361 * (where this code never runs anyway due to the
362 * if statement above)
363 */
364 return addr | ((hi_len << 16) << 16);
365 }
362} 366}
363 367
364static inline void iwl_pcie_tfd_set_tb(struct iwl_trans *trans, void *tfd, 368static inline void iwl_pcie_tfd_set_tb(struct iwl_trans *trans, void *tfd,
@@ -388,18 +392,17 @@ static inline void iwl_pcie_tfd_set_tb(struct iwl_trans *trans, void *tfd,
388 } 392 }
389} 393}
390 394
391static inline u8 iwl_pcie_tfd_get_num_tbs(struct iwl_trans *trans, void *tfd) 395static inline u8 iwl_pcie_tfd_get_num_tbs(struct iwl_trans *trans, void *_tfd)
392{ 396{
393 struct iwl_tfd *tfd_fh;
394
395 if (trans->cfg->use_tfh) { 397 if (trans->cfg->use_tfh) {
396 struct iwl_tfh_tfd *tfd_fh = (void *)tfd; 398 struct iwl_tfh_tfd *tfd = _tfd;
397 399
398 return le16_to_cpu(tfd_fh->num_tbs) & 0x1f; 400 return le16_to_cpu(tfd->num_tbs) & 0x1f;
399 } 401 } else {
402 struct iwl_tfd *tfd = _tfd;
400 403
401 tfd_fh = (void *)tfd; 404 return tfd->num_tbs & 0x1f;
402 return tfd_fh->num_tbs & 0x1f; 405 }
403} 406}
404 407
405static void iwl_pcie_tfd_unmap(struct iwl_trans *trans, 408static void iwl_pcie_tfd_unmap(struct iwl_trans *trans,