util: add scan_freq_set_subtract

Removes any frequencies from one set that are found in the other.
This commit is contained in:
James Prestwood 2022-07-26 10:09:17 -07:00 committed by Denis Kenzior
parent 3f1d72e545
commit 081b0af2d6
2 changed files with 24 additions and 0 deletions

View File

@ -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;

View File

@ -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);