iwl3945: remove unused len_org variable
PATCH 1/3 iwl3945: remove unused len_org variable
--- drivers/net/wireless/iwlwifi/iwl3945-base.c | 9 +-------- 1 files changed, 1 insertions(+), 8 deletions(-)
drivers/net/wireless/iwlwifi/iwl3945-base.c +1 -8
@@ -475,7 +475,7 @@ static int iwl3945_tx_skb(struct iwl_priv *priv, struct sk_buff *skb)dma_addr_t phys_addr;dma_addr_t txcmd_phys;int txq_id =skb_get_queue_mapping (skb); -u16 len, idx, len_org, hdr_len;/* TODO: len_org is not used */ +u16 len, idx, hdr_len;u8 id;u8 unicast;u8 sta_id;
@@ -612,15 +612,8 @@ static int iwl3945_tx_skb(struct iwl_priv *priv, struct sk_buff *skb)*/ len =sizeof (struct iwl3945_tx_cmd ) +sizeof (struct iwl_cmd_header ) + hdr_len; - - len_org = len; len = (len +3 ) & ~3 ; -if (len_org != len) - len_org =1 ; -else - len_org =0 ; -/* Physical address of this Tx command's header (not MAC header!), * within command buffer array. */ txcmd_phys = pci_map_single(priv->pci_dev, &out_cmd->hdr,
Signature · 1 line
1.7.1
PATCH 2/3 iwlagn: simplify iwlagn_tx_skb
We can simplify length calculation in iwlagn_tx_skb, that function is enough complex, without fuzz it more than necessary.
--- drivers/net/wireless/iwlwifi/iwl-agn-tx.c | 33 ++++++++++------------------ 1 files changed, 12 insertions(+), 21 deletions(-)
drivers/net/wireless/iwlwifi/iwl-agn-tx.c +12 -21
@@ -522,7 +522,7 @@ int iwlagn_tx_skb(struct iwl_priv *priv, struct sk_buff *skb)dma_addr_t phys_addr;dma_addr_t txcmd_phys;dma_addr_t scratch_phys; -u16 len, len_org, firstlen, secondlen; +u16 len, firstlen, secondlen;u16 seq_number =0 ;__le16 fc;u8 hdr_len;
@@ -687,30 +687,23 @@ int iwlagn_tx_skb(struct iwl_priv *priv, struct sk_buff *skb)*/ len =sizeof (struct iwl_tx_cmd ) +sizeof (struct iwl_cmd_header ) + hdr_len; - - len_org = len; - firstlen = len = (len +3 ) & ~3 ; - -if (len_org != len) - len_org =1 ; -else - len_org =0 ; + firstlen = (len +3 ) & ~3 ;/* Tell NIC about any 2-byte padding after MAC header */ -if (len_org) +if (firstlen != len) tx_cmd->tx_flags |=TX_CMD_FLG_MH_PAD_MSK ;/* Physical address of this Tx command's header (not MAC header!), * within command buffer array. */ txcmd_phys =pci_map_single (priv->pci_dev, - &out_cmd->hdr, len, + &out_cmd->hdr, firstlen,PCI_DMA_BIDIRECTIONAL );dma_unmap_addr_set (out_meta, mapping, txcmd_phys); -dma_unmap_len_set (out_meta, len, len); +dma_unmap_len_set (out_meta, len, firstlen);/* Add buffer containing Tx command and MAC(!) header to TFD's * first entry */ priv->cfg->ops->lib->txq_attach_buf_to_tfd (priv, txq, - txcmd_phys, len,1 ,0 ); + txcmd_phys, firstlen,1 ,0 );if (!ieee80211_has_morefrags (hdr->frame_control)) { txq->need_update =1 ;
@@ -721,23 +714,21 @@ int iwlagn_tx_skb(struct iwl_priv *priv, struct sk_buff *skb)/* Set up TFD's 2nd entry to point directly to remainder of skb, * if any (802.11 null frames have no payload). */ - secondlen = len = skb->len - hdr_len; -if (len) { + secondlen = skb->len - hdr_len; +if (secondlen >0 ) { phys_addr =pci_map_single (priv->pci_dev, skb->data + hdr_len, - len,PCI_DMA_TODEVICE ); + secondlen,PCI_DMA_TODEVICE ); priv->cfg->ops->lib->txq_attach_buf_to_tfd (priv, txq, - phys_addr, len, + phys_addr, secondlen,0 ,0 ); } scratch_phys = txcmd_phys +sizeof (struct iwl_cmd_header ) + offsetof(struct iwl_tx_cmd , scratch); - len =sizeof (struct iwl_tx_cmd ) + -sizeof (struct iwl_cmd_header ) + hdr_len;/* take back ownership of DMA buffer to enable update */ pci_dma_sync_single_for_cpu (priv->pci_dev, txcmd_phys, - len,PCI_DMA_BIDIRECTIONAL ); + firstlen,PCI_DMA_BIDIRECTIONAL ); tx_cmd->dram_lsb_ptr =cpu_to_le32 (scratch_phys); tx_cmd->dram_msb_ptr =iwl_get_dma_hi_addr (scratch_phys);
@@ -753,7 +744,7 @@ int iwlagn_tx_skb(struct iwl_priv *priv, struct sk_buff *skb) le16_to_cpu(tx_cmd->len));pci_dma_sync_single_for_device (priv->pci_dev, txcmd_phys, - len,PCI_DMA_BIDIRECTIONAL ); + firstlen,PCI_DMA_BIDIRECTIONAL ); trace_iwlwifi_dev_tx(priv, &((struct iwl_tfd *)txq->tfds)[txq->q.write_ptr],
Signature · 1 line
1.7.1
Re: [PATCH 2/3] iwlagn: simplify iwlagn_tx_skb
Hi Gruszka,
Quoted 39 lines · Stanislaw Gruszka
We can simplify length calculation in
iwlagn_tx_skb, that function is enough complex, without fuzz it more than necessary.Signed-off-by Stanislaw Gruszka <[email protected]>--- drivers/net/wireless/iwlwifi/iwl-agn-tx.c | 33 ++++++++++------------------ 1 files changed, 12 insertions(+), 21 deletions(-)drivers/net/wireless/iwlwifi/iwl-agn-tx.c +3
-10@@ -522,7 +522,7 @@ int iwlagn_tx_skb(struct iwl_priv *priv, struct sk_buff *skb)dma_addr_t phys_addr;dma_addr_t txcmd_phys;dma_addr_t scratch_phys; -u16 len, len_org, firstlen, secondlen; +u16 len, firstlen, secondlen;u16 seq_number =0 ;__le16 fc;u8 hdr_len;@@ -687,30 +687,23 @@ int iwlagn_tx_skb(struct iwl_priv *priv, struct sk_buff *skb)*/ len =sizeof (struct iwl_tx_cmd ) +sizeof (struct iwl_cmd_header ) + hdr_len; - - len_org = len; - firstlen = len = (len +3 ) & ~3 ; - -if (len_org != len) - len_org =1 ; -else - len_org =0 ; + firstlen = (len +3 ) & ~3 ;/* Tell NIC about any 2-byte padding after MAC header */ -if (len_org) +if (firstlen != len) tx_cmd->tx_flags |=TX_CMD_FLG_MH_PAD_MSK ;
drivers/net/wireless/iwlwifi/iwl-agn-tx.c int iwlagn_tx_skb(struct iwl_priv *priv, struct sk_buff *skb) · line 702
Quoted 10 lines
drivers/net/wireless/iwlwifi/iwl-agn-tx.c +2
-2/* Physical address of this Tx command's header (not MAC header!), * within command buffer array. */ txcmd_phys =pci_map_single (priv->pci_dev, - &out_cmd->hdr, len, + &out_cmd->hdr, firstlen,PCI_DMA_BIDIRECTIONAL );dma_unmap_addr_set (out_meta, mapping, txcmd_phys); -dma_unmap_len_set (out_meta, len, len); +dma_unmap_len_set (out_meta, len, firstlen);
it is possible len != firstlen, right?
Quoted 24 lines
drivers/net/wireless/iwlwifi/iwl-agn-tx.c +5
-5/* Add buffer containing Tx command and MAC(!) header to TFD's * first entry */ priv->cfg->ops->lib->txq_attach_buf_to_tfd (priv, txq, - txcmd_phys, len,1 ,0 ); + txcmd_phys, firstlen,1 ,0 );if (!ieee80211_has_morefrags (hdr->frame_control)) { txq->need_update =1 ;@@ -721,23 +714,21 @@ int iwlagn_tx_skb(struct iwl_priv *priv, struct sk_buff *skb)/* Set up TFD's 2nd entry to point directly to remainder of skb, * if any (802.11 null frames have no payload). */ - secondlen = len = skb->len - hdr_len; -if (len) { + secondlen = skb->len - hdr_len; +if (secondlen >0 ) { phys_addr =pci_map_single (priv->pci_dev, skb->data + hdr_len, - len,PCI_DMA_TODEVICE ); + secondlen,PCI_DMA_TODEVICE ); priv->cfg->ops->lib->txq_attach_buf_to_tfd (priv, txq, - phys_addr, len, + phys_addr, secondlen,0 ,0 ); }
drivers/net/wireless/iwlwifi/iwl-agn-tx.c int iwlagn_tx_skb(struct iwl_priv *priv, struct sk_buff *skb) · line 731
Quoted 10 lines
drivers/net/wireless/iwlwifi/iwl-agn-tx.c +1
-3scratch_phys = txcmd_phys +sizeof (struct iwl_cmd_header ) + offsetof(struct iwl_tx_cmd , scratch); - len =sizeof (struct iwl_tx_cmd ) + -sizeof (struct iwl_cmd_header ) + hdr_len;/* take back ownership of DMA buffer to enable update */ pci_dma_sync_single_for_cpu (priv->pci_dev, txcmd_phys, - len,PCI_DMA_BIDIRECTIONAL ); + firstlen,PCI_DMA_BIDIRECTIONAL );
same here, "firstlen" not necessary equal "len"
drivers/net/wireless/iwlwifi/iwl-agn-tx.c int iwlagn_tx_skb(struct iwl_priv *priv, struct sk_buff *skb) · line 747
Quoted 9 lines
drivers/net/wireless/iwlwifi/iwl-agn-tx.c +1
-1tx_cmd->dram_lsb_ptr =cpu_to_le32 (scratch_phys); tx_cmd->dram_msb_ptr =iwl_get_dma_hi_addr (scratch_phys);@@ -753,7 +744,7 @@ int iwlagn_tx_skb(struct iwl_priv *priv, struct sk_buff *skb) le16_to_cpu(tx_cmd->len));pci_dma_sync_single_for_device (priv->pci_dev, txcmd_phys, - len,PCI_DMA_BIDIRECTIONAL ); + firstlen,PCI_DMA_BIDIRECTIONAL );
same here
drivers/net/wireless/iwlwifi/iwl-agn-tx.c int iwlagn_tx_skb(struct iwl_priv *priv, struct sk_buff *skb) · line 750
Quoted 3 lines
drivers/net/wireless/iwlwifi/iwl-agn-tx.c +0
-0trace_iwlwifi_dev_tx(priv, &((struct iwl_tfd *)txq->tfds)[txq->q.write_ptr],
Wey
Re: [PATCH 2/3] iwlagn: simplify iwlagn_tx_skb
Hi,
Quoted 41 lines · Wey-Yi
Quoted 40 lines · Stanislaw Gruszka
We can simplify length calculation in
iwlagn_tx_skb, that function is enough complex, without fuzz it more than necessary.Signed-off-by Stanislaw Gruszka <[email protected]>--- drivers/net/wireless/iwlwifi/iwl-agn-tx.c | 33 ++++++++++------------------ 1 files changed, 12 insertions(+), 21 deletions(-)drivers/net/wireless/iwlwifi/iwl-agn-tx.c +3
-10@@ -522,7 +522,7 @@ int iwlagn_tx_skb(struct iwl_priv *priv, struct sk_buff *skb)dma_addr_t phys_addr;dma_addr_t txcmd_phys;dma_addr_t scratch_phys; -u16 len, len_org, firstlen, secondlen; +u16 len, firstlen, secondlen;u16 seq_number =0 ;__le16 fc;u8 hdr_len;@@ -687,30 +687,23 @@ int iwlagn_tx_skb(struct iwl_priv *priv, struct sk_buff *skb)*/ len =sizeof (struct iwl_tx_cmd ) +sizeof (struct iwl_cmd_header ) + hdr_len; - - len_org = len; - firstlen = len = (len +3 ) & ~3 ; - -if (len_org != len) - len_org =1 ; -else - len_org =0 ; + firstlen = (len +3 ) & ~3 ;/* Tell NIC about any 2-byte padding after MAC header */ -if (len_org) +if (firstlen != len) tx_cmd->tx_flags |=TX_CMD_FLG_MH_PAD_MSK ;
Quoted 11 lines
drivers/net/wireless/iwlwifi/iwl-agn-tx.c int iwlagn_tx_skb(struct iwl_priv *priv, struct sk_buff *skb) · line 702
Quoted 9 lines
drivers/net/wireless/iwlwifi/iwl-agn-tx.c +2
-2/* Physical address of this Tx command's header (not MAC header!), * within command buffer array. */ txcmd_phys =pci_map_single (priv->pci_dev, - &out_cmd->hdr, len, + &out_cmd->hdr, firstlen,PCI_DMA_BIDIRECTIONAL );dma_unmap_addr_set (out_meta, mapping, txcmd_phys); -dma_unmap_len_set (out_meta, len, len); +dma_unmap_len_set (out_meta, len, firstlen);it is possible len != firstlen, right?
Yes it is, firstlen is aligned up to 4 byes value, txcmd_phys dma map size is firstlen and in consequence I use it every time with txcmd_phys.
Quoted 28 lines
Quoted 28 lines
drivers/net/wireless/iwlwifi/iwl-agn-tx.c +5
-5/* Add buffer containing Tx command and MAC(!) header to TFD's * first entry */ priv->cfg->ops->lib->txq_attach_buf_to_tfd (priv, txq, - txcmd_phys, len,1 ,0 ); + txcmd_phys, firstlen,1 ,0 );if (!ieee80211_has_morefrags (hdr->frame_control)) { txq->need_update =1 ;@@ -721,23 +714,21 @@ int iwlagn_tx_skb(struct iwl_priv *priv, struct sk_buff *skb)/* Set up TFD's 2nd entry to point directly to remainder of skb, * if any (802.11 null frames have no payload). */ - secondlen = len = skb->len - hdr_len; -if (len) { + secondlen = skb->len - hdr_len; +if (secondlen >0 ) { phys_addr =pci_map_single (priv->pci_dev, skb->data + hdr_len, - len,PCI_DMA_TODEVICE ); + secondlen,PCI_DMA_TODEVICE ); priv->cfg->ops->lib->txq_attach_buf_to_tfd (priv, txq, - phys_addr, len, + phys_addr, secondlen,0 ,0 ); } scratch_phys = txcmd_phys +sizeof (struct iwl_cmd_header ) + offsetof(struct iwl_tx_cmd , scratch);
Quoted 8 lines
drivers/net/wireless/iwlwifi/iwl-agn-tx.c int iwlagn_tx_skb(struct iwl_priv *priv, struct sk_buff *skb) · line 731
Quoted 6 lines
drivers/net/wireless/iwlwifi/iwl-agn-tx.c +1
-3- len =sizeof (struct iwl_tx_cmd ) + -sizeof (struct iwl_cmd_header ) + hdr_len;/* take back ownership of DMA buffer to enable update */ pci_dma_sync_single_for_cpu (priv->pci_dev, txcmd_phys, - len,PCI_DMA_BIDIRECTIONAL ); + firstlen,PCI_DMA_BIDIRECTIONAL );same here, "firstlen" not necessary equal "len"
I guess its enough to sync just "len" but I prefer to use the size we used to map dma.
Stanislaw
Guy, Wey-Yi
Acked-byRe: [PATCH 2/3] iwlagn: simplify iwlagn_tx_skb
Quoted 96 lines · Stanislaw Gruszka
Hi,
Quoted 41 lines · Wey-Yi
Quoted 40 lines · Stanislaw Gruszka
We can simplify length calculation in
iwlagn_tx_skb, that function is enough complex, without fuzz it more than necessary.Signed-off-by Stanislaw Gruszka <[email protected]>--- drivers/net/wireless/iwlwifi/iwl-agn-tx.c | 33 ++++++++++------------------ 1 files changed, 12 insertions(+), 21 deletions(-)drivers/net/wireless/iwlwifi/iwl-agn-tx.c +3
-10@@ -522,7 +522,7 @@ int iwlagn_tx_skb(struct iwl_priv *priv, struct sk_buff *skb)dma_addr_t phys_addr;dma_addr_t txcmd_phys;dma_addr_t scratch_phys; -u16 len, len_org, firstlen, secondlen; +u16 len, firstlen, secondlen;u16 seq_number =0 ;__le16 fc;u8 hdr_len;@@ -687,30 +687,23 @@ int iwlagn_tx_skb(struct iwl_priv *priv, struct sk_buff *skb)*/ len =sizeof (struct iwl_tx_cmd ) +sizeof (struct iwl_cmd_header ) + hdr_len; - - len_org = len; - firstlen = len = (len +3 ) & ~3 ; - -if (len_org != len) - len_org =1 ; -else - len_org =0 ; + firstlen = (len +3 ) & ~3 ;/* Tell NIC about any 2-byte padding after MAC header */ -if (len_org) +if (firstlen != len) tx_cmd->tx_flags |=TX_CMD_FLG_MH_PAD_MSK ;Quoted 11 lines
drivers/net/wireless/iwlwifi/iwl-agn-tx.c int iwlagn_tx_skb(struct iwl_priv *priv, struct sk_buff *skb) · line 702
Quoted 9 lines
drivers/net/wireless/iwlwifi/iwl-agn-tx.c +2
-2/* Physical address of this Tx command's header (not MAC header!), * within command buffer array. */ txcmd_phys =pci_map_single (priv->pci_dev, - &out_cmd->hdr, len, + &out_cmd->hdr, firstlen,PCI_DMA_BIDIRECTIONAL );dma_unmap_addr_set (out_meta, mapping, txcmd_phys); -dma_unmap_len_set (out_meta, len, len); +dma_unmap_len_set (out_meta, len, firstlen);it is possible len != firstlen, right?
Yes it is, firstlen is aligned up to 4 byes value,
txcmd_physdma map size is firstlen and in consequence I use it every time withtxcmd_phys.Quoted 28 lines
Quoted 28 lines
drivers/net/wireless/iwlwifi/iwl-agn-tx.c +5
-5/* Add buffer containing Tx command and MAC(!) header to TFD's * first entry */ priv->cfg->ops->lib->txq_attach_buf_to_tfd (priv, txq, - txcmd_phys, len,1 ,0 ); + txcmd_phys, firstlen,1 ,0 );if (!ieee80211_has_morefrags (hdr->frame_control)) { txq->need_update =1 ;@@ -721,23 +714,21 @@ int iwlagn_tx_skb(struct iwl_priv *priv, struct sk_buff *skb)/* Set up TFD's 2nd entry to point directly to remainder of skb, * if any (802.11 null frames have no payload). */ - secondlen = len = skb->len - hdr_len; -if (len) { + secondlen = skb->len - hdr_len; +if (secondlen >0 ) { phys_addr =pci_map_single (priv->pci_dev, skb->data + hdr_len, - len,PCI_DMA_TODEVICE ); + secondlen,PCI_DMA_TODEVICE ); priv->cfg->ops->lib->txq_attach_buf_to_tfd (priv, txq, - phys_addr, len, + phys_addr, secondlen,0 ,0 ); } scratch_phys = txcmd_phys +sizeof (struct iwl_cmd_header ) + offsetof(struct iwl_tx_cmd , scratch);Quoted 8 lines
drivers/net/wireless/iwlwifi/iwl-agn-tx.c int iwlagn_tx_skb(struct iwl_priv *priv, struct sk_buff *skb) · line 731
Quoted 6 lines
drivers/net/wireless/iwlwifi/iwl-agn-tx.c +1
-3- len =sizeof (struct iwl_tx_cmd ) + -sizeof (struct iwl_cmd_header ) + hdr_len;/* take back ownership of DMA buffer to enable update */ pci_dma_sync_single_for_cpu (priv->pci_dev, txcmd_phys, - len,PCI_DMA_BIDIRECTIONAL ); + firstlen,PCI_DMA_BIDIRECTIONAL );same here, "firstlen" not necessary equal "len"
Quoted 3 lines
I guess its enough to sync just "len" but I prefer to use the size we used to map dma.
ok, it make sense
PATCH 3/3 iwlwifi: kill elapsed_jiffies
In reply to Stanislaw GruszkaSubtract of jiffies is fine even if one variable overwrap.
--- drivers/net/wireless/iwlwifi/iwl-helpers.h | 9 --------- drivers/net/wireless/iwlwifi/iwl-scan.c | 3 +-- 2 files changed, 1 insertions(+), 11 deletions(-)
drivers/net/wireless/iwlwifi/iwl-helpers.h +0 -9
@@ -44,15 +44,6 @@ static inline struct ieee80211_conf *ieee80211_get_hw_conf(return &hw->conf; } -static inline unsigned long elapsed_jiffies (unsigned long start, -unsigned long end) -{ -if (end >= start) -return end - start; - -return end + (MAX_JIFFY_OFFSET - start) +1 ; -} -/** * iwl_queue_inc_wrap - increment queue index, wrap back to beginning * @index -- current index
drivers/net/wireless/iwlwifi/iwl-scan.c +1 -2
@@ -252,8 +252,7 @@ static void iwl_rx_scan_complete_notif(struct iwl_priv *priv,IWL_DEBUG_SCAN (priv,"Scan on %sGHz took %dms\n" , (priv->scan_band ==IEEE80211_BAND_2GHZ ) ?"2.4" :"5.2" , -jiffies_to_msecs (elapsed_jiffies - (priv->scan_start, jiffies))); +jiffies_to_msecs (jiffies - priv->scan_start));queue_work (priv->workqueue, &priv->scan_completed);
Signature · 1 line
1.7.1
Re: [PATCH 3/3] iwlwifi: kill elapsed_jiffies
Quoted 3 lines · Stanislaw Gruszka
Subtract of jiffies is fine even if one variable overwrap.
Signed-off-by Stanislaw Gruszka <[email protected]>
Against which GIT tree has your patchset to be applied?
- Sedat -
Quoted 42 lines · Stanislaw Gruszka
Signed-off-by Stanislaw Gruszka <[email protected]>---
drivers/net/wireless/iwlwifi/iwl3945-base.c | 9 +--------1 files changed, 1 insertions(+), 8 deletions(-)drivers/net/wireless/iwlwifi/iwl3945-base.c +1
-1@@ -475,7 +475,7 @@ static int iwl3945_tx_skb(struct iwl_priv *priv, struct sk_buff *skb) dma_addr_t phys_addr; dma_addr_t txcmd_phys; int txq_id = skb_get_queue_mapping(skb); - u16 len, idx, len_org, hdr_len; /* TODO: len_org is not used */ + u16 len, idx, hdr_len; u8 id; u8 unicast; u8 sta_id;@@ -612,15 +612,8 @@ static int iwl3945_tx_skb(struct iwl_priv *priv, struct sk_buff *skb)*/ len =
sizeof(struct iwl3945_tx_cmd)+sizeof(struct iwl_cmd_header)+hdr_len; -
-len_org= len;
len = (len + 3) & ~3;- if (
len_org!= len)
-len_org= 1;
- else
-len_org= 0;
-
/* Physical address of this Tx command's header (not MAC header!),
* within command buffer array. */
txcmd_phys = pci_map_single(priv->pci_dev,&out_cmd->hdr, --
1.7.1--
To unsubscribe from this list: send the line "unsubscribe linux-wireless" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Quoted 1 line · Sedat Dilek
Against which GIT tree has your patchset to be applied?
wireless-testing
Stanislaw
Quoted 1 line · Stanislaw Gruszka
Signed-off-by Stanislaw Gruszka <[email protected]>