0001
0002
0003
0004 #ifndef __RTW89_UTIL_H__
0005 #define __RTW89_UTIL_H__
0006
0007 #include "core.h"
0008
0009 #define rtw89_iterate_vifs_bh(rtwdev, iterator, data) \
0010 ieee80211_iterate_active_interfaces_atomic((rtwdev)->hw, \
0011 IEEE80211_IFACE_ITER_NORMAL, iterator, data)
0012
0013
0014 #define rtw89_for_each_rtwvif(rtwdev, rtwvif) \
0015 list_for_each_entry(rtwvif, &(rtwdev)->rtwvifs_list, list)
0016
0017
0018
0019
0020
0021
0022
0023 static inline s32 s32_div_u32_round_down(s32 dividend, u32 divisor, s32 *remainder)
0024 {
0025 s32 i_divisor = (s32)divisor;
0026 s32 i_remainder;
0027 s32 quotient;
0028
0029 quotient = dividend / i_divisor;
0030 i_remainder = dividend % i_divisor;
0031
0032 if (i_remainder < 0) {
0033 quotient--;
0034 i_remainder += i_divisor;
0035 }
0036
0037 if (remainder)
0038 *remainder = i_remainder;
0039 return quotient;
0040 }
0041
0042 static inline s32 s32_div_u32_round_closest(s32 dividend, u32 divisor)
0043 {
0044 return s32_div_u32_round_down(dividend + divisor / 2, divisor, NULL);
0045 }
0046
0047 #endif