On Sun, Jul 31, 2016 at 01:55:31PM +0200, Claudio Jeker wrote:
> On Sat, Jul 30, 2016 at 10:03:33PM +0200, Mark Kettenis wrote:
> > Removes a couple of lines of code from the driver.
> > 
> > ok?
> 
> This is the right use of m_devget. OK claudio@
> 

Another one. (2 dlg@, this was the m_*() i was looking for.)

-Artturi

> PS: realized that the manpage for m_devget still has the old prototype
> with the ifp in it...
> 
> -- 
> :wq Claudio
>  
> 


Index: sxie.c
===================================================================
RCS file: /cvs/src/sys/arch/armv7/sunxi/sxie.c,v
retrieving revision 1.17
diff -u -p -r1.17 sxie.c
--- sxie.c      27 Jul 2016 11:45:02 -0000      1.17
+++ sxie.c      31 Jul 2016 12:12:44 -0000
@@ -179,7 +179,6 @@ void        sxie_init(struct sxie_softc *);
 void   sxie_stop(struct sxie_softc *);
 void   sxie_reset(struct sxie_softc *);
 void   sxie_iff(struct sxie_softc *, struct ifnet *);
-struct mbuf * sxie_newbuf(void);
 int    sxie_intr(void *);
 void   sxie_recv(struct sxie_softc *);
 int    sxie_miibus_readreg(struct device *, int, int);
@@ -607,10 +606,6 @@ trynext:
                goto err_out;
        }
        
-       m = sxie_newbuf();
-       if (m == NULL)
-               goto err_out;
-
        reg = SXIREAD4(sc, SXIE_RXIO);
        pktstat = (uint16_t)reg >> 16;
        pktlen = (int16_t)reg; /* length of useful data */
@@ -622,10 +617,6 @@ trynext:
        if (pktlen > SXIE_MAX_PKT_SIZE)
                pktlen = SXIE_MAX_PKT_SIZE; /* XXX is truncating ok? */
 
-       m->m_pkthdr.len = m->m_len = pktlen;
-       /* XXX m->m_pkthdr.csum_flags ? */
-       m_adj(m, ETHER_ALIGN);
-
        /* read the actual packet from fifo XXX through 'align buffer'.. */
        if (pktlen & 3)
                rlen = SXIE_ROUNDUP(pktlen, 4);
@@ -633,7 +624,12 @@ trynext:
                rlen = pktlen;
        bus_space_read_multi_4(sc->sc_iot, sc->sc_ioh,
            SXIE_RXIO, (uint32_t *)&rxbuf[0], rlen >> 2);
-       memcpy(mtod(m, char *), (char *)&rxbuf[0], pktlen);
+
+       m = m_devget(&rxbuf[0], pktlen, ETHER_ALIGN);
+       if (m == NULL) {
+               ifp->if_ierrors++;
+               goto err_out;
+       }
 
        ml_enqueue(&ml, m);
        goto trynext;
@@ -683,24 +679,6 @@ sxie_ioctl(struct ifnet *ifp, u_long cmd
 
        splx(s);
        return error;
-}
-
-struct mbuf *
-sxie_newbuf(void)
-{
-       struct mbuf *m;
-
-       MGETHDR(m, M_DONTWAIT, MT_DATA);
-       if (m == NULL)
-               return (NULL);
-
-       MCLGET(m, M_DONTWAIT);
-       if (!(m->m_flags & M_EXT)) {
-               m_freem(m);
-               return (NULL);
-       }
-
-       return (m);
 }
 
 void

Reply via email to