All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v4 1/3] util: add scan_freq_set_copy_bands
@ 2022-08-04 22:02 James Prestwood
  2022-08-04 22:02 ` [PATCH v4 2/3] scan: split full scans by band to enable 6GHz James Prestwood
                   ` (2 more replies)
  0 siblings, 3 replies; 5+ messages in thread
From: James Prestwood @ 2022-08-04 22:02 UTC (permalink / raw)
  To: iwd; +Cc: James Prestwood

This creates a new scan_freq_set from an input set which only contains
frequencies from bands included in the mask.
---
 src/util.c | 21 +++++++++++++++++++++
 src/util.h |  2 ++
 2 files changed, 23 insertions(+)

diff --git a/src/util.c b/src/util.c
index ebaff6a0..64d85cbc 100644
--- a/src/util.c
+++ b/src/util.c
@@ -554,3 +554,24 @@ uint32_t *scan_freq_set_to_fixed_array(const struct scan_freq_set *set,
 
 	return freqs;
 }
+
+struct scan_freq_set *scan_freq_set_copy_bands(const struct scan_freq_set *set,
+						uint32_t band_mask)
+{
+	struct scan_freq_set *new = l_new(struct scan_freq_set, 1);
+
+	if (band_mask & BAND_FREQ_2_4_GHZ)
+		new->channels_2ghz = set->channels_2ghz;
+
+	if (band_mask & BAND_FREQ_5_GHZ)
+		new->channels_5ghz = l_uintset_clone(set->channels_5ghz);
+	else
+		new->channels_5ghz = l_uintset_new_from_range(1, 200);
+
+	if (band_mask & BAND_FREQ_6_GHZ)
+		new->channels_6ghz = l_uintset_clone(set->channels_6ghz);
+	else
+		new->channels_6ghz = l_uintset_new_from_range(1, 233);
+
+	return new;
+}
diff --git a/src/util.h b/src/util.h
index 0b7832fb..9d3ec604 100644
--- a/src/util.h
+++ b/src/util.h
@@ -123,5 +123,7 @@ void scan_freq_set_subtract(struct scan_freq_set *set,
 bool scan_freq_set_isempty(const struct scan_freq_set *set);
 uint32_t *scan_freq_set_to_fixed_array(const struct scan_freq_set *set,
 					size_t *len_out);
+struct scan_freq_set *scan_freq_set_copy_bands(const struct scan_freq_set *set,
+						uint32_t band_mask);
 
 #endif /* __UTIL_H */
-- 
2.34.3


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

end of thread, other threads:[~2022-08-05 17:21 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-08-04 22:02 [PATCH v4 1/3] util: add scan_freq_set_copy_bands James Prestwood
2022-08-04 22:02 ` [PATCH v4 2/3] scan: split full scans by band to enable 6GHz James Prestwood
2022-08-05 17:03   ` Denis Kenzior
2022-08-04 22:02 ` [PATCH v4 3/3] scan: watch for regdom updates " James Prestwood
2022-08-05 16:54 ` [PATCH v4 1/3] util: add scan_freq_set_copy_bands Denis Kenzior

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.