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 07/10] util: add scan_freq_set_subtract
Date: Tue, 26 Jul 2022 10:09:17 -0700	[thread overview]
Message-ID: <20220726170920.15929-7-prestwoj@gmail.com> (raw)
In-Reply-To: <20220726170920.15929-1-prestwoj@gmail.com>

Removes any frequencies from one set that are found in the other.
---
 src/util.c | 22 ++++++++++++++++++++++
 src/util.h |  2 ++
 2 files changed, 24 insertions(+)

diff --git a/src/util.c b/src/util.c
index 3c6e2b1b..ebaff6a0 100644
--- a/src/util.c
+++ b/src/util.c
@@ -499,6 +499,28 @@ void scan_freq_set_constrain(struct scan_freq_set *set,
 	set->channels_2ghz &= constraint->channels_2ghz;
 }
 
+void scan_freq_set_subtract(struct scan_freq_set *set,
+					const struct scan_freq_set *subtract)
+{
+	struct l_uintset *sub;
+
+	sub = l_uintset_subtract(set->channels_6ghz, subtract->channels_6ghz);
+	if (L_WARN_ON(!sub))
+		return;
+
+	l_uintset_free(set->channels_6ghz);
+	set->channels_6ghz = sub;
+
+	sub = l_uintset_subtract(set->channels_5ghz, subtract->channels_5ghz);
+	if (L_WARN_ON(!sub))
+		return;
+
+	l_uintset_free(set->channels_5ghz);
+	set->channels_5ghz = sub;
+
+	set->channels_2ghz &= ~subtract->channels_2ghz;
+}
+
 static void add_foreach(uint32_t freq, void *user_data)
 {
 	uint32_t **list = user_data;
diff --git a/src/util.h b/src/util.h
index f61e3575..0b7832fb 100644
--- a/src/util.h
+++ b/src/util.h
@@ -118,6 +118,8 @@ void scan_freq_set_merge(struct scan_freq_set *to,
 					const struct scan_freq_set *from);
 void scan_freq_set_constrain(struct scan_freq_set *set,
 					const struct scan_freq_set *constraint);
+void scan_freq_set_subtract(struct scan_freq_set *set,
+					const struct scan_freq_set *subtract);
 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);
-- 
2.34.3


  parent reply	other threads:[~2022-07-26 17:09 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-07-26 17:09 [PATCH 01/10] manager: unregister nl80211 config watch James Prestwood
2022-07-26 17:09 ` [PATCH 02/10] test-runner: make developer mode optional James Prestwood
2022-07-26 17:09 ` [PATCH 03/10] auto-t: iwd.py: let IWD class specify developer mode James Prestwood
2022-07-26 17:09 ` [PATCH 04/10] wiphy: fix runtime error from bit shift James Prestwood
2022-07-26 20:57   ` Denis Kenzior
2022-07-27 16:00     ` James Prestwood
2022-07-26 17:09 ` [PATCH 05/10] scan: make scan_freq_set const in scan_passive James Prestwood
2022-07-26 17:09 ` [PATCH 06/10] util: make scan_freq_set_get_bands const James Prestwood
2022-07-26 17:09 ` James Prestwood [this message]
2022-07-26 17:09 ` [PATCH 08/10] wiphy: add disabled_freqs list James Prestwood
2022-07-26 17:09 ` [PATCH 09/10] wiphy: constrain scan set by disabled frequencies James Prestwood
2022-07-26 17:09 ` [PATCH 10/10] nl80211util: add nested attribute support James Prestwood
2022-07-26 20:52 ` [PATCH 01/10] manager: unregister nl80211 config watch 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=20220726170920.15929-7-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.