Skip to contentSkip to conversation

ath10k: making static variables const

PATCH New Kalle Valo 2 participants 9 messages Apr 24, 2013 Qualcomm Atheros ATH10K wireless driver

lore
Share & tools
lore

Kalle Valo

author
#0 lore raw

cover ath10k: making static variables const

Did some review of static variables and noticed that we had quite a few variables which were not const.

Please review carefully, I might have missed something.

---

Kalle Valo (5):
ath10k: make rx_legacy_rate_idx variable const
ath10k: make host_ce_config_wlan static variable const
ath10k: make target_ce_config_wlan and target_service_to_ce_map_wlan const
ath10k: make iee80211 iface combination structures static
ath10k: copy ieee80211_supported_band for each instance

 drivers/net/wireless/ath/ath10k/ce.c   |    8 ++--
 drivers/net/wireless/ath/ath10k/ce.h   |    2 -
 drivers/net/wireless/ath/ath10k/core.h |    4 ++
 drivers/net/wireless/ath/ath10k/mac.c  |   67 ++++++++++++++++++++------------
 drivers/net/wireless/ath/ath10k/pci.c  |   12 +++---
 drivers/net/wireless/ath/ath10k/txrx.c |    2 -
 6 files changed, 57 insertions(+), 38 deletions(-)
author
#1 lore raw

PATCH 1/5 ath10k: make rx_legacy_rate_idx variable const

It's not modified in any way.

---
 drivers/net/wireless/ath/ath10k/txrx.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/wireless/ath/ath10k/txrx.c +1 -1
index 6a66dc2..239eff5 100644
@@ -120,7 +120,7 @@ void ath10k_txrx_tx_completed(struct htt_struct *htt,
 	ath10k_txrx_tx_unref(htt, txdesc);
 }
 
-static u8 rx_legacy_rate_idx[] = {
+static const u8 rx_legacy_rate_idx[] = {
 	3,	/* 0x00  - 11Mbps  */
 	2,	/* 0x01  - 5.5Mbps */
 	1,	/* 0x02  - 2Mbps   */
author
#2 lore raw

PATCH 2/5 ath10k: make host_ce_config_wlan static variable const

In reply to Kalle Valo

Nothing modifies it.

---
 drivers/net/wireless/ath/ath10k/ce.c  |    8 ++++----
 drivers/net/wireless/ath/ath10k/ce.h  |    2 +-
 drivers/net/wireless/ath/ath10k/pci.c |    8 ++++----
 3 files changed, 9 insertions(+), 9 deletions(-)
drivers/net/wireless/ath/ath10k/ce.c +4 -4
index d5351a3..d3aa515 100644
@@ -703,7 +703,7 @@ void ath10k_ce_recv_cb_register(struct ce_state *ce_state,
 static int ath10k_ce_init_src_ring(struct ath10k *ar,
 				   unsigned int ce_id,
 				   struct ce_state *ce_state,
-				   struct ce_attr *attr)
+				   const struct ce_attr *attr)
 {
 	struct ath10k_pci *ar_pci = ath10k_pci_priv(ar);
 	struct ce_ring_state *src_ring;
@@ -795,7 +795,7 @@ static int ath10k_ce_init_src_ring(struct ath10k *ar,
 static int ath10k_ce_init_dest_ring(struct ath10k *ar,
 				    unsigned int ce_id,
 				    struct ce_state *ce_state,
-				    struct ce_attr *attr)
+				    const struct ce_attr *attr)
 {
 	struct ath10k_pci *ar_pci = ath10k_pci_priv(ar);
 	struct ce_ring_state *dest_ring;
@@ -877,7 +877,7 @@ static int ath10k_ce_init_dest_ring(struct ath10k *ar,
 
 static struct ce_state *ath10k_ce_init_state(struct ath10k *ar,
 				      unsigned int ce_id,
-				      struct ce_attr *attr)
+				      const struct ce_attr *attr)
 {
 	struct ath10k_pci *ar_pci = ath10k_pci_priv(ar);
 	struct ce_state *ce_state = NULL;
@@ -916,7 +916,7 @@ static struct ce_state *ath10k_ce_init_state(struct ath10k *ar,
  */
 struct ce_state *ath10k_ce_init(struct ath10k *ar,
 				unsigned int ce_id,
-				struct ce_attr *attr)
+				const struct ce_attr *attr)
 {
 	struct ath10k_pci *ar_pci = ath10k_pci_priv(ar);
 	struct ce_state *ce_state;
drivers/net/wireless/ath/ath10k/ce.h +1 -1
index 084b997..01879eb 100644
@@ -275,7 +275,7 @@ int ath10k_ce_completed_send_next(struct ce_state *ce_state,
 /* Initialize an instance of a CE */
 struct ce_state *ath10k_ce_init(struct ath10k *ar,
 				unsigned int ce_id,
-				struct ce_attr *attr);
+				const struct ce_attr *attr);
 
 /*==================CE Engine Shutdown=======================*/
 /*
drivers/net/wireless/ath/ath10k/pci.c +4 -4
index 0d1523b..22a5451 100644
@@ -52,7 +52,7 @@ static int ath10k_pci_post_recv_buffers(struct ath10k *ar);
 static int ath10k_pci_post_recv_buffers_pipe(struct hif_ce_pipe_info *pipe_info,
 					     int num);
 
-static struct ce_attr host_ce_config_wlan[] = {
+static const struct ce_attr host_ce_config_wlan[] = {
 	/* host->target HTC control and raw streams */
 	{ /* CE0 */ CE_ATTR_FLAGS, 0, 16, 256, 0, NULL,},
 	/* could be moved to share CE3 */
@@ -770,7 +770,7 @@ static void ath10k_pci_start_ce(struct ath10k *ar)
 {
 	struct ath10k_pci *ar_pci = ath10k_pci_priv(ar);
 	struct ce_state *ce_diag = ar_pci->ce_diag;
-	struct ce_attr *attr;
+	const struct ce_attr *attr;
 	struct hif_ce_pipe_info *pipe_info;
 	struct hif_ce_completion_state *compl;
 	int i, pipe_num, completions;
@@ -1075,7 +1075,7 @@ static int ath10k_pci_post_recv_buffers(struct ath10k *ar)
 {
 	struct ath10k_pci *ar_pci = ath10k_pci_priv(ar);
 	struct hif_ce_pipe_info *pipe_info;
-	struct ce_attr *attr;
+	const struct ce_attr *attr;
 	int pipe_num, ret = 0;
 
 	for (pipe_num = 0; pipe_num < ar_pci->ce_count; pipe_num++) {
@@ -1622,7 +1622,7 @@ static void ath10k_pci_ce_init(struct ath10k *ar)
 {
 	struct ath10k_pci *ar_pci = ath10k_pci_priv(ar);
 	struct hif_ce_pipe_info *pipe_info;
-	struct ce_attr *attr;
+	const struct ce_attr *attr;
 	int pipe_num;
 
 	for (pipe_num = 0; pipe_num < ar_pci->ce_count; pipe_num++) {
author
#3 lore raw

PATCH 3/5 ath10k: make target_ce_config_wlan and target_service_to_ce_map_wlan const

In reply to Kalle Valo

Nothing modifies them.

---
 drivers/net/wireless/ath/ath10k/pci.c |    4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/net/wireless/ath/ath10k/pci.c +2 -2
index 22a5451..7a35234 100644
@@ -74,7 +74,7 @@ static const struct ce_attr host_ce_config_wlan[] = {
 };
 
 /* Target firmware's Copy Engine configuration. */
-static struct ce_pipe_config target_ce_config_wlan[] = {
+static const struct ce_pipe_config target_ce_config_wlan[] = {
 	/* host->target HTC control and raw streams */
 	{ /* CE0 */ 0, PIPEDIR_OUT, 32, 256, CE_ATTR_FLAGS, 0,},
 	/* target->host HTT + HTC control */
@@ -1358,7 +1358,7 @@ static void ath10k_pci_bmi_recv_data(struct ce_state *ce_state,
  * This table is derived from the CE_PCI TABLE, above.
  * It is passed to the Target at startup for use by firmware.
  */
-static struct service_to_pipe target_service_to_ce_map_wlan[] = {
+static const struct service_to_pipe target_service_to_ce_map_wlan[] = {
 	{
 		 ATH10K_HTC_SVC_ID_WMI_DATA_VO,
 		 PIPEDIR_OUT,		/* out = UL = host -> target */
author
#4 lore raw

PATCH 4/5 ath10k: make iee80211 iface combination structures static

In reply to Kalle Valo

Nothing modifies them.

---
 drivers/net/wireless/ath/ath10k/mac.c |    4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/net/wireless/ath/ath10k/mac.c +2 -2
index 60855fb..8f58dda 100644
@@ -2531,7 +2531,7 @@ void ath10k_mac_destroy(struct ath10k *ar)
 	ieee80211_free_hw(ar->hw);
 }
 
-static struct ieee80211_iface_limit ath10k_if_limits[] = {
+static const struct ieee80211_iface_limit ath10k_if_limits[] = {
 	{
 	.max	= 8,
 	.types	= BIT(NL80211_IFTYPE_STATION)
@@ -2541,7 +2541,7 @@ static struct ieee80211_iface_limit ath10k_if_limits[] = {
 	}
 };
 
-static struct ieee80211_iface_combination ath10k_if_comb = {
+static const struct ieee80211_iface_combination ath10k_if_comb = {
 	.limits = ath10k_if_limits,
 	.n_limits = ARRAY_SIZE(ath10k_if_limits),
 	.max_interfaces = 8,
#5 lore raw

PATCH 4/5 ath10k: make iee80211 iface combination structures static

Quoted 1 line · Kalle Valo

Nothing modifies them.

I think the title should be s/static/const/

-- Pozdrawiam / Best regards, Michal Kazior.

author
#6 lore raw

PATCH 4/5 ath10k: make iee80211 iface combination structures static

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

Nothing modifies them.

I think the title should be s/static/const/

Yup, I fixed that in my branch.

Thanks for review.

Signature · 1 line
Kalle Valo
author
#7 lore raw

PATCH 5/5 ath10k: copy ieee80211_supported_band for each instance

In reply to Kalle Valo

If we run multiple instances of ath10k the supported band structures were shared with all instances. This is wrong and would cause corruption. Fix it by making a private copy for each instance.

I didn't copy the rate structure ath10k_rates as ath9k also doesn't copy it. Most likely nothing modifies that structure, but that needs to be verified.

---
 drivers/net/wireless/ath/ath10k/core.h |    4 ++
 drivers/net/wireless/ath/ath10k/mac.c  |   63 ++++++++++++++++++++------------
 2 files changed, 43 insertions(+), 24 deletions(-)
drivers/net/wireless/ath/ath10k/core.h +4 -0
index 42d9e72..c50ef59 100644
@@ -322,6 +322,10 @@ struct ath10k {
 		int vdev_id;
 	} scan;
 
+	struct {
+		struct ieee80211_supported_band sbands[IEEE80211_NUM_BANDS];
+	} mac;
+
 	/* should never be NULL; needed for regular htt rx */
 	struct ieee80211_channel __rcu *rx_channel;
 
drivers/net/wireless/ath/ath10k/mac.c +39 -24

101 lines not on this page · raw message

author Applied
#8 lore raw

cover ath10k: making static variables const

In reply to Kalle Valo
Quoted 5 lines · Kalle Valo

Did some review of static variables and noticed that we had quite a few variables which were not const.

Please review carefully, I might have missed something.

Quoted 8 lines

---

Kalle Valo (5):
ath10k: make rx_legacy_rate_idx variable const
ath10k: make host_ce_config_wlan static variable const
ath10k: make target_ce_config_wlan and target_service_to_ce_map_wlan const
ath10k: make iee80211 iface combination structures static
ath10k: copy ieee80211_supported_band for each instance

Applied.

Signature · 1 line
Kalle Valo