From: James Prestwood <prestwoj@gmail.com>
To: iwd@lists.linux.dev
Cc: James Prestwood <prestwoj@gmail.com>
Subject: [PATCH 2/7] util: add scan_freq_set_remove
Date: Tue, 13 Dec 2022 12:36:19 -0800 [thread overview]
Message-ID: <20221213203624.1423277-2-prestwoj@gmail.com> (raw)
In-Reply-To: <20221213203624.1423277-1-prestwoj@gmail.com>
Removes one frequency from a scan_freq_set object.
---
src/util.c | 22 ++++++++++++++++++++++
src/util.h | 1 +
2 files changed, 23 insertions(+)
diff --git a/src/util.c b/src/util.c
index d564ebc0..69019dc8 100644
--- a/src/util.c
+++ b/src/util.c
@@ -360,6 +360,28 @@ bool scan_freq_set_add(struct scan_freq_set *freqs, uint32_t freq)
return false;
}
+bool scan_freq_set_remove(struct scan_freq_set *freqs, uint32_t freq)
+{
+ enum band_freq band;
+ uint8_t channel;
+
+ channel = band_freq_to_channel(freq, &band);
+ if (!channel)
+ return false;
+
+ switch (band) {
+ case BAND_FREQ_2_4_GHZ:
+ freqs->channels_2ghz &= ~(1 << (channel - 1));
+ return true;
+ case BAND_FREQ_5_GHZ:
+ return l_uintset_take(freqs->channels_5ghz, channel);
+ case BAND_FREQ_6_GHZ:
+ return l_uintset_take(freqs->channels_6ghz, channel);
+ }
+
+ return false;
+}
+
bool scan_freq_set_contains(const struct scan_freq_set *freqs, uint32_t freq)
{
enum band_freq band;
diff --git a/src/util.h b/src/util.h
index cc45059f..dafa446d 100644
--- a/src/util.h
+++ b/src/util.h
@@ -111,6 +111,7 @@ typedef void (*scan_freq_set_func_t)(uint32_t freq, void *userdata);
struct scan_freq_set *scan_freq_set_new(void);
void scan_freq_set_free(struct scan_freq_set *freqs);
bool scan_freq_set_add(struct scan_freq_set *freqs, uint32_t freq);
+bool scan_freq_set_remove(struct scan_freq_set *freqs, uint32_t freq);
bool scan_freq_set_contains(const struct scan_freq_set *freqs, uint32_t freq);
uint32_t scan_freq_set_get_bands(const struct scan_freq_set *freqs);
void scan_freq_set_foreach(const struct scan_freq_set *freqs,
--
2.34.3
next prev parent reply other threads:[~2022-12-13 20:36 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-12-13 20:36 [PATCH 1/7] band: introduce new method of tracking frequencies James Prestwood
2022-12-13 20:36 ` James Prestwood [this message]
2022-12-14 21:37 ` [PATCH 2/7] util: add scan_freq_set_remove Denis Kenzior
2022-12-13 20:36 ` [PATCH 3/7] wiphy: parse/store frequency info in band object James Prestwood
2022-12-14 22:11 ` Denis Kenzior
2022-12-13 20:36 ` [PATCH 4/7] wiphy: add wiphy_check_{frequency,band} James Prestwood
2022-12-13 20:36 ` [PATCH 5/7] station: use wiphy_check_{frequency,band} James Prestwood
2022-12-13 20:36 ` [PATCH 6/7] ap: " James Prestwood
2022-12-13 20:36 ` [PATCH 7/7] wiphy: remove disabled_freqs and related dump code James Prestwood
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=20221213203624.1423277-2-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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).