All of lore.kernel.org
 help / color / mirror / Atom feed
From: James Prestwood <prestwoj@gmail.com>
To: iwd@lists.linux.dev
Cc: James Prestwood <prestwoj@gmail.com>
Subject: [PATCH v4 1/3] util: add scan_freq_set_copy_bands
Date: Thu,  4 Aug 2022 15:02:47 -0700	[thread overview]
Message-ID: <20220804220249.508207-1-prestwoj@gmail.com> (raw)

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


             reply	other threads:[~2022-08-04 22:02 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-08-04 22:02 James Prestwood [this message]
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

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20220804220249.508207-1-prestwoj@gmail.com \
    --to=prestwoj@gmail.com \
    --cc=iwd@lists.linux.dev \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.