Skip to contentSkip to conversation

ath10k: non-functional cleanups

PATCH New Michal Kazior 2 participants 9 messages Apr 18, 2013 Qualcomm Atheros ATH10K wireless driver

lore
Share & tools
lore
#0 lore raw

cover ath10k: non-functional cleanups

Michal Kazior (7):
ath10k: fix code style
ath10k: use if() instead of ternary operator
ath10k: remove unnecessary void cast
ath10k: kill WARN_ONs in htt_rx.c
ath10k: use macros instead of if() for value range limiting
ath10k: use ath10k_warn() instead of WARN()
ath10k: remove old function prototype

 drivers/net/wireless/ath/ath10k/bmi.c    |   18 +++++++++---------
 drivers/net/wireless/ath/ath10k/core.h   |    1 -
 drivers/net/wireless/ath/ath10k/htc.c    |    9 +++++----
 drivers/net/wireless/ath/ath10k/htt_rx.c |   21 ++++++++++++++-------
 drivers/net/wireless/ath/ath10k/mac.c    |   10 ++++------
 drivers/net/wireless/ath/ath10k/wmi.c    |    3 ++-
 6 files changed, 34 insertions(+), 28 deletions(-)
Signature · 1 line
1.7.9.5
#1 lore raw

PATCH 1/7 ath10k: fix code style

This fixes funky error handling.

---
 drivers/net/wireless/ath/ath10k/bmi.c |   18 +++++++++---------
 1 file changed, 9 insertions(+), 9 deletions(-)
drivers/net/wireless/ath/ath10k/bmi.c +9 -9
index b0149b7..0b3b509 100644
@@ -282,14 +282,14 @@ int ath10k_bmi_fast_download(struct ath10k *ar,
 	if (unaligned_bytes)
 		ret = ath10k_bmi_lz_data(ar, &last_work, 4);
 
-	if (ret == 0) {
-		/*
-		 * Close compressed stream and open a new (fake) one.
-		 * This serves mainly to flush Target caches.
-		 */
-		ret = ath10k_bmi_lz_stream_start(ar, 0x00);
-		if (ret)
-			return ret;
-	}
+	if (ret != 0)
+		return ret;
+
+	/*
+	 * Close compressed stream and open a new (fake) one.
+	 * This serves mainly to flush Target caches.
+	 */
+	ret = ath10k_bmi_lz_stream_start(ar, 0x00);
+
 	return ret;
 }
Signature · 1 line
1.7.9.5
#2 lore raw

PATCH 2/7 ath10k: use if() instead of ternary operator

In reply to Michal Kazior

Improves readability.

---
 drivers/net/wireless/ath/ath10k/htc.c |    7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)
drivers/net/wireless/ath/ath10k/htc.c +4 -3
index 89b9dab..854d728 100644
@@ -149,9 +149,10 @@ static int ath10k_htc_prepare_tx_skb(struct htc_endpoint *ep,
 
 	spin_lock_bh(&ep->target->htc_tx_lock);
 	hdr->seq_no = ep->seq_no++;
-	hdr->flags |= ath10k_htc_ep_need_credit_update(ep)
-			? HTC_FLAG_NEED_CREDIT_UPDATE
-			: 0;
+
+	if (ath10k_htc_ep_need_credit_update(ep))
+		hdr->flags |= HTC_FLAG_NEED_CREDIT_UPDATE;
+
 	spin_unlock_bh(&ep->target->htc_tx_lock);
 
 	return 0;
Signature · 1 line
1.7.9.5
#3 lore raw

PATCH 3/7 ath10k: remove unnecessary void cast

In reply to Michal Kazior
---
 drivers/net/wireless/ath/ath10k/htc.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/wireless/ath/ath10k/htc.c +1 -1
index 854d728..b51f554 100644
@@ -279,7 +279,7 @@ static struct sk_buff *ath10k_htc_get_skb(struct htc_target *target,
 
 static void ath10k_htc_send_work(struct work_struct *work)
 {
-	struct htc_endpoint *ep = container_of((void *)work,
+	struct htc_endpoint *ep = container_of(work,
 					struct htc_endpoint, send_work);
 	struct htc_target *target = ep->target;
 	struct sk_buff *skb;
Signature · 1 line
1.7.9.5
#4 lore raw

PATCH 4/7 ath10k: kill WARN_ONs in htt_rx.c

In reply to Michal Kazior

We should not use WARN_ON in this place as it may
spam the kernel logs easily. Instead use simple
prints.

---
 drivers/net/wireless/ath/ath10k/htt_rx.c |   21 ++++++++++++++-------
 1 file changed, 14 insertions(+), 7 deletions(-)
drivers/net/wireless/ath/ath10k/htt_rx.c +14 -7
index 6fe273d..7c90a2c 100644
@@ -219,7 +219,7 @@ static inline struct sk_buff *ath10k_htt_rx_netbuf_pop(struct htt_struct *htt)
 	spin_lock_bh(&htt->rx_ring.lock);
 
 	if (ath10k_htt_rx_ring_elems(htt) == 0)
-		WARN_ON(1);
+		ath10k_warn("htt rx ring is empty!\n");
 
 	idx = htt->rx_ring.sw_rd_idx.msdu_payld;
 	msdu = htt->rx_ring.buf.netbufs_ring[idx];
@@ -243,7 +243,7 @@ static int ath10k_htt_rx_amsdu_pop(struct htt_struct *htt,
 	struct htt_rx_desc *rx_desc;
 
 	if (ath10k_htt_rx_ring_elems(htt) == 0)
-		WARN_ON(1);
+		ath10k_warn("htt rx ring is empty!\n");
 
 	if (htt->rx_confused) {
 		ath10k_warn("%s: htt failure: cannot rx\n", __func__);
@@ -277,11 +277,12 @@ static int ath10k_htt_rx_amsdu_pop(struct htt_struct *htt,
 		 * To prevent the case that we handle a stale Rx descriptor,
 		 * just assert for now until we have a way to recover.
 		 */
-		if (WARN_ON(!(__le32_to_cpu(rx_desc->attention.flags)
-				& RX_ATTENTION_FLAGS_MSDU_DONE))) {
+		if (!(__le32_to_cpu(rx_desc->attention.flags)
+				& RX_ATTENTION_FLAGS_MSDU_DONE)) {
 			if (*head_msdu == msdu)
 				*head_msdu = NULL;
 			dev_kfree_skb_any(msdu);
+			ath10k_err("htt rx stopped. cannot recover\n");
 			htt->rx_confused = true;
 			break;
 		}
@@ -405,7 +406,11 @@ int ath10k_htt_rx_attach(struct htt_struct *htt)
 	struct timer_list *timer = &htt->rx_ring.refill_retry_timer;
 
 	htt->rx_ring.size = ath10k_htt_rx_ring_size(htt);
-	WARN_ON(!is_power_of_2(htt->rx_ring.size));
+	if (!is_power_of_2(htt->rx_ring.size)) {
+		ath10k_warn("htt rx ring size is not power of 2\n");
+		return -EINVAL;
+	}
+
 	htt->rx_ring.size_mask = htt->rx_ring.size - 1;
 
 	/*
@@ -928,7 +933,8 @@ more:
 	/* remove crypto trailer; we use rx desc for mic failure */
 	trim += ath10k_htt_rx_crypto_tail_len(info.encrypt_type);
 
-	if (WARN_ON(trim > info.skb->len)) {
+	if (trim > info.skb->len) {
+		ath10k_warn("htt rx fragment: trailer longer than the frame itself? drop\n");
 		dev_kfree_skb_any(info.skb);
 		goto end;
 	}
@@ -953,7 +959,8 @@ void ath10k_htt_t2h_msg_handler(void *context, struct sk_buff *skb)
 	struct htt_resp *resp = (struct htt_resp *)skb->data;
 
 	/* confirm alignment */
-	WARN_ON_ONCE((((unsigned long)skb->data) & 0x3) != 0);
+	if ((((unsigned long)skb->data) & 0x3) != 0)
+		ath10k_warn("unaligned htt message, expect trouble\n");
 
 	ath10k_dbg(ATH10K_DBG_HTT, "HTT RX, msg_type: 0x%0X\n", resp->hdr.msg_type);
 	switch (resp->hdr.msg_type) {
Signature · 1 line
1.7.9.5
#5 lore raw

PATCH 5/7 ath10k: use macros instead of if() for value range limiting

In reply to Michal Kazior
---
 drivers/net/wireless/ath/ath10k/mac.c |   10 ++++------
 1 file changed, 4 insertions(+), 6 deletions(-)
drivers/net/wireless/ath/ath10k/mac.c +4 -6
index 1c9c048..3499858 100644
@@ -2296,8 +2296,7 @@ static void ath10k_set_rts_iter(void *data, u8 *mac, struct ieee80211_vif *vif)
 	struct ath10k_vif *arvif = ath10k_vif_to_arvif(vif);
 	u32 rts = ar_iter->ar->hw->wiphy->rts_threshold;
 
-	if (rts > ATH10K_RTS_MAX)
-		rts = ATH10K_RTS_MAX;
+	rts = min_t(u32, rts, ATH10K_RTS_MAX);
 
 	ar_iter->ret = ath10k_wmi_vdev_set_param(ar_iter->ar, arvif->vdev_id,
 						 WMI_VDEV_PARAM_RTS_THRESHOLD,
@@ -2333,10 +2332,9 @@ static void ath10k_set_frag_iter(void *data, u8 *mac, struct ieee80211_vif *vif)
 	struct ath10k_vif *arvif = ath10k_vif_to_arvif(vif);
 	u32 frag = ar_iter->ar->hw->wiphy->frag_threshold;
 
-	if (frag > ATH10K_FRAGMT_THRESHOLD_MAX)
-		frag = ATH10K_FRAGMT_THRESHOLD_MAX;
-	else if (frag < ATH10K_FRAGMT_THRESHOLD_MIN)
-		frag = ATH10K_FRAGMT_THRESHOLD_MIN;
+	frag = clamp_t(u32, frag,
+		       ATH10K_FRAGMT_THRESHOLD_MIN,
+		       ATH10K_FRAGMT_THRESHOLD_MAX);
 
 	ar_iter->ret = ath10k_wmi_vdev_set_param(ar_iter->ar, arvif->vdev_id,
 						 WMI_VDEV_PARAM_FRAGMENTATION_THRESHOLD,
Signature · 1 line
1.7.9.5
#6 lore raw

PATCH 6/7 ath10k: use ath10k_warn() instead of WARN()

In reply to Michal Kazior

Avoid spamming kernel logs.

---
 drivers/net/wireless/ath/ath10k/wmi.c |    3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/net/wireless/ath/ath10k/wmi.c +2 -1
index ae30be3..d19d2cc 100644
@@ -36,7 +36,8 @@ void ath10k_wmi_flush_tx(struct ath10k *ar)
 	if (ret == 0)
 		ret = -ETIMEDOUT;
 
-	WARN(ret < 0, "%s failed %d\n", __func__, ret);
+	if (ret < 0)
+		ath10k_warn("wmi flush failed (%d)\n", ret);
 }
 
 int ath10k_wmi_wait_for_service_ready(struct ath10k *ar)
Signature · 1 line
1.7.9.5
#7 lore raw

PATCH 7/7 ath10k: remove old function prototype

In reply to Michal Kazior
---
 drivers/net/wireless/ath/ath10k/core.h |    1 -
 1 file changed, 1 deletion(-)
drivers/net/wireless/ath/ath10k/core.h +0 -1
index e689212..de47b41 100644
@@ -386,5 +386,4 @@ void ath10k_core_destroy(struct ath10k *ar);
 int ath10k_core_register(struct ath10k *ar);
 void ath10k_core_unregister(struct ath10k *ar);
 
-void ath10k_remain_on_channel_reset(unsigned long ptr);
 #endif /* _CORE_H_ */
Signature · 1 line
1.7.9.5
#8 lore raw

cover ath10k: non-functional cleanups

In reply to Michal Kazior
Quoted 8 lines · Michal Kazior

Michal Kazior (7):
ath10k: fix code style
ath10k: use if() instead of ternary operator
ath10k: remove unnecessary void cast
ath10k: kill WARN_ONs in htt_rx.c
ath10k: use macros instead of if() for value range limiting
ath10k: use ath10k_warn() instead of WARN()
ath10k: remove old function prototype

Thanks, all seven applied.

Signature · 1 line
Kalle Valo