diff options
Diffstat (limited to 'sys/net80211/ieee80211.c')
-rw-r--r-- | sys/net80211/ieee80211.c | 23 |
1 files changed, 11 insertions, 12 deletions
diff --git a/sys/net80211/ieee80211.c b/sys/net80211/ieee80211.c index aaadb92..db505ab 100644 --- a/sys/net80211/ieee80211.c +++ b/sys/net80211/ieee80211.c @@ -1518,7 +1518,6 @@ findmedia(const struct ratemedia rates[], int n, u_int match) int ieee80211_rate2media(struct ieee80211com *ic, int rate, enum ieee80211_phymode mode) { -#define N(a) (sizeof(a) / sizeof(a[0])) static const struct ratemedia rates[] = { { 2 | IFM_IEEE80211_FH, IFM_IEEE80211_FH1 }, { 4 | IFM_IEEE80211_FH, IFM_IEEE80211_FH2 }, @@ -1639,7 +1638,7 @@ ieee80211_rate2media(struct ieee80211com *ic, int rate, enum ieee80211_phymode m if (mode == IEEE80211_MODE_11NA) { if (rate & IEEE80211_RATE_MCS) { rate &= ~IEEE80211_RATE_MCS; - m = findmedia(htrates, N(htrates), rate); + m = findmedia(htrates, nitems(htrates), rate); if (m != IFM_AUTO) return m | IFM_IEEE80211_11NA; } @@ -1647,7 +1646,7 @@ ieee80211_rate2media(struct ieee80211com *ic, int rate, enum ieee80211_phymode m /* NB: 12 is ambiguous, it will be treated as an MCS */ if (rate & IEEE80211_RATE_MCS) { rate &= ~IEEE80211_RATE_MCS; - m = findmedia(htrates, N(htrates), rate); + m = findmedia(htrates, nitems(htrates), rate); if (m != IFM_AUTO) return m | IFM_IEEE80211_11NG; } @@ -1660,31 +1659,32 @@ ieee80211_rate2media(struct ieee80211com *ic, int rate, enum ieee80211_phymode m case IEEE80211_MODE_11NA: case IEEE80211_MODE_TURBO_A: case IEEE80211_MODE_STURBO_A: - return findmedia(rates, N(rates), rate | IFM_IEEE80211_11A); + return findmedia(rates, nitems(rates), + rate | IFM_IEEE80211_11A); case IEEE80211_MODE_11B: - return findmedia(rates, N(rates), rate | IFM_IEEE80211_11B); + return findmedia(rates, nitems(rates), + rate | IFM_IEEE80211_11B); case IEEE80211_MODE_FH: - return findmedia(rates, N(rates), rate | IFM_IEEE80211_FH); + return findmedia(rates, nitems(rates), + rate | IFM_IEEE80211_FH); case IEEE80211_MODE_AUTO: /* NB: ic may be NULL for some drivers */ if (ic != NULL && ic->ic_phytype == IEEE80211_T_FH) - return findmedia(rates, N(rates), + return findmedia(rates, nitems(rates), rate | IFM_IEEE80211_FH); /* NB: hack, 11g matches both 11b+11a rates */ /* fall thru... */ case IEEE80211_MODE_11G: case IEEE80211_MODE_11NG: case IEEE80211_MODE_TURBO_G: - return findmedia(rates, N(rates), rate | IFM_IEEE80211_11G); + return findmedia(rates, nitems(rates), rate | IFM_IEEE80211_11G); } return IFM_AUTO; -#undef N } int ieee80211_media2rate(int mword) { -#define N(a) (sizeof(a) / sizeof(a[0])) static const int ieeerates[] = { -1, /* IFM_AUTO */ 0, /* IFM_MANUAL */ @@ -1712,9 +1712,8 @@ ieee80211_media2rate(int mword) 54, /* IFM_IEEE80211_OFDM27 */ -1, /* IFM_IEEE80211_MCS */ }; - return IFM_SUBTYPE(mword) < N(ieeerates) ? + return IFM_SUBTYPE(mword) < nitems(ieeerates) ? ieeerates[IFM_SUBTYPE(mword)] : 0; -#undef N } /* |