summaryrefslogtreecommitdiffstats
path: root/sys/net80211/ieee80211.c
diff options
context:
space:
mode:
authorrpaulo <rpaulo@FreeBSD.org>2013-08-14 04:24:25 +0000
committerrpaulo <rpaulo@FreeBSD.org>2013-08-14 04:24:25 +0000
commitb66e5efc0f138709337bda97b97422177187cf60 (patch)
treeaab84fc7202136670f336f52bd4cbf358edc91cf /sys/net80211/ieee80211.c
parentcee1e037da7213db868bb6bfc99884926330de56 (diff)
downloadFreeBSD-src-b66e5efc0f138709337bda97b97422177187cf60.zip
FreeBSD-src-b66e5efc0f138709337bda97b97422177187cf60.tar.gz
Replace the homegrown implementation of nitems() with calls to nitems()
(param.h). Operating systems that don't have nitems() can easily define it on their own net80211 OS-specific header file. Discussed with: adrian
Diffstat (limited to 'sys/net80211/ieee80211.c')
-rw-r--r--sys/net80211/ieee80211.c23
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
}
/*
OpenPOWER on IntegriCloud