summaryrefslogtreecommitdiff
path: root/sys/dev/ic/rt2661.c
diff options
context:
space:
mode:
Diffstat (limited to 'sys/dev/ic/rt2661.c')
-rw-r--r--sys/dev/ic/rt2661.c32
1 files changed, 5 insertions, 27 deletions
diff --git a/sys/dev/ic/rt2661.c b/sys/dev/ic/rt2661.c
index a105b8f79f1..c22fd40b010 100644
--- a/sys/dev/ic/rt2661.c
+++ b/sys/dev/ic/rt2661.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: rt2661.c,v 1.44 2008/08/27 09:05:03 damien Exp $ */
+/* $OpenBSD: rt2661.c,v 1.45 2008/11/25 21:43:57 damien Exp $ */
/*-
* Copyright (c) 2006
@@ -1546,7 +1546,6 @@ rt2661_tx_data(struct rt2661_softc *sc, struct mbuf *m0,
struct rt2661_tx_data *data;
struct ieee80211_frame *wh;
struct ieee80211_key *k;
- struct mbuf *mnew;
uint16_t dur;
uint32_t flags = 0;
int pktlen, rate, needcts = 0, needrts = 0, error;
@@ -1672,27 +1671,10 @@ rt2661_tx_data(struct rt2661_softc *sc, struct mbuf *m0,
}
if (error != 0) {
/* too many fragments, linearize */
-
- MGETHDR(mnew, M_DONTWAIT, MT_DATA);
- if (mnew == NULL) {
+ if (m_defrag(m0, M_DONTWAIT) != 0) {
m_freem(m0);
return ENOMEM;
}
- M_DUP_PKTHDR(mnew, m0);
- if (m0->m_pkthdr.len > MHLEN) {
- MCLGET(mnew, M_DONTWAIT);
- if (!(mnew->m_flags & M_EXT)) {
- m_freem(m0);
- m_freem(mnew);
- return ENOMEM;
- }
- }
-
- m_copydata(m0, 0, m0->m_pkthdr.len, mtod(mnew, caddr_t));
- m_freem(m0);
- mnew->m_len = mnew->m_pkthdr.len;
- m0 = mnew;
-
error = bus_dmamap_load_mbuf(sc->sc_dmat, data->map, m0,
BUS_DMA_NOWAIT);
if (error != 0) {
@@ -2387,7 +2369,6 @@ rt2661_read_eeprom(struct rt2661_softc *sc)
int
rt2661_bbp_init(struct rt2661_softc *sc)
{
-#define N(a) (sizeof (a) / sizeof ((a)[0]))
int i, ntries;
/* wait for BBP to be ready */
@@ -2403,7 +2384,7 @@ rt2661_bbp_init(struct rt2661_softc *sc)
}
/* initialize BBP registers to default values */
- for (i = 0; i < N(rt2661_def_bbp); i++) {
+ for (i = 0; i < nitems(rt2661_def_bbp); i++) {
rt2661_bbp_write(sc, rt2661_def_bbp[i].reg,
rt2661_def_bbp[i].val);
}
@@ -2416,13 +2397,11 @@ rt2661_bbp_init(struct rt2661_softc *sc)
}
return 0;
-#undef N
}
int
rt2661_init(struct ifnet *ifp)
{
-#define N(a) (sizeof (a) / sizeof ((a)[0]))
struct rt2661_softc *sc = ifp->if_softc;
struct ieee80211com *ic = &sc->sc_ic;
const char *name = NULL; /* make lint happy */
@@ -2515,7 +2494,7 @@ rt2661_init(struct ifnet *ifp)
RAL_WRITE(sc, RT2661_RX_CNTL_CSR, 2);
/* initialize MAC registers to default values */
- for (i = 0; i < N(rt2661_def_mac); i++)
+ for (i = 0; i < nitems(rt2661_def_mac); i++)
RAL_WRITE(sc, rt2661_def_mac[i].reg, rt2661_def_mac[i].val);
IEEE80211_ADDR_COPY(ic->ic_myaddr, LLADDR(ifp->if_sadl));
@@ -2566,7 +2545,7 @@ rt2661_init(struct ifnet *ifp)
RAL_WRITE(sc, RT2661_TXRX_CSR0, tmp);
/* clear STA registers */
- RAL_READ_REGION_4(sc, RT2661_STA_CSR0, sta, N(sta));
+ RAL_READ_REGION_4(sc, RT2661_STA_CSR0, sta, nitems(sta));
/* initialize ASIC */
RAL_WRITE(sc, RT2661_MAC_CSR1, 4);
@@ -2590,7 +2569,6 @@ rt2661_init(struct ifnet *ifp)
ieee80211_new_state(ic, IEEE80211_S_RUN, -1);
return 0;
-#undef N
}
void