Skip to contentSkip to conversation

ath10k: coding style cleanup

PATCH Superseded Michal Kazior 2 participants 17 messages Apr 26, 2013 – Apr 30, 2013 Qualcomm Atheros ATH10K wireless driver

lore
Share & tools
lore
#0 lore raw

cover ath10k: coding style cleanup

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(-)
Signature · 1 line
1.7.9.5
#1 lore raw

PATCH 1/6 ath10k: fix code style and add comments to tx code

---
 drivers/net/wireless/ath/ath10k/htt_tx.c |    4 ++++
 drivers/net/wireless/ath/ath10k/txrx.c   |    4 +++-
 2 files changed, 7 insertions(+), 1 deletion(-)
drivers/net/wireless/ath/ath10k/htt_tx.c +4 -0
index 9f7ee9e..edbe4f4 100644
@@ -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;
drivers/net/wireless/ath/ath10k/txrx.c +3 -1
index ab5eb3b..dd51d38 100644
@@ -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) {
Signature · 1 line
1.7.9.5
#2 lore raw

PATCH 2/6 ath10k: tweak ath10k_pci_diag_read_mem() prototype

In reply to Michal Kazior

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

---
 drivers/net/wireless/ath/ath10k/pci.c |    9 ++++-----
 1 file changed, 4 insertions(+), 5 deletions(-)
drivers/net/wireless/ath/ath10k/pci.c +4 -5
index e7874b2..278db71 100644
@@ -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;
Signature · 1 line
1.7.9.5
#3 lore raw

PATCH 3/6 ath10k: tweak ath10k_pci_diag_write_mem() prototype

In reply to Michal Kazior

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.

---
 drivers/net/wireless/ath/ath10k/pci.c |   14 +++++++-------
 1 file changed, 7 insertions(+), 7 deletions(-)
drivers/net/wireless/ath/ath10k/pci.c +7 -7
index 278db71..ddef94e 100644
@@ -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);
Signature · 1 line
1.7.9.5
#4 lore raw

PATCH 4/6 ath10k: drop unnecessary else branch

In reply to Michal Kazior
---
 drivers/net/wireless/ath/ath10k/pci.c |   26 +++++++++++---------------
 1 file changed, 11 insertions(+), 15 deletions(-)
drivers/net/wireless/ath/ath10k/pci.c +11 -15
index ddef94e..c3c91a0 100644
@@ -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)
Signature · 1 line
1.7.9.5
#5 lore raw

PATCH 5/6 ath10k: drop unnecessary else branch

In reply to Michal Kazior

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

---
 drivers/net/wireless/ath/ath10k/pci.c |    5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)
drivers/net/wireless/ath/ath10k/pci.c +2 -3
index c3c91a0..d521270 100644
@@ -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 = {
Signature · 1 line
1.7.9.5
#6 lore raw

PATCH 6/6 ath10k: cleanup ath10k_pci_stop_intr()

In reply to Michal Kazior
---
 drivers/net/wireless/ath/ath10k/pci.c |   16 +++++++---------
 1 file changed, 7 insertions(+), 9 deletions(-)
drivers/net/wireless/ath/ath10k/pci.c +7 -9
index d521270..31881f9 100644
@@ -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)
Signature · 1 line
1.7.9.5
#7 lore raw

PATCH v2 6/6 ath10k: cleanup ath10k_pci_stop_intr()

Quoted 1 line · Michal Kazior

[...]

drivers/net/wireless/ath/ath10k/pci.c exit: · line 1946

Quoted 4 lines
drivers/net/wireless/ath/ath10k/pci.c +4 -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);

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

Signature · 1 line
Kalle Valo
#8 lore raw

PATCH 6/6 ath10k: cleanup ath10k_pci_stop_intr()

Quoted 6 lines · Kalle Valo
Quoted 1 line · Michal Kazior

[...]

Quoted 7 lines

drivers/net/wireless/ath/ath10k/pci.c exit: · line 1946

Quoted 4 lines
drivers/net/wireless/ath/ath10k/pci.c +4 -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);

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.

#9 lore raw

v2 cover ath10k: coding style cleanup

In reply to Michal Kazior

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(-)
Signature · 1 line
1.7.9.5
#10 lore raw

PATCH v2 1/6 ath10k: fix code style and add comments to tx code

---
 drivers/net/wireless/ath/ath10k/htt_tx.c |    4 ++++
 drivers/net/wireless/ath/ath10k/txrx.c   |    4 +++-
 2 files changed, 7 insertions(+), 1 deletion(-)
drivers/net/wireless/ath/ath10k/htt_tx.c +4 -0
index 9f7ee9e..edbe4f4 100644
@@ -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;
drivers/net/wireless/ath/ath10k/txrx.c +3 -1
index a54ad8f..9d0b1e2 100644
@@ -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) {
Signature · 1 line
1.7.9.5
#11 lore raw

PATCH v2 2/6 ath10k: tweak ath10k_pci_diag_read_mem() prototype

In reply to Michal Kazior

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

---
 drivers/net/wireless/ath/ath10k/pci.c |    9 ++++-----
 1 file changed, 4 insertions(+), 5 deletions(-)
drivers/net/wireless/ath/ath10k/pci.c +4 -5
index e7874b2..278db71 100644
@@ -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;
Signature · 1 line
1.7.9.5
#12 lore raw

PATCH v2 3/6 ath10k: tweak ath10k_pci_diag_write_mem() prototype

In reply to Michal Kazior

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.

---
 drivers/net/wireless/ath/ath10k/pci.c |   14 +++++++-------
 1 file changed, 7 insertions(+), 7 deletions(-)
drivers/net/wireless/ath/ath10k/pci.c +7 -7
index 278db71..ddef94e 100644
@@ -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);
Signature · 1 line
1.7.9.5
#13 lore raw

PATCH v2 4/6 ath10k: drop unnecessary else branch

In reply to Michal Kazior
---
 drivers/net/wireless/ath/ath10k/pci.c |   26 +++++++++++---------------
 1 file changed, 11 insertions(+), 15 deletions(-)
drivers/net/wireless/ath/ath10k/pci.c +11 -15
index ddef94e..c3c91a0 100644
@@ -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)
Signature · 1 line
1.7.9.5
#14 lore raw

PATCH v2 5/6 ath10k: drop unnecessary else branch

In reply to Michal Kazior

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

---
 drivers/net/wireless/ath/ath10k/pci.c |    5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)
drivers/net/wireless/ath/ath10k/pci.c +2 -3
index c3c91a0..d521270 100644
@@ -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 = {
Signature · 1 line
1.7.9.5
#15 lore raw

PATCH v2 6/6 ath10k: cleanup ath10k_pci_stop_intr()

In reply to Michal Kazior

---
v2: fix loop by using max()

 drivers/net/wireless/ath/ath10k/pci.c |   16 +++++++---------
 1 file changed, 7 insertions(+), 9 deletions(-)
drivers/net/wireless/ath/ath10k/pci.c +7 -9
index d521270..9965506 100644
@@ -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)
Signature · 1 line
1.7.9.5
#16 lore raw

v2 cover ath10k: coding style cleanup

In reply to Michal Kazior
Quoted 9 lines · Michal Kazior

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.

Signature · 1 line
Kalle Valo