All of lore.kernel.org
 help / color / mirror / Atom feed
* [ath9k-devel] [PATCH 0/6] ath10k: coding style cleanup
@ 2013-04-26  7:52 Michal Kazior
  2013-04-26  7:52 ` [ath9k-devel] [PATCH 1/6] ath10k: fix code style and add comments to tx code Michal Kazior
                   ` (6 more replies)
  0 siblings, 7 replies; 17+ messages in thread
From: Michal Kazior @ 2013-04-26  7:52 UTC (permalink / raw)
  To: ath9k-devel

Michal Kazior (6):
  ath10k: fix code style and add comments to tx code
  ath10k: tweak ath10k_pci_diag_read_mem() prototype
  ath10k: tweak ath10k_pci_diag_write_mem() prototype
  ath10k: drop unnecessary else branch
  ath10k: drop unnecessary else branch
  ath10k: cleanup ath10k_pci_stop_intr()

 drivers/net/wireless/ath/ath10k/htt_tx.c |    4 ++
 drivers/net/wireless/ath/ath10k/pci.c    |   68 +++++++++++++-----------------
 drivers/net/wireless/ath/ath10k/txrx.c   |    4 +-
 3 files changed, 37 insertions(+), 39 deletions(-)

-- 
1.7.9.5

^ permalink raw reply	[flat|nested] 17+ messages in thread

* [ath9k-devel] [PATCH 1/6] ath10k: fix code style and add comments to tx code
  2013-04-26  7:52 [ath9k-devel] [PATCH 0/6] ath10k: coding style cleanup Michal Kazior
@ 2013-04-26  7:52 ` Michal Kazior
  2013-04-26  7:52 ` [ath9k-devel] [PATCH 2/6] ath10k: tweak ath10k_pci_diag_read_mem() prototype Michal Kazior
                   ` (5 subsequent siblings)
  6 siblings, 0 replies; 17+ messages in thread
From: Michal Kazior @ 2013-04-26  7:52 UTC (permalink / raw)
  To: ath9k-devel

Signed-off-by: Michal Kazior <michal.kazior@tieto.com>
---
 drivers/net/wireless/ath/ath10k/htt_tx.c |    4 ++++
 drivers/net/wireless/ath/ath10k/txrx.c   |    4 +++-
 2 files changed, 7 insertions(+), 1 deletion(-)

diff --git a/drivers/net/wireless/ath/ath10k/htt_tx.c b/drivers/net/wireless/ath/ath10k/htt_tx.c
index 9f7ee9e..edbe4f4 100644
--- a/drivers/net/wireless/ath/ath10k/htt_tx.c
+++ b/drivers/net/wireless/ath/ath10k/htt_tx.c
@@ -271,6 +271,8 @@ int ath10k_htt_mgmt_tx(struct ath10k_htt *htt, struct sk_buff *msdu)
 	memcpy(cmd->mgmt_tx.hdr, msdu->data,
 	       min((int)msdu->len, HTT_MGMT_FRM_HDR_DOWNLOAD_LEN));
 
+	/* refcount is decremented by HTC and HTT completions until it reaches
+	 * zero and is freed */
 	skb_cb = ATH10K_SKB_CB(txdesc);
 	skb_cb->htt.msdu_id = msdu_id;
 	skb_cb->htt.refcount = 2;
@@ -403,6 +405,8 @@ int ath10k_htt_tx(struct ath10k_htt *htt, struct sk_buff *msdu)
 
 	memcpy(cmd->data_tx.prefetch, msdu->data, prefetch_len);
 
+	/* refcount is decremented by HTC and HTT completions until it reaches
+	 * zero and is freed */
 	skb_cb = ATH10K_SKB_CB(txdesc);
 	skb_cb->htt.msdu_id = msdu_id;
 	skb_cb->htt.refcount = 2;
diff --git a/drivers/net/wireless/ath/ath10k/txrx.c b/drivers/net/wireless/ath/ath10k/txrx.c
index ab5eb3b..dd51d38 100644
--- a/drivers/net/wireless/ath/ath10k/txrx.c
+++ b/drivers/net/wireless/ath/ath10k/txrx.c
@@ -55,7 +55,9 @@ void ath10k_txrx_tx_unref(struct ath10k_htt *htt, struct sk_buff *txdesc)
 	if (ATH10K_SKB_CB(txdesc)->htt.refcount == 0)
 		return;
 
-	if (--ATH10K_SKB_CB(txdesc)->htt.refcount > 0)
+	ATH10K_SKB_CB(txdesc)->htt.refcount--;
+
+	if (ATH10K_SKB_CB(txdesc)->htt.refcount > 0)
 		return;
 
 	if (txfrag) {
-- 
1.7.9.5

^ permalink raw reply related	[flat|nested] 17+ messages in thread

* [ath9k-devel] [PATCH 2/6] ath10k: tweak ath10k_pci_diag_read_mem() prototype
  2013-04-26  7:52 [ath9k-devel] [PATCH 0/6] ath10k: coding style cleanup Michal Kazior
  2013-04-26  7:52 ` [ath9k-devel] [PATCH 1/6] ath10k: fix code style and add comments to tx code Michal Kazior
@ 2013-04-26  7:52 ` Michal Kazior
  2013-04-26  7:52 ` [ath9k-devel] [PATCH 3/6] ath10k: tweak ath10k_pci_diag_write_mem() prototype Michal Kazior
                   ` (4 subsequent siblings)
  6 siblings, 0 replies; 17+ messages in thread
From: Michal Kazior @ 2013-04-26  7:52 UTC (permalink / raw)
  To: ath9k-devel

It reads not well defined data thus void pointer
seems a better match here.

Signed-off-by: Michal Kazior <michal.kazior@tieto.com>
---
 drivers/net/wireless/ath/ath10k/pci.c |    9 ++++-----
 1 file changed, 4 insertions(+), 5 deletions(-)

diff --git a/drivers/net/wireless/ath/ath10k/pci.c b/drivers/net/wireless/ath/ath10k/pci.c
index e7874b2..278db71 100644
--- a/drivers/net/wireless/ath/ath10k/pci.c
+++ b/drivers/net/wireless/ath/ath10k/pci.c
@@ -98,7 +98,7 @@ static const struct ce_pipe_config target_ce_config_wlan[] = {
  * Caller must guarantee proper alignment, when applicable, and single user
  * at any moment.
  */
-static int ath10k_pci_diag_read_mem(struct ath10k *ar, u32 address, u8 *data,
+static int ath10k_pci_diag_read_mem(struct ath10k *ar, u32 address, void *data,
 				    int nbytes)
 {
 	struct ath10k_pci *ar_pci = ath10k_pci_priv(ar);
@@ -248,8 +248,7 @@ static int ath10k_pci_diag_read_access(struct ath10k *ar, u32 address, u32 *data
 {
 	/* Assume range doesn't cross this boundary */
 	if (address >= DRAM_BASE_ADDRESS)
-		return ath10k_pci_diag_read_mem(ar, address, (u8 *)data,
-						sizeof(u32));
+		return ath10k_pci_diag_read_mem(ar, address, data, sizeof(u32));
 	else {
 		ath10k_pci_wake(ar);
 		*data = ath10k_pci_read32(ar, address);
@@ -692,7 +691,7 @@ static void ath10k_pci_hif_dump_area(struct ath10k *ar)
 
 	host_addr = host_interest_item_address(HI_ITEM(hi_failure_state));
 	if (ath10k_pci_diag_read_mem(ar, host_addr,
-				     (u8 *) &reg_dump_area, sizeof(u32)) != 0) {
+				     &reg_dump_area, sizeof(u32)) != 0) {
 		ath10k_warn("could not read hi_failure_state\n");
 		return;
 	}
@@ -700,7 +699,7 @@ static void ath10k_pci_hif_dump_area(struct ath10k *ar)
 	ath10k_err("target register Dump Location: 0x%08X\n", reg_dump_area);
 
 	if (ath10k_pci_diag_read_mem(ar, reg_dump_area,
-				     (u8 *) &reg_dump_values[0],
+				     &reg_dump_values[0],
 				     REG_DUMP_COUNT_QCA988X * sizeof(u32)) != 0) {
 		ath10k_err("could not dump FW Dump Area\n");
 		return;
-- 
1.7.9.5

^ permalink raw reply related	[flat|nested] 17+ messages in thread

* [ath9k-devel] [PATCH 3/6] ath10k: tweak ath10k_pci_diag_write_mem() prototype
  2013-04-26  7:52 [ath9k-devel] [PATCH 0/6] ath10k: coding style cleanup Michal Kazior
  2013-04-26  7:52 ` [ath9k-devel] [PATCH 1/6] ath10k: fix code style and add comments to tx code Michal Kazior
  2013-04-26  7:52 ` [ath9k-devel] [PATCH 2/6] ath10k: tweak ath10k_pci_diag_read_mem() prototype Michal Kazior
@ 2013-04-26  7:52 ` Michal Kazior
  2013-04-26  7:52 ` [ath9k-devel] [PATCH 4/6] ath10k: drop unnecessary else branch Michal Kazior
                   ` (3 subsequent siblings)
  6 siblings, 0 replies; 17+ messages in thread
From: Michal Kazior @ 2013-04-26  7:52 UTC (permalink / raw)
  To: ath9k-devel

It doesn't modify the data argument thus const. It
also is more suitable to use void pointer here
since the payload type is not well defined.

Signed-off-by: Michal Kazior <michal.kazior@tieto.com>
---
 drivers/net/wireless/ath/ath10k/pci.c |   14 +++++++-------
 1 file changed, 7 insertions(+), 7 deletions(-)

diff --git a/drivers/net/wireless/ath/ath10k/pci.c b/drivers/net/wireless/ath/ath10k/pci.c
index 278db71..ddef94e 100644
--- a/drivers/net/wireless/ath/ath10k/pci.c
+++ b/drivers/net/wireless/ath/ath10k/pci.c
@@ -257,8 +257,8 @@ static int ath10k_pci_diag_read_access(struct ath10k *ar, u32 address, u32 *data
 	}
 }
 
-static int ath10k_pci_diag_write_mem(struct ath10k *ar, u32 address, u8 *data,
-				     int nbytes)
+static int ath10k_pci_diag_write_mem(struct ath10k *ar, u32 address,
+				     const void *data, int nbytes)
 {
 	struct ath10k_pci *ar_pci = ath10k_pci_priv(ar);
 	int ret = 0;
@@ -395,8 +395,8 @@ static int ath10k_pci_diag_write_access(struct ath10k *ar, u32 address,
 	/* Assume range doesn't cross this boundary */
 	if (address >= DRAM_BASE_ADDRESS) {
 		u32 data_buf = data;
-		return ath10k_pci_diag_write_mem(ar, address, (u8 *) &data_buf,
-					  sizeof(u32));
+		return ath10k_pci_diag_write_mem(ar, address, &data_buf,
+						 sizeof(u32));
 	} else {
 		ath10k_pci_wake(ar);
 		ath10k_pci_write32(ar, address, data);
@@ -1503,7 +1503,7 @@ static int ath10k_pci_init_config(struct ath10k *ar)
 	}
 
 	ret = ath10k_pci_diag_write_mem(ar, pipe_cfg_targ_addr,
-				 (u8 *) target_ce_config_wlan,
+				 target_ce_config_wlan,
 				 sizeof(target_ce_config_wlan));
 
 	if (ret != 0) {
@@ -1526,7 +1526,7 @@ static int ath10k_pci_init_config(struct ath10k *ar)
 	}
 
 	ret = ath10k_pci_diag_write_mem(ar, svc_to_pipe_map,
-				 (u8 *) target_service_to_ce_map_wlan,
+				 target_service_to_ce_map_wlan,
 				 sizeof(target_service_to_ce_map_wlan));
 	if (ret != 0) {
 		ath10k_err("Failed to write svc/pipe map: %d\n", ret);
@@ -1545,7 +1545,7 @@ static int ath10k_pci_init_config(struct ath10k *ar)
 
 	ret = ath10k_pci_diag_write_mem(ar, pcie_state_targ_addr +
 				 offsetof(struct pcie_state, config_flags),
-				 (u8 *) &pcie_config_flags,
+				 &pcie_config_flags,
 				 sizeof(pcie_config_flags));
 	if (ret != 0) {
 		ath10k_err("Failed to write pcie config_flags: %d\n", ret);
-- 
1.7.9.5

^ permalink raw reply related	[flat|nested] 17+ messages in thread

* [ath9k-devel] [PATCH 4/6] ath10k: drop unnecessary else branch
  2013-04-26  7:52 [ath9k-devel] [PATCH 0/6] ath10k: coding style cleanup Michal Kazior
                   ` (2 preceding siblings ...)
  2013-04-26  7:52 ` [ath9k-devel] [PATCH 3/6] ath10k: tweak ath10k_pci_diag_write_mem() prototype Michal Kazior
@ 2013-04-26  7:52 ` Michal Kazior
  2013-04-26  7:52 ` [ath9k-devel] [PATCH 5/6] " Michal Kazior
                   ` (2 subsequent siblings)
  6 siblings, 0 replies; 17+ messages in thread
From: Michal Kazior @ 2013-04-26  7:52 UTC (permalink / raw)
  To: ath9k-devel

Signed-off-by: Michal Kazior <michal.kazior@tieto.com>
---
 drivers/net/wireless/ath/ath10k/pci.c |   26 +++++++++++---------------
 1 file changed, 11 insertions(+), 15 deletions(-)

diff --git a/drivers/net/wireless/ath/ath10k/pci.c b/drivers/net/wireless/ath/ath10k/pci.c
index ddef94e..c3c91a0 100644
--- a/drivers/net/wireless/ath/ath10k/pci.c
+++ b/drivers/net/wireless/ath/ath10k/pci.c
@@ -249,12 +249,11 @@ static int ath10k_pci_diag_read_access(struct ath10k *ar, u32 address, u32 *data
 	/* Assume range doesn't cross this boundary */
 	if (address >= DRAM_BASE_ADDRESS)
 		return ath10k_pci_diag_read_mem(ar, address, data, sizeof(u32));
-	else {
-		ath10k_pci_wake(ar);
-		*data = ath10k_pci_read32(ar, address);
-		ath10k_pci_sleep(ar);
-		return 0;
-	}
+
+	ath10k_pci_wake(ar);
+	*data = ath10k_pci_read32(ar, address);
+	ath10k_pci_sleep(ar);
+	return 0;
 }
 
 static int ath10k_pci_diag_write_mem(struct ath10k *ar, u32 address,
@@ -393,17 +392,14 @@ static int ath10k_pci_diag_write_access(struct ath10k *ar, u32 address,
 					u32 data)
 {
 	/* Assume range doesn't cross this boundary */
-	if (address >= DRAM_BASE_ADDRESS) {
-		u32 data_buf = data;
-		return ath10k_pci_diag_write_mem(ar, address, &data_buf,
+	if (address >= DRAM_BASE_ADDRESS)
+		return ath10k_pci_diag_write_mem(ar, address, &data,
 						 sizeof(u32));
-	} else {
-		ath10k_pci_wake(ar);
-		ath10k_pci_write32(ar, address, data);
-		ath10k_pci_sleep(ar);
 
-		return 0;
-	}
+	ath10k_pci_wake(ar);
+	ath10k_pci_write32(ar, address, data);
+	ath10k_pci_sleep(ar);
+	return 0;
 }
 
 static bool ath10k_pci_target_is_awake(struct ath10k *ar)
-- 
1.7.9.5

^ permalink raw reply related	[flat|nested] 17+ messages in thread

* [ath9k-devel] [PATCH 5/6] ath10k: drop unnecessary else branch
  2013-04-26  7:52 [ath9k-devel] [PATCH 0/6] ath10k: coding style cleanup Michal Kazior
                   ` (3 preceding siblings ...)
  2013-04-26  7:52 ` [ath9k-devel] [PATCH 4/6] ath10k: drop unnecessary else branch Michal Kazior
@ 2013-04-26  7:52 ` Michal Kazior
  2013-04-26  7:52 ` [ath9k-devel] [PATCH 6/6] ath10k: cleanup ath10k_pci_stop_intr() Michal Kazior
  2013-04-30 11:13 ` [ath9k-devel] [PATCH v2 0/6] ath10k: coding style cleanup Michal Kazior
  6 siblings, 0 replies; 17+ messages in thread
From: Michal Kazior @ 2013-04-26  7:52 UTC (permalink / raw)
  To: ath9k-devel

ath10k_pci_{sleep,wake} do refcounting and the
awake sections can be nested.

Signed-off-by: Michal Kazior <michal.kazior@tieto.com>
---
 drivers/net/wireless/ath/ath10k/pci.c |    5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/drivers/net/wireless/ath/ath10k/pci.c b/drivers/net/wireless/ath/ath10k/pci.c
index c3c91a0..d521270 100644
--- a/drivers/net/wireless/ath/ath10k/pci.c
+++ b/drivers/net/wireless/ath/ath10k/pci.c
@@ -1650,7 +1650,6 @@ static void ath10k_pci_fw_interrupt_handler(struct ath10k *ar)
 	if (fw_indicator & FW_IND_EVENT_PENDING) {
 		/* ACK: clear Target-side pending event */
 		ath10k_pci_write32(ar, fw_indicator_address, fw_indicator & ~FW_IND_EVENT_PENDING);
-		ath10k_pci_sleep(ar);
 
 		if (ar_pci->started)
 			ath10k_pci_hif_dump_area(ar);
@@ -1661,9 +1660,9 @@ static void ath10k_pci_fw_interrupt_handler(struct ath10k *ar)
 			 */
 			ath10k_warn("early firmware event indicated\n");
 		}
-	} else {
-		ath10k_pci_sleep(ar);
 	}
+
+	ath10k_pci_sleep(ar);
 }
 
 static const struct ath10k_hif_ops ath10k_pci_hif_ops = {
-- 
1.7.9.5

^ permalink raw reply related	[flat|nested] 17+ messages in thread

* [ath9k-devel] [PATCH 6/6] ath10k: cleanup ath10k_pci_stop_intr()
  2013-04-26  7:52 [ath9k-devel] [PATCH 0/6] ath10k: coding style cleanup Michal Kazior
                   ` (4 preceding siblings ...)
  2013-04-26  7:52 ` [ath9k-devel] [PATCH 5/6] " Michal Kazior
@ 2013-04-26  7:52 ` Michal Kazior
  2013-04-30  7:23   ` Kalle Valo
  2013-04-30 11:13 ` [ath9k-devel] [PATCH v2 0/6] ath10k: coding style cleanup Michal Kazior
  6 siblings, 1 reply; 17+ messages in thread
From: Michal Kazior @ 2013-04-26  7:52 UTC (permalink / raw)
  To: ath9k-devel

Signed-off-by: Michal Kazior <michal.kazior@tieto.com>
---
 drivers/net/wireless/ath/ath10k/pci.c |   16 +++++++---------
 1 file changed, 7 insertions(+), 9 deletions(-)

diff --git a/drivers/net/wireless/ath/ath10k/pci.c b/drivers/net/wireless/ath/ath10k/pci.c
index d521270..31881f9 100644
--- a/drivers/net/wireless/ath/ath10k/pci.c
+++ b/drivers/net/wireless/ath/ath10k/pci.c
@@ -1937,18 +1937,16 @@ exit:
 
 static void ath10k_pci_stop_intr(struct ath10k *ar)
 {
-	int i;
 	struct ath10k_pci *ar_pci = ath10k_pci_priv(ar);
+	int i;
 
-	if (ar_pci->num_msi_intrs > 0) {
-		/* MSI interrupt(s) */
-		for (i = 0; i < ar_pci->num_msi_intrs; i++)
-			free_irq(ar_pci->pdev->irq + i, ar);
-		ar_pci->num_msi_intrs = 0;
+	/* There's at least one interrupt irregardless whether its legacy INTR
+	 * or MSI or MSI-X */
+	for (i = 0; i < min(1, ar_pci->num_msi_intrs); i++)
+		free_irq(ar_pci->pdev->irq + i, ar);
+
+	if (ar_pci->num_msi_intrs > 0)
 		pci_disable_msi(ar_pci->pdev);
-	} else
-		/* Legacy PCI line interrupt */
-		free_irq(ar_pci->pdev->irq, ar);
 }
 
 static int ath10k_pci_reset_target(struct ath10k *ar)
-- 
1.7.9.5

^ permalink raw reply related	[flat|nested] 17+ messages in thread

* [ath9k-devel] [PATCH 6/6] ath10k: cleanup ath10k_pci_stop_intr()
  2013-04-26  7:52 ` [ath9k-devel] [PATCH 6/6] ath10k: cleanup ath10k_pci_stop_intr() Michal Kazior
@ 2013-04-30  7:23   ` Kalle Valo
  2013-04-30  7:51     ` Michal Kazior
  0 siblings, 1 reply; 17+ messages in thread
From: Kalle Valo @ 2013-04-30  7:23 UTC (permalink / raw)
  To: ath9k-devel

Michal Kazior <michal.kazior@tieto.com> writes:

> Signed-off-by: Michal Kazior <michal.kazior@tieto.com>

[...]

> +	/* There's at least one interrupt irregardless whether its legacy INTR
> +	 * or MSI or MSI-X */
> +	for (i = 0; i < min(1, ar_pci->num_msi_intrs); i++)
> +		free_irq(ar_pci->pdev->irq + i, ar);

I'm not sure about this. If num_msi_intrs is 5 we still free only the
first irq? Did I understood this correctly?

-- 
Kalle Valo

^ permalink raw reply	[flat|nested] 17+ messages in thread

* [ath9k-devel] [PATCH 6/6] ath10k: cleanup ath10k_pci_stop_intr()
  2013-04-30  7:23   ` Kalle Valo
@ 2013-04-30  7:51     ` Michal Kazior
  0 siblings, 0 replies; 17+ messages in thread
From: Michal Kazior @ 2013-04-30  7:51 UTC (permalink / raw)
  To: ath9k-devel

On 30/04/13 09:23, Kalle Valo wrote:
> Michal Kazior <michal.kazior@tieto.com> writes:
>
>> Signed-off-by: Michal Kazior <michal.kazior@tieto.com>
>
> [...]
>
>> +	/* There's at least one interrupt irregardless whether its legacy INTR
>> +	 * or MSI or MSI-X */
>> +	for (i = 0; i < min(1, ar_pci->num_msi_intrs); i++)
>> +		free_irq(ar_pci->pdev->irq + i, ar);
>
> I'm not sure about this. If num_msi_intrs is 5 we still free only the
> first irq? Did I understood this correctly?

Oh my! This is supposed to be max(). Good catch, thanks!


-- Pozdrawiam / Best regards, Michal Kazior.

^ permalink raw reply	[flat|nested] 17+ messages in thread

* [ath9k-devel] [PATCH v2 0/6] ath10k: coding style cleanup
  2013-04-26  7:52 [ath9k-devel] [PATCH 0/6] ath10k: coding style cleanup Michal Kazior
                   ` (5 preceding siblings ...)
  2013-04-26  7:52 ` [ath9k-devel] [PATCH 6/6] ath10k: cleanup ath10k_pci_stop_intr() Michal Kazior
@ 2013-04-30 11:13 ` Michal Kazior
  2013-04-30 11:13   ` [ath9k-devel] [PATCH v2 1/6] ath10k: fix code style and add comments to tx code Michal Kazior
                     ` (6 more replies)
  6 siblings, 7 replies; 17+ messages in thread
From: Michal Kazior @ 2013-04-30 11:13 UTC (permalink / raw)
  To: ath9k-devel

v2: fixed patch #6

Michal Kazior (6):
  ath10k: fix code style and add comments to tx code
  ath10k: tweak ath10k_pci_diag_read_mem() prototype
  ath10k: tweak ath10k_pci_diag_write_mem() prototype
  ath10k: drop unnecessary else branch
  ath10k: drop unnecessary else branch
  ath10k: cleanup ath10k_pci_stop_intr()

 drivers/net/wireless/ath/ath10k/htt_tx.c |    4 ++
 drivers/net/wireless/ath/ath10k/pci.c    |   68 +++++++++++++-----------------
 drivers/net/wireless/ath/ath10k/txrx.c   |    4 +-
 3 files changed, 37 insertions(+), 39 deletions(-)

-- 
1.7.9.5

^ permalink raw reply	[flat|nested] 17+ messages in thread

* [ath9k-devel] [PATCH v2 1/6] ath10k: fix code style and add comments to tx code
  2013-04-30 11:13 ` [ath9k-devel] [PATCH v2 0/6] ath10k: coding style cleanup Michal Kazior
@ 2013-04-30 11:13   ` Michal Kazior
  2013-04-30 11:13   ` [ath9k-devel] [PATCH v2 2/6] ath10k: tweak ath10k_pci_diag_read_mem() prototype Michal Kazior
                     ` (5 subsequent siblings)
  6 siblings, 0 replies; 17+ messages in thread
From: Michal Kazior @ 2013-04-30 11:13 UTC (permalink / raw)
  To: ath9k-devel

Signed-off-by: Michal Kazior <michal.kazior@tieto.com>
---
 drivers/net/wireless/ath/ath10k/htt_tx.c |    4 ++++
 drivers/net/wireless/ath/ath10k/txrx.c   |    4 +++-
 2 files changed, 7 insertions(+), 1 deletion(-)

diff --git a/drivers/net/wireless/ath/ath10k/htt_tx.c b/drivers/net/wireless/ath/ath10k/htt_tx.c
index 9f7ee9e..edbe4f4 100644
--- a/drivers/net/wireless/ath/ath10k/htt_tx.c
+++ b/drivers/net/wireless/ath/ath10k/htt_tx.c
@@ -271,6 +271,8 @@ int ath10k_htt_mgmt_tx(struct ath10k_htt *htt, struct sk_buff *msdu)
 	memcpy(cmd->mgmt_tx.hdr, msdu->data,
 	       min((int)msdu->len, HTT_MGMT_FRM_HDR_DOWNLOAD_LEN));
 
+	/* refcount is decremented by HTC and HTT completions until it reaches
+	 * zero and is freed */
 	skb_cb = ATH10K_SKB_CB(txdesc);
 	skb_cb->htt.msdu_id = msdu_id;
 	skb_cb->htt.refcount = 2;
@@ -403,6 +405,8 @@ int ath10k_htt_tx(struct ath10k_htt *htt, struct sk_buff *msdu)
 
 	memcpy(cmd->data_tx.prefetch, msdu->data, prefetch_len);
 
+	/* refcount is decremented by HTC and HTT completions until it reaches
+	 * zero and is freed */
 	skb_cb = ATH10K_SKB_CB(txdesc);
 	skb_cb->htt.msdu_id = msdu_id;
 	skb_cb->htt.refcount = 2;
diff --git a/drivers/net/wireless/ath/ath10k/txrx.c b/drivers/net/wireless/ath/ath10k/txrx.c
index a54ad8f..9d0b1e2 100644
--- a/drivers/net/wireless/ath/ath10k/txrx.c
+++ b/drivers/net/wireless/ath/ath10k/txrx.c
@@ -55,7 +55,9 @@ void ath10k_txrx_tx_unref(struct ath10k_htt *htt, struct sk_buff *txdesc)
 	if (ATH10K_SKB_CB(txdesc)->htt.refcount == 0)
 		return;
 
-	if (--ATH10K_SKB_CB(txdesc)->htt.refcount > 0)
+	ATH10K_SKB_CB(txdesc)->htt.refcount--;
+
+	if (ATH10K_SKB_CB(txdesc)->htt.refcount > 0)
 		return;
 
 	if (txfrag) {
-- 
1.7.9.5

^ permalink raw reply related	[flat|nested] 17+ messages in thread

* [ath9k-devel] [PATCH v2 2/6] ath10k: tweak ath10k_pci_diag_read_mem() prototype
  2013-04-30 11:13 ` [ath9k-devel] [PATCH v2 0/6] ath10k: coding style cleanup Michal Kazior
  2013-04-30 11:13   ` [ath9k-devel] [PATCH v2 1/6] ath10k: fix code style and add comments to tx code Michal Kazior
@ 2013-04-30 11:13   ` Michal Kazior
  2013-04-30 11:13   ` [ath9k-devel] [PATCH v2 3/6] ath10k: tweak ath10k_pci_diag_write_mem() prototype Michal Kazior
                     ` (4 subsequent siblings)
  6 siblings, 0 replies; 17+ messages in thread
From: Michal Kazior @ 2013-04-30 11:13 UTC (permalink / raw)
  To: ath9k-devel

It reads not well defined data thus void pointer
seems a better match here.

Signed-off-by: Michal Kazior <michal.kazior@tieto.com>
---
 drivers/net/wireless/ath/ath10k/pci.c |    9 ++++-----
 1 file changed, 4 insertions(+), 5 deletions(-)

diff --git a/drivers/net/wireless/ath/ath10k/pci.c b/drivers/net/wireless/ath/ath10k/pci.c
index e7874b2..278db71 100644
--- a/drivers/net/wireless/ath/ath10k/pci.c
+++ b/drivers/net/wireless/ath/ath10k/pci.c
@@ -98,7 +98,7 @@ static const struct ce_pipe_config target_ce_config_wlan[] = {
  * Caller must guarantee proper alignment, when applicable, and single user
  * at any moment.
  */
-static int ath10k_pci_diag_read_mem(struct ath10k *ar, u32 address, u8 *data,
+static int ath10k_pci_diag_read_mem(struct ath10k *ar, u32 address, void *data,
 				    int nbytes)
 {
 	struct ath10k_pci *ar_pci = ath10k_pci_priv(ar);
@@ -248,8 +248,7 @@ static int ath10k_pci_diag_read_access(struct ath10k *ar, u32 address, u32 *data
 {
 	/* Assume range doesn't cross this boundary */
 	if (address >= DRAM_BASE_ADDRESS)
-		return ath10k_pci_diag_read_mem(ar, address, (u8 *)data,
-						sizeof(u32));
+		return ath10k_pci_diag_read_mem(ar, address, data, sizeof(u32));
 	else {
 		ath10k_pci_wake(ar);
 		*data = ath10k_pci_read32(ar, address);
@@ -692,7 +691,7 @@ static void ath10k_pci_hif_dump_area(struct ath10k *ar)
 
 	host_addr = host_interest_item_address(HI_ITEM(hi_failure_state));
 	if (ath10k_pci_diag_read_mem(ar, host_addr,
-				     (u8 *) &reg_dump_area, sizeof(u32)) != 0) {
+				     &reg_dump_area, sizeof(u32)) != 0) {
 		ath10k_warn("could not read hi_failure_state\n");
 		return;
 	}
@@ -700,7 +699,7 @@ static void ath10k_pci_hif_dump_area(struct ath10k *ar)
 	ath10k_err("target register Dump Location: 0x%08X\n", reg_dump_area);
 
 	if (ath10k_pci_diag_read_mem(ar, reg_dump_area,
-				     (u8 *) &reg_dump_values[0],
+				     &reg_dump_values[0],
 				     REG_DUMP_COUNT_QCA988X * sizeof(u32)) != 0) {
 		ath10k_err("could not dump FW Dump Area\n");
 		return;
-- 
1.7.9.5

^ permalink raw reply related	[flat|nested] 17+ messages in thread

* [ath9k-devel] [PATCH v2 3/6] ath10k: tweak ath10k_pci_diag_write_mem() prototype
  2013-04-30 11:13 ` [ath9k-devel] [PATCH v2 0/6] ath10k: coding style cleanup Michal Kazior
  2013-04-30 11:13   ` [ath9k-devel] [PATCH v2 1/6] ath10k: fix code style and add comments to tx code Michal Kazior
  2013-04-30 11:13   ` [ath9k-devel] [PATCH v2 2/6] ath10k: tweak ath10k_pci_diag_read_mem() prototype Michal Kazior
@ 2013-04-30 11:13   ` Michal Kazior
  2013-04-30 11:13   ` [ath9k-devel] [PATCH v2 4/6] ath10k: drop unnecessary else branch Michal Kazior
                     ` (3 subsequent siblings)
  6 siblings, 0 replies; 17+ messages in thread
From: Michal Kazior @ 2013-04-30 11:13 UTC (permalink / raw)
  To: ath9k-devel

It doesn't modify the data argument thus const. It
also is more suitable to use void pointer here
since the payload type is not well defined.

Signed-off-by: Michal Kazior <michal.kazior@tieto.com>
---
 drivers/net/wireless/ath/ath10k/pci.c |   14 +++++++-------
 1 file changed, 7 insertions(+), 7 deletions(-)

diff --git a/drivers/net/wireless/ath/ath10k/pci.c b/drivers/net/wireless/ath/ath10k/pci.c
index 278db71..ddef94e 100644
--- a/drivers/net/wireless/ath/ath10k/pci.c
+++ b/drivers/net/wireless/ath/ath10k/pci.c
@@ -257,8 +257,8 @@ static int ath10k_pci_diag_read_access(struct ath10k *ar, u32 address, u32 *data
 	}
 }
 
-static int ath10k_pci_diag_write_mem(struct ath10k *ar, u32 address, u8 *data,
-				     int nbytes)
+static int ath10k_pci_diag_write_mem(struct ath10k *ar, u32 address,
+				     const void *data, int nbytes)
 {
 	struct ath10k_pci *ar_pci = ath10k_pci_priv(ar);
 	int ret = 0;
@@ -395,8 +395,8 @@ static int ath10k_pci_diag_write_access(struct ath10k *ar, u32 address,
 	/* Assume range doesn't cross this boundary */
 	if (address >= DRAM_BASE_ADDRESS) {
 		u32 data_buf = data;
-		return ath10k_pci_diag_write_mem(ar, address, (u8 *) &data_buf,
-					  sizeof(u32));
+		return ath10k_pci_diag_write_mem(ar, address, &data_buf,
+						 sizeof(u32));
 	} else {
 		ath10k_pci_wake(ar);
 		ath10k_pci_write32(ar, address, data);
@@ -1503,7 +1503,7 @@ static int ath10k_pci_init_config(struct ath10k *ar)
 	}
 
 	ret = ath10k_pci_diag_write_mem(ar, pipe_cfg_targ_addr,
-				 (u8 *) target_ce_config_wlan,
+				 target_ce_config_wlan,
 				 sizeof(target_ce_config_wlan));
 
 	if (ret != 0) {
@@ -1526,7 +1526,7 @@ static int ath10k_pci_init_config(struct ath10k *ar)
 	}
 
 	ret = ath10k_pci_diag_write_mem(ar, svc_to_pipe_map,
-				 (u8 *) target_service_to_ce_map_wlan,
+				 target_service_to_ce_map_wlan,
 				 sizeof(target_service_to_ce_map_wlan));
 	if (ret != 0) {
 		ath10k_err("Failed to write svc/pipe map: %d\n", ret);
@@ -1545,7 +1545,7 @@ static int ath10k_pci_init_config(struct ath10k *ar)
 
 	ret = ath10k_pci_diag_write_mem(ar, pcie_state_targ_addr +
 				 offsetof(struct pcie_state, config_flags),
-				 (u8 *) &pcie_config_flags,
+				 &pcie_config_flags,
 				 sizeof(pcie_config_flags));
 	if (ret != 0) {
 		ath10k_err("Failed to write pcie config_flags: %d\n", ret);
-- 
1.7.9.5

^ permalink raw reply related	[flat|nested] 17+ messages in thread

* [ath9k-devel] [PATCH v2 4/6] ath10k: drop unnecessary else branch
  2013-04-30 11:13 ` [ath9k-devel] [PATCH v2 0/6] ath10k: coding style cleanup Michal Kazior
                     ` (2 preceding siblings ...)
  2013-04-30 11:13   ` [ath9k-devel] [PATCH v2 3/6] ath10k: tweak ath10k_pci_diag_write_mem() prototype Michal Kazior
@ 2013-04-30 11:13   ` Michal Kazior
  2013-04-30 11:13   ` [ath9k-devel] [PATCH v2 5/6] " Michal Kazior
                     ` (2 subsequent siblings)
  6 siblings, 0 replies; 17+ messages in thread
From: Michal Kazior @ 2013-04-30 11:13 UTC (permalink / raw)
  To: ath9k-devel

Signed-off-by: Michal Kazior <michal.kazior@tieto.com>
---
 drivers/net/wireless/ath/ath10k/pci.c |   26 +++++++++++---------------
 1 file changed, 11 insertions(+), 15 deletions(-)

diff --git a/drivers/net/wireless/ath/ath10k/pci.c b/drivers/net/wireless/ath/ath10k/pci.c
index ddef94e..c3c91a0 100644
--- a/drivers/net/wireless/ath/ath10k/pci.c
+++ b/drivers/net/wireless/ath/ath10k/pci.c
@@ -249,12 +249,11 @@ static int ath10k_pci_diag_read_access(struct ath10k *ar, u32 address, u32 *data
 	/* Assume range doesn't cross this boundary */
 	if (address >= DRAM_BASE_ADDRESS)
 		return ath10k_pci_diag_read_mem(ar, address, data, sizeof(u32));
-	else {
-		ath10k_pci_wake(ar);
-		*data = ath10k_pci_read32(ar, address);
-		ath10k_pci_sleep(ar);
-		return 0;
-	}
+
+	ath10k_pci_wake(ar);
+	*data = ath10k_pci_read32(ar, address);
+	ath10k_pci_sleep(ar);
+	return 0;
 }
 
 static int ath10k_pci_diag_write_mem(struct ath10k *ar, u32 address,
@@ -393,17 +392,14 @@ static int ath10k_pci_diag_write_access(struct ath10k *ar, u32 address,
 					u32 data)
 {
 	/* Assume range doesn't cross this boundary */
-	if (address >= DRAM_BASE_ADDRESS) {
-		u32 data_buf = data;
-		return ath10k_pci_diag_write_mem(ar, address, &data_buf,
+	if (address >= DRAM_BASE_ADDRESS)
+		return ath10k_pci_diag_write_mem(ar, address, &data,
 						 sizeof(u32));
-	} else {
-		ath10k_pci_wake(ar);
-		ath10k_pci_write32(ar, address, data);
-		ath10k_pci_sleep(ar);
 
-		return 0;
-	}
+	ath10k_pci_wake(ar);
+	ath10k_pci_write32(ar, address, data);
+	ath10k_pci_sleep(ar);
+	return 0;
 }
 
 static bool ath10k_pci_target_is_awake(struct ath10k *ar)
-- 
1.7.9.5

^ permalink raw reply related	[flat|nested] 17+ messages in thread

* [ath9k-devel] [PATCH v2 5/6] ath10k: drop unnecessary else branch
  2013-04-30 11:13 ` [ath9k-devel] [PATCH v2 0/6] ath10k: coding style cleanup Michal Kazior
                     ` (3 preceding siblings ...)
  2013-04-30 11:13   ` [ath9k-devel] [PATCH v2 4/6] ath10k: drop unnecessary else branch Michal Kazior
@ 2013-04-30 11:13   ` Michal Kazior
  2013-04-30 11:13   ` [ath9k-devel] [PATCH v2 6/6] ath10k: cleanup ath10k_pci_stop_intr() Michal Kazior
  2013-04-30 11:49   ` [ath9k-devel] [PATCH v2 0/6] ath10k: coding style cleanup Kalle Valo
  6 siblings, 0 replies; 17+ messages in thread
From: Michal Kazior @ 2013-04-30 11:13 UTC (permalink / raw)
  To: ath9k-devel

ath10k_pci_{sleep,wake} do refcounting and the
awake sections can be nested.

Signed-off-by: Michal Kazior <michal.kazior@tieto.com>
---
 drivers/net/wireless/ath/ath10k/pci.c |    5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/drivers/net/wireless/ath/ath10k/pci.c b/drivers/net/wireless/ath/ath10k/pci.c
index c3c91a0..d521270 100644
--- a/drivers/net/wireless/ath/ath10k/pci.c
+++ b/drivers/net/wireless/ath/ath10k/pci.c
@@ -1650,7 +1650,6 @@ static void ath10k_pci_fw_interrupt_handler(struct ath10k *ar)
 	if (fw_indicator & FW_IND_EVENT_PENDING) {
 		/* ACK: clear Target-side pending event */
 		ath10k_pci_write32(ar, fw_indicator_address, fw_indicator & ~FW_IND_EVENT_PENDING);
-		ath10k_pci_sleep(ar);
 
 		if (ar_pci->started)
 			ath10k_pci_hif_dump_area(ar);
@@ -1661,9 +1660,9 @@ static void ath10k_pci_fw_interrupt_handler(struct ath10k *ar)
 			 */
 			ath10k_warn("early firmware event indicated\n");
 		}
-	} else {
-		ath10k_pci_sleep(ar);
 	}
+
+	ath10k_pci_sleep(ar);
 }
 
 static const struct ath10k_hif_ops ath10k_pci_hif_ops = {
-- 
1.7.9.5

^ permalink raw reply related	[flat|nested] 17+ messages in thread

* [ath9k-devel] [PATCH v2 6/6] ath10k: cleanup ath10k_pci_stop_intr()
  2013-04-30 11:13 ` [ath9k-devel] [PATCH v2 0/6] ath10k: coding style cleanup Michal Kazior
                     ` (4 preceding siblings ...)
  2013-04-30 11:13   ` [ath9k-devel] [PATCH v2 5/6] " Michal Kazior
@ 2013-04-30 11:13   ` Michal Kazior
  2013-04-30 11:49   ` [ath9k-devel] [PATCH v2 0/6] ath10k: coding style cleanup Kalle Valo
  6 siblings, 0 replies; 17+ messages in thread
From: Michal Kazior @ 2013-04-30 11:13 UTC (permalink / raw)
  To: ath9k-devel

Signed-off-by: Michal Kazior <michal.kazior@tieto.com>
---
v2: fix loop by using max()

 drivers/net/wireless/ath/ath10k/pci.c |   16 +++++++---------
 1 file changed, 7 insertions(+), 9 deletions(-)

diff --git a/drivers/net/wireless/ath/ath10k/pci.c b/drivers/net/wireless/ath/ath10k/pci.c
index d521270..9965506 100644
--- a/drivers/net/wireless/ath/ath10k/pci.c
+++ b/drivers/net/wireless/ath/ath10k/pci.c
@@ -1937,18 +1937,16 @@ exit:
 
 static void ath10k_pci_stop_intr(struct ath10k *ar)
 {
-	int i;
 	struct ath10k_pci *ar_pci = ath10k_pci_priv(ar);
+	int i;
 
-	if (ar_pci->num_msi_intrs > 0) {
-		/* MSI interrupt(s) */
-		for (i = 0; i < ar_pci->num_msi_intrs; i++)
-			free_irq(ar_pci->pdev->irq + i, ar);
-		ar_pci->num_msi_intrs = 0;
+	/* There's at least one interrupt irregardless whether its legacy INTR
+	 * or MSI or MSI-X */
+	for (i = 0; i < max(1, ar_pci->num_msi_intrs); i++)
+		free_irq(ar_pci->pdev->irq + i, ar);
+
+	if (ar_pci->num_msi_intrs > 0)
 		pci_disable_msi(ar_pci->pdev);
-	} else
-		/* Legacy PCI line interrupt */
-		free_irq(ar_pci->pdev->irq, ar);
 }
 
 static int ath10k_pci_reset_target(struct ath10k *ar)
-- 
1.7.9.5

^ permalink raw reply related	[flat|nested] 17+ messages in thread

* [ath9k-devel] [PATCH v2 0/6] ath10k: coding style cleanup
  2013-04-30 11:13 ` [ath9k-devel] [PATCH v2 0/6] ath10k: coding style cleanup Michal Kazior
                     ` (5 preceding siblings ...)
  2013-04-30 11:13   ` [ath9k-devel] [PATCH v2 6/6] ath10k: cleanup ath10k_pci_stop_intr() Michal Kazior
@ 2013-04-30 11:49   ` Kalle Valo
  6 siblings, 0 replies; 17+ messages in thread
From: Kalle Valo @ 2013-04-30 11:49 UTC (permalink / raw)
  To: ath9k-devel

Michal Kazior <michal.kazior@tieto.com> writes:

> v2: fixed patch #6
>
> Michal Kazior (6):
>   ath10k: fix code style and add comments to tx code
>   ath10k: tweak ath10k_pci_diag_read_mem() prototype
>   ath10k: tweak ath10k_pci_diag_write_mem() prototype
>   ath10k: drop unnecessary else branch
>   ath10k: drop unnecessary else branch
>   ath10k: cleanup ath10k_pci_stop_intr()

Thanks, all applied.

-- 
Kalle Valo

^ permalink raw reply	[flat|nested] 17+ messages in thread

end of thread, other threads:[~2013-04-30 11:49 UTC | newest]

Thread overview: 17+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-04-26  7:52 [ath9k-devel] [PATCH 0/6] ath10k: coding style cleanup Michal Kazior
2013-04-26  7:52 ` [ath9k-devel] [PATCH 1/6] ath10k: fix code style and add comments to tx code Michal Kazior
2013-04-26  7:52 ` [ath9k-devel] [PATCH 2/6] ath10k: tweak ath10k_pci_diag_read_mem() prototype Michal Kazior
2013-04-26  7:52 ` [ath9k-devel] [PATCH 3/6] ath10k: tweak ath10k_pci_diag_write_mem() prototype Michal Kazior
2013-04-26  7:52 ` [ath9k-devel] [PATCH 4/6] ath10k: drop unnecessary else branch Michal Kazior
2013-04-26  7:52 ` [ath9k-devel] [PATCH 5/6] " Michal Kazior
2013-04-26  7:52 ` [ath9k-devel] [PATCH 6/6] ath10k: cleanup ath10k_pci_stop_intr() Michal Kazior
2013-04-30  7:23   ` Kalle Valo
2013-04-30  7:51     ` Michal Kazior
2013-04-30 11:13 ` [ath9k-devel] [PATCH v2 0/6] ath10k: coding style cleanup Michal Kazior
2013-04-30 11:13   ` [ath9k-devel] [PATCH v2 1/6] ath10k: fix code style and add comments to tx code Michal Kazior
2013-04-30 11:13   ` [ath9k-devel] [PATCH v2 2/6] ath10k: tweak ath10k_pci_diag_read_mem() prototype Michal Kazior
2013-04-30 11:13   ` [ath9k-devel] [PATCH v2 3/6] ath10k: tweak ath10k_pci_diag_write_mem() prototype Michal Kazior
2013-04-30 11:13   ` [ath9k-devel] [PATCH v2 4/6] ath10k: drop unnecessary else branch Michal Kazior
2013-04-30 11:13   ` [ath9k-devel] [PATCH v2 5/6] " Michal Kazior
2013-04-30 11:13   ` [ath9k-devel] [PATCH v2 6/6] ath10k: cleanup ath10k_pci_stop_intr() Michal Kazior
2013-04-30 11:49   ` [ath9k-devel] [PATCH v2 0/6] ath10k: coding style cleanup Kalle Valo

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.