3
0
mirror of https://git.kernel.org/pub/scm/network/wireless/iwd.git synced 2024-12-22 04:32:37 +01:00

util: add scan_freq_set_remove

Removes one frequency from a scan_freq_set object.
This commit is contained in:
James Prestwood 2022-12-13 12:36:19 -08:00 committed by Denis Kenzior
parent ea93e74a06
commit 59a0947c76
2 changed files with 23 additions and 0 deletions

View File

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

View File

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