mirror of
https://git.kernel.org/pub/scm/network/wireless/iwd.git
synced 2025-01-03 10:32:33 +01:00
scan: add scan_freq_set_to_fixed_array
This serializes a scan_freq_set into a uint32_t array.
This commit is contained in:
parent
9c732cb32d
commit
94cdbb4669
33
src/util.c
33
src/util.c
@ -470,3 +470,36 @@ void scan_freq_set_constrain(struct scan_freq_set *set,
|
|||||||
|
|
||||||
set->channels_2ghz &= constraint->channels_2ghz;
|
set->channels_2ghz &= constraint->channels_2ghz;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void add_foreach(uint32_t freq, void *user_data)
|
||||||
|
{
|
||||||
|
uint32_t **list = user_data;
|
||||||
|
|
||||||
|
**list = freq;
|
||||||
|
|
||||||
|
*list = *list + 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
uint32_t *scan_freq_set_to_fixed_array(const struct scan_freq_set *set,
|
||||||
|
size_t *len_out)
|
||||||
|
{
|
||||||
|
uint8_t count = 0;
|
||||||
|
uint32_t *freqs;
|
||||||
|
|
||||||
|
count = __builtin_popcount(set->channels_2ghz) +
|
||||||
|
l_uintset_size(set->channels_5ghz);
|
||||||
|
|
||||||
|
if (!count)
|
||||||
|
return NULL;
|
||||||
|
|
||||||
|
freqs = l_new(uint32_t, count);
|
||||||
|
|
||||||
|
scan_freq_set_foreach(set, add_foreach, &freqs);
|
||||||
|
|
||||||
|
/* Move pointer back to start of list */
|
||||||
|
freqs -= count;
|
||||||
|
|
||||||
|
*len_out = count;
|
||||||
|
|
||||||
|
return freqs;
|
||||||
|
}
|
||||||
|
@ -115,5 +115,7 @@ void scan_freq_set_merge(struct scan_freq_set *to,
|
|||||||
void scan_freq_set_constrain(struct scan_freq_set *set,
|
void scan_freq_set_constrain(struct scan_freq_set *set,
|
||||||
const struct scan_freq_set *constraint);
|
const struct scan_freq_set *constraint);
|
||||||
bool scan_freq_set_isempty(const 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);
|
||||||
|
|
||||||
#endif /* __UTIL_H */
|
#endif /* __UTIL_H */
|
||||||
|
Loading…
Reference in New Issue
Block a user