All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/4] ath11k: Avoid use of struct initializers for runtime assignment
@ 2019-06-22  0:17 Sriram R
  2019-06-22  0:17 ` [PATCH 2/4] ath11k: modify code styling for boolean function return values Sriram R
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: Sriram R @ 2019-06-22  0:17 UTC (permalink / raw)
  To: ath11k; +Cc: Sriram R

Cleanup the use of REG_RULE struct initializer macro for updating or
addinig reg rules at runtime. Rather make use of a separate function
to update reg rules while building new regd data.

Signed-off-by: Sriram R <srirrama@codeaurora.org>
---
 drivers/net/wireless/ath/ath11k/reg.c | 64 +++++++++++++++++++----------------
 1 file changed, 34 insertions(+), 30 deletions(-)

diff --git a/drivers/net/wireless/ath/ath11k/reg.c b/drivers/net/wireless/ath/ath11k/reg.c
index cc847a7..f181061 100644
--- a/drivers/net/wireless/ath/ath11k/reg.c
+++ b/drivers/net/wireless/ath/ath11k/reg.c
@@ -468,6 +468,19 @@ ath11k_reg_adjust_bw(u16 start_freq, u16 end_freq, u16 max_bw)
 }
 
 static void
+ath11k_reg_update_rule(struct ieee80211_reg_rule *reg_rule, u32 start_freq,
+		       u32 end_freq, u32 bw, u32 ant_gain, u32 reg_pwr,
+		       u32 reg_flags)
+{
+	reg_rule->freq_range.start_freq_khz = MHZ_TO_KHZ(start_freq);
+	reg_rule->freq_range.end_freq_khz = MHZ_TO_KHZ(end_freq);
+	reg_rule->freq_range.max_bandwidth_khz = MHZ_TO_KHZ(bw);
+	reg_rule->power_rule.max_antenna_gain = DBI_TO_MBI(ant_gain);
+	reg_rule->power_rule.max_eirp = DBM_TO_MBM(reg_pwr);
+	reg_rule->flags = reg_flags;
+}
+
+static void
 ath11k_reg_update_weather_radar_band(struct ath11k_base *ab,
 				     struct ieee80211_regdomain *regd,
 				     struct cur_reg_rule *reg_rule,
@@ -482,13 +495,10 @@ ath11k_reg_update_weather_radar_band(struct ath11k_base *ab,
 	bw = ath11k_reg_adjust_bw(reg_rule->start_freq,
 				  ETSI_WEATHER_RADAR_BAND_LOW, max_bw);
 
-	regd->reg_rules[i] = (struct ieee80211_reg_rule)
-				REG_RULE(reg_rule->start_freq,
-					 ETSI_WEATHER_RADAR_BAND_LOW,
-					 bw,
-					 reg_rule->ant_gain,
-					 reg_rule->reg_power,
-					 flags);
+	ath11k_reg_update_rule(regd->reg_rules + i, reg_rule->start_freq,
+			       ETSI_WEATHER_RADAR_BAND_LOW, bw,
+			       reg_rule->ant_gain, reg_rule->reg_power,
+			       flags);
 
 	ath11k_dbg(ab, ATH11K_DBG_REG,
 		   "\t%d. (%d - %d @ %d) (%d, %d) (%d ms) (FLAGS %d)\n",
@@ -505,13 +515,12 @@ ath11k_reg_update_weather_radar_band(struct ath11k_base *ab,
 	bw = ath11k_reg_adjust_bw(ETSI_WEATHER_RADAR_BAND_LOW, end_freq,
 				  max_bw);
 
-	regd->reg_rules[++i] = (struct ieee80211_reg_rule)
-					REG_RULE(ETSI_WEATHER_RADAR_BAND_LOW,
-						 end_freq,
-						 bw,
-						 reg_rule->ant_gain,
-						 reg_rule->reg_power,
-						 flags);
+	i++;
+
+	ath11k_reg_update_rule(regd->reg_rules + i,
+			       ETSI_WEATHER_RADAR_BAND_LOW, end_freq, bw,
+			       reg_rule->ant_gain, reg_rule->reg_power,
+			       flags);
 
 	regd->reg_rules[i].dfs_cac_ms = ETSI_WEATHER_RADAR_BAND_CAC_TIMEOUT;
 
@@ -531,14 +540,12 @@ ath11k_reg_update_weather_radar_band(struct ath11k_base *ab,
 	bw = ath11k_reg_adjust_bw(ETSI_WEATHER_RADAR_BAND_HIGH,
 				  reg_rule->end_freq, max_bw);
 
-	regd->reg_rules[++i] =
-			(struct ieee80211_reg_rule)
-				REG_RULE(ETSI_WEATHER_RADAR_BAND_HIGH,
-					 reg_rule->end_freq,
-					 bw,
-					 reg_rule->ant_gain,
-					 reg_rule->reg_power,
-					 flags);
+	i++;
+
+	ath11k_reg_update_rule(regd->reg_rules + i, ETSI_WEATHER_RADAR_BAND_HIGH,
+			       reg_rule->end_freq, bw,
+			       reg_rule->ant_gain, reg_rule->reg_power,
+			       flags);
 
 	ath11k_dbg(ab, ATH11K_DBG_REG,
 		   "\t%d. (%d - %d @ %d) (%d, %d) (%d ms) (FLAGS %d)\n",
@@ -616,14 +623,11 @@ ath11k_reg_build_regd(struct ath11k_base *ab,
 
 		flags |= ath11k_map_fw_reg_flags(reg_rule->flags);
 
-		tmp_regd->reg_rules[i] =
-				(struct ieee80211_reg_rule)
-					REG_RULE(reg_rule->start_freq,
-						 reg_rule->end_freq,
-						 max_bw,
-						 reg_rule->ant_gain,
-						 reg_rule->reg_power,
-						 flags);
+		ath11k_reg_update_rule(tmp_regd->reg_rules + i,
+				       reg_rule->start_freq,
+				       reg_rule->end_freq, max_bw,
+				       reg_rule->ant_gain, reg_rule->reg_power,
+				       flags);
 
 		/* Update dfs cac timeout if the dfs domain is ETSI and the
 		 * new rule covers weather radar band.
-- 
2.7.4


_______________________________________________
ath11k mailing list
ath11k@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/ath11k

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

end of thread, other threads:[~2019-06-24 10:51 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2019-06-22  0:17 [PATCH 1/4] ath11k: Avoid use of struct initializers for runtime assignment Sriram R
2019-06-22  0:17 ` [PATCH 2/4] ath11k: modify code styling for boolean function return values Sriram R
2019-06-22  0:17 ` [PATCH 3/4] ath11k: replace locally defined MACRO's with actual functions Sriram R
2019-06-22  0:17 ` [PATCH 4/4] ath11k: Remove stray character in reg notifier debug log Sriram R
2019-06-24 10:51 ` [PATCH 1/4] ath11k: Avoid use of struct initializers for runtime assignment 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.