move a common statement out of if/else;
authorthib <thib@openbsd.org>
Thu, 10 Jul 2008 18:14:59 +0000 (18:14 +0000)
committerthib <thib@openbsd.org>
Thu, 10 Jul 2008 18:14:59 +0000 (18:14 +0000)
adjust the mbuf before loading it, with bus_dmamap_load_mbuf(),
that way we dont have to fiddle with ds_addr;

ok dlg@

sys/dev/pci/if_sis.c

index 82aac88..685dc5c 100644 (file)
@@ -1,4 +1,4 @@
-/*     $OpenBSD: if_sis.c,v 1.78 2008/07/07 12:53:43 thib Exp $ */
+/*     $OpenBSD: if_sis.c,v 1.79 2008/07/10 18:14:59 thib Exp $ */
 /*
  * Copyright (c) 1997, 1998, 1999
  *     Bill Paul <wpaul@ctr.columbia.edu>.  All rights reserved.
@@ -1251,13 +1251,15 @@ sis_newbuf(struct sis_softc *sc, struct sis_desc *c, struct mbuf *m)
                        m_freem(m_new);
                        return (ENOBUFS);
                }
-               m_new->m_len = m_new->m_pkthdr.len = MCLBYTES;
        } else {
                m_new = m;
-               m_new->m_len = m_new->m_pkthdr.len = MCLBYTES;
                m_new->m_data = m_new->m_ext.ext_buf;
        }
 
+       m_new->m_len = m_new->m_pkthdr.len = MCLBYTES;
+
+       m_adj(m_new, sizeof(u_int64_t));
+
        if (bus_dmamap_load_mbuf(sc->sc_dmat, sc->sc_rx_sparemap, m_new,
            BUS_DMA_NOWAIT)) {
                m_freem(m_new);
@@ -1271,10 +1273,8 @@ sis_newbuf(struct sis_softc *sc, struct sis_desc *c, struct mbuf *m)
        bus_dmamap_sync(sc->sc_dmat, c->map, 0, c->map->dm_mapsize,
            BUS_DMASYNC_PREREAD);
 
-       m_adj(m_new, sizeof(u_int64_t));
-
        c->sis_mbuf = m_new;
-       c->sis_ptr = c->map->dm_segs[0].ds_addr + sizeof(u_int64_t);
+       c->sis_ptr = c->map->dm_segs[0].ds_addr;
        c->sis_ctl = ETHER_MAX_DIX_LEN;
 
        bus_dmamap_sync(sc->sc_dmat, sc->sc_listmap,