diff options
Diffstat (limited to 'sys/dev/pci')
-rw-r--r-- | sys/dev/pci/if_ipw.c | 27 | ||||
-rw-r--r-- | sys/dev/pci/if_iwi.c | 22 | ||||
-rw-r--r-- | sys/dev/pci/if_iwn.c | 23 | ||||
-rw-r--r-- | sys/dev/pci/if_wpi.c | 19 |
4 files changed, 11 insertions, 80 deletions
diff --git a/sys/dev/pci/if_ipw.c b/sys/dev/pci/if_ipw.c index 52f30ff4c9d..3df6e44fd83 100644 --- a/sys/dev/pci/if_ipw.c +++ b/sys/dev/pci/if_ipw.c @@ -1,4 +1,4 @@ -/* $OpenBSD: if_ipw.c,v 1.80 2008/09/03 19:43:59 damien Exp $ */ +/* $OpenBSD: if_ipw.c,v 1.81 2008/11/25 21:43:57 damien Exp $ */ /*- * Copyright (c) 2004-2008 @@ -610,7 +610,6 @@ ipw_media_change(struct ifnet *ifp) void ipw_media_status(struct ifnet *ifp, struct ifmediareq *imr) { -#define N(a) (sizeof (a) / sizeof (a[0])) struct ipw_softc *sc = ifp->if_softc; struct ieee80211com *ic = &sc->sc_ic; static const struct { @@ -635,8 +634,8 @@ ipw_media_status(struct ifnet *ifp, struct ifmediareq *imr) val &= 0xf; /* convert rate to 802.11 rate */ - for (i = 0; i < N(rates) && rates[i].val != val; i++); - rate = (i < N(rates)) ? rates[i].rate : 0; + for (i = 0; i < nitems(rates) && rates[i].val != val; i++); + rate = (i < nitems(rates)) ? rates[i].rate : 0; imr->ifm_active |= IFM_IEEE80211_11B; imr->ifm_active |= ieee80211_rate2media(ic, rate, IEEE80211_MODE_11B); @@ -655,7 +654,6 @@ ipw_media_status(struct ifnet *ifp, struct ifmediareq *imr) /* should not get there */ break; } -#undef N } int @@ -1132,7 +1130,6 @@ ipw_tx_start(struct ifnet *ifp, struct mbuf *m, struct ieee80211_node *ni) struct ipw_soft_bd *sbd; struct ipw_soft_hdr *shdr; struct ipw_soft_buf *sbuf; - struct mbuf *mnew; int error, i; wh = mtod(m, struct ieee80211_frame *); @@ -1194,26 +1191,10 @@ ipw_tx_start(struct ifnet *ifp, struct mbuf *m, struct ieee80211_node *ni) } if (error != 0) { /* too many fragments, linearize */ - - MGETHDR(mnew, M_DONTWAIT, MT_DATA); - if (mnew == NULL) { + if (m_defrag(m, M_DONTWAIT) != 0) { m_freem(m); return ENOMEM; } - M_DUP_PKTHDR(mnew, m); - if (m->m_pkthdr.len > MHLEN) { - MCLGET(mnew, M_DONTWAIT); - if (!(mnew->m_flags & M_EXT)) { - m_freem(m); - m_freem(mnew); - return ENOMEM; - } - } - m_copydata(m, 0, m->m_pkthdr.len, mtod(mnew, caddr_t)); - m_freem(m); - mnew->m_len = mnew->m_pkthdr.len; - m = mnew; - error = bus_dmamap_load_mbuf(sc->sc_dmat, sbuf->map, m, BUS_DMA_NOWAIT); if (error != 0) { diff --git a/sys/dev/pci/if_iwi.c b/sys/dev/pci/if_iwi.c index 64dc8c74db1..69a826cfc92 100644 --- a/sys/dev/pci/if_iwi.c +++ b/sys/dev/pci/if_iwi.c @@ -1,4 +1,4 @@ -/* $OpenBSD: if_iwi.c,v 1.94 2008/09/04 15:59:52 damien Exp $ */ +/* $OpenBSD: if_iwi.c,v 1.95 2008/11/25 21:43:57 damien Exp $ */ /*- * Copyright (c) 2004-2008 @@ -1236,7 +1236,6 @@ iwi_tx_start(struct ifnet *ifp, struct mbuf *m0, struct ieee80211_node *ni) struct iwi_tx_data *data; struct iwi_tx_desc *desc; struct iwi_tx_ring *txq = &sc->txq[0]; - struct mbuf *mnew; int hdrlen, error, i, station = 0; wh = mtod(m0, struct ieee80211_frame *); @@ -1300,27 +1299,10 @@ iwi_tx_start(struct ifnet *ifp, struct mbuf *m0, struct ieee80211_node *ni) } 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) { diff --git a/sys/dev/pci/if_iwn.c b/sys/dev/pci/if_iwn.c index e60825b5877..1933e9515ba 100644 --- a/sys/dev/pci/if_iwn.c +++ b/sys/dev/pci/if_iwn.c @@ -1,4 +1,4 @@ -/* $OpenBSD: if_iwn.c,v 1.38 2008/11/25 17:06:27 damien Exp $ */ +/* $OpenBSD: if_iwn.c,v 1.39 2008/11/25 21:43:57 damien Exp $ */ /*- * Copyright (c) 2007, 2008 @@ -2144,7 +2144,6 @@ iwn_wakeup_intr(struct iwn_softc *sc) void iwn_fatal_intr(struct iwn_softc *sc) { -#define N(a) (sizeof (a) / sizeof ((a)[0])) const struct iwn_hal *hal = sc->sc_hal; struct iwn_fw_dump dump; int i; @@ -2174,7 +2173,7 @@ iwn_fatal_intr(struct iwn_softc *sc) } printf("firmware error log:\n"); printf(" error type = \"%s\" (0x%08X)\n", - (dump.id < N(iwn_fw_errmsg)) ? + (dump.id < nitems(iwn_fw_errmsg)) ? iwn_fw_errmsg[dump.id] : "UNKNOWN", dump.id); printf(" program counter = 0x%08X\n", dump.pc); @@ -2196,7 +2195,6 @@ iwn_fatal_intr(struct iwn_softc *sc) } printf(" rx ring: cur=%d\n", sc->rxq.cur); printf(" 802.11 state %d\n", sc->sc_ic.ic_state); -#undef N } int @@ -2334,7 +2332,6 @@ iwn_tx(struct iwn_softc *sc, struct mbuf *m, struct ieee80211_node *ni) struct ieee80211_frame *wh; struct ieee80211_key *k = NULL; enum ieee80211_edca_ac ac; - struct mbuf *m1; uint32_t flags; uint16_t qos; u_int hdrlen; @@ -2549,24 +2546,10 @@ iwn_tx(struct iwn_softc *sc, struct mbuf *m, struct ieee80211_node *ni) } if (error != 0) { /* Too many DMA segments, linearize mbuf. */ - MGETHDR(m1, M_DONTWAIT, MT_DATA); - if (m1 == NULL) { + if (m_defrag(m, M_DONTWAIT) != 0) { m_freem(m); return ENOMEM; } - if (m->m_pkthdr.len > MHLEN) { - MCLGET(m1, M_DONTWAIT); - if (!(m1->m_flags & M_EXT)) { - m_freem(m); - m_freem(m1); - return ENOMEM; - } - } - m_copydata(m, 0, m->m_pkthdr.len, mtod(m1, caddr_t)); - m1->m_len = m1->m_pkthdr.len = m->m_pkthdr.len; - m_freem(m); - m = m1; - error = bus_dmamap_load_mbuf(sc->sc_dmat, data->map, m, BUS_DMA_NOWAIT); if (error != 0) { diff --git a/sys/dev/pci/if_wpi.c b/sys/dev/pci/if_wpi.c index 3cdbf8af0ed..730ae5d9ab3 100644 --- a/sys/dev/pci/if_wpi.c +++ b/sys/dev/pci/if_wpi.c @@ -1,4 +1,4 @@ -/* $OpenBSD: if_wpi.c,v 1.74 2008/11/25 17:06:26 damien Exp $ */ +/* $OpenBSD: if_wpi.c,v 1.75 2008/11/25 21:43:57 damien Exp $ */ /*- * Copyright (c) 2006-2008 @@ -1675,7 +1675,6 @@ wpi_tx(struct wpi_softc *sc, struct mbuf *m, struct ieee80211_node *ni) struct ieee80211_frame *wh; struct ieee80211_key *k = NULL; enum ieee80211_edca_ac ac; - struct mbuf *m1; uint32_t flags; uint16_t qos; u_int hdrlen; @@ -1851,24 +1850,10 @@ wpi_tx(struct wpi_softc *sc, struct mbuf *m, struct ieee80211_node *ni) } if (error != 0) { /* Too many DMA segments, linearize mbuf. */ - MGETHDR(m1, M_DONTWAIT, MT_DATA); - if (m1 == NULL) { + if (m_defrag(m, M_DONTWAIT) != 0) { m_freem(m); return ENOMEM; } - if (m->m_pkthdr.len > MHLEN) { - MCLGET(m1, M_DONTWAIT); - if (!(m1->m_flags & M_EXT)) { - m_freem(m); - m_freem(m1); - return ENOMEM; - } - } - m_copydata(m, 0, m->m_pkthdr.len, mtod(m1, caddr_t)); - m1->m_len = m1->m_pkthdr.len = m->m_pkthdr.len; - m_freem(m); - m = m1; - error = bus_dmamap_load_mbuf(sc->sc_dmat, data->map, m, BUS_DMA_NOWAIT); if (error != 0) { |