diff options
author | imp <imp@FreeBSD.org> | 2006-04-04 19:30:47 +0000 |
---|---|---|
committer | imp <imp@FreeBSD.org> | 2006-04-04 19:30:47 +0000 |
commit | c95a2670388d0513559c5aa2c453fa9932f58d8d (patch) | |
tree | cbc26561e757d87167702ad19d10162c0c2b04d1 /sys | |
parent | b5dd7f5b999f6ccf3785cf36f0a6edfa7029ccd9 (diff) | |
download | FreeBSD-src-c95a2670388d0513559c5aa2c453fa9932f58d8d.zip FreeBSD-src-c95a2670388d0513559c5aa2c453fa9932f58d8d.tar.gz |
Turn a file that was mostly style(9) compliant to a file that's really close
to being completely style(9). The odd-ball indentation in a few places was
really distracting.
Diffstat (limited to 'sys')
-rw-r--r-- | sys/dev/iicbus/if_ic.c | 256 |
1 files changed, 115 insertions, 141 deletions
diff --git a/sys/dev/iicbus/if_ic.c b/sys/dev/iicbus/if_ic.c index 5c6e05b..07adfc6 100644 --- a/sys/dev/iicbus/if_ic.c +++ b/sys/dev/iicbus/if_ic.c @@ -132,9 +132,8 @@ icattach(device_t dev) struct ifnet *ifp; ifp = sc->ic_ifp = if_alloc(IFT_PARA); - if (ifp == NULL) { + if (ifp == NULL) return (ENOSPC); - } sc->ic_addr = PCF_MASTER_ADDRESS; /* XXX only PCF masters */ @@ -162,121 +161,106 @@ icattach(device_t dev) static int icioctl(struct ifnet *ifp, u_long cmd, caddr_t data) { - device_t icdev = devclass_get_device(ic_devclass, ifp->if_dunit); - device_t parent = device_get_parent(icdev); - struct ic_softc *sc = (struct ic_softc *)device_get_softc(icdev); - - struct ifaddr *ifa = (struct ifaddr *)data; - struct ifreq *ifr = (struct ifreq *)data; - - u_char *iptr, *optr; - int error; - - switch (cmd) { - - case SIOCSIFDSTADDR: - case SIOCAIFADDR: - case SIOCSIFADDR: - if (ifa->ifa_addr->sa_family != AF_INET) - return EAFNOSUPPORT; - ifp->if_flags |= IFF_UP; - /* FALLTHROUGH */ - case SIOCSIFFLAGS: - if ((!(ifp->if_flags & IFF_UP)) && - (ifp->if_drv_flags & IFF_DRV_RUNNING)) { - - /* XXX disable PCF */ - ifp->if_drv_flags &= ~IFF_DRV_RUNNING; - - /* IFF_UP is not set, try to release the bus anyway */ - iicbus_release_bus(parent, icdev); - break; - } - if (((ifp->if_flags & IFF_UP)) && - (!(ifp->if_drv_flags & IFF_DRV_RUNNING))) { - - if ((error = iicbus_request_bus(parent, icdev, IIC_WAIT|IIC_INTR))) - return (error); - - sc->ic_obuf = malloc(sc->ic_ifp->if_mtu + ICHDRLEN, - M_DEVBUF, M_WAITOK); - if (!sc->ic_obuf) { - iicbus_release_bus(parent, icdev); - return ENOBUFS; - } - - sc->ic_ifbuf = malloc(sc->ic_ifp->if_mtu + ICHDRLEN, - M_DEVBUF, M_WAITOK); - if (!sc->ic_ifbuf) { - iicbus_release_bus(parent, icdev); - return ENOBUFS; - } - - iicbus_reset(parent, IIC_FASTEST, 0, NULL); - - ifp->if_drv_flags |= IFF_DRV_RUNNING; - } - break; - - case SIOCSIFMTU: - /* save previous buffers */ - iptr = sc->ic_ifbuf; - optr = sc->ic_obuf; - - /* allocate input buffer */ - sc->ic_ifbuf = malloc(ifr->ifr_mtu+ICHDRLEN, M_DEVBUF, M_NOWAIT); - if (!sc->ic_ifbuf) { - - sc->ic_ifbuf = iptr; - sc->ic_obuf = optr; - - return ENOBUFS; - } + device_t icdev = devclass_get_device(ic_devclass, ifp->if_dunit); + device_t parent = device_get_parent(icdev); + struct ic_softc *sc = (struct ic_softc *)device_get_softc(icdev); - /* allocate output buffer */ - sc->ic_ifbuf = malloc(ifr->ifr_mtu+ICHDRLEN, M_DEVBUF, M_NOWAIT); - if (!sc->ic_obuf) { + struct ifaddr *ifa = (struct ifaddr *)data; + struct ifreq *ifr = (struct ifreq *)data; - free(sc->ic_ifbuf,M_DEVBUF); + u_char *iptr, *optr; + int error; - sc->ic_ifbuf = iptr; - sc->ic_obuf = optr; + switch (cmd) { - return ENOBUFS; - } + case SIOCSIFDSTADDR: + case SIOCAIFADDR: + case SIOCSIFADDR: + if (ifa->ifa_addr->sa_family != AF_INET) + return (EAFNOSUPPORT); + ifp->if_flags |= IFF_UP; + /* FALLTHROUGH */ + case SIOCSIFFLAGS: + if ((!(ifp->if_flags & IFF_UP)) && + (ifp->if_drv_flags & IFF_DRV_RUNNING)) { - if (iptr) - free(iptr,M_DEVBUF); + /* XXX disable PCF */ + ifp->if_drv_flags &= ~IFF_DRV_RUNNING; - if (optr) - free(optr,M_DEVBUF); + /* IFF_UP is not set, try to release the bus anyway */ + iicbus_release_bus(parent, icdev); + break; + } + if (((ifp->if_flags & IFF_UP)) && + (!(ifp->if_drv_flags & IFF_DRV_RUNNING))) { + if ((error = iicbus_request_bus(parent, icdev, + IIC_WAIT | IIC_INTR))) + return (error); + sc->ic_obuf = malloc(sc->ic_ifp->if_mtu + ICHDRLEN, + M_DEVBUF, M_WAITOK); + if (!sc->ic_obuf) { + iicbus_release_bus(parent, icdev); + return (ENOBUFS); + } + sc->ic_ifbuf = malloc(sc->ic_ifp->if_mtu + ICHDRLEN, + M_DEVBUF, M_WAITOK); + if (!sc->ic_ifbuf) { + iicbus_release_bus(parent, icdev); + return (ENOBUFS); + } + iicbus_reset(parent, IIC_FASTEST, 0, NULL); + ifp->if_drv_flags |= IFF_DRV_RUNNING; + } + break; - sc->ic_ifp->if_mtu = ifr->ifr_mtu; - break; + case SIOCSIFMTU: + /* save previous buffers */ + iptr = sc->ic_ifbuf; + optr = sc->ic_obuf; + + /* allocate input buffer */ + sc->ic_ifbuf = malloc(ifr->ifr_mtu+ICHDRLEN, M_DEVBUF, M_NOWAIT); + if (!sc->ic_ifbuf) { + sc->ic_ifbuf = iptr; + sc->ic_obuf = optr; + return (ENOBUFS); + } - case SIOCGIFMTU: - ifr->ifr_mtu = sc->ic_ifp->if_mtu; - break; + /* allocate output buffer */ + sc->ic_ifbuf = malloc(ifr->ifr_mtu+ICHDRLEN, M_DEVBUF, M_NOWAIT); + if (!sc->ic_obuf) { + free(sc->ic_ifbuf,M_DEVBUF); + sc->ic_ifbuf = iptr; + sc->ic_obuf = optr; + return (ENOBUFS); + } - case SIOCADDMULTI: - case SIOCDELMULTI: - if (ifr == 0) { - return EAFNOSUPPORT; /* XXX */ - } - switch (ifr->ifr_addr.sa_family) { + if (iptr) + free(iptr,M_DEVBUF); + if (optr) + free(optr,M_DEVBUF); + sc->ic_ifp->if_mtu = ifr->ifr_mtu; + break; - case AF_INET: - break; + case SIOCGIFMTU: + ifr->ifr_mtu = sc->ic_ifp->if_mtu; + break; + case SIOCADDMULTI: + case SIOCDELMULTI: + if (ifr == 0) + return (EAFNOSUPPORT); /* XXX */ + switch (ifr->ifr_addr.sa_family) { + case AF_INET: + break; + default: + return (EAFNOSUPPORT); + } + break; default: - return EAFNOSUPPORT; + return (EINVAL); } - break; - - default: - return EINVAL; - } - return 0; + return (0); } /* @@ -302,44 +286,34 @@ icintr (device_t dev, int event, char *ptr) case INTR_STOP: - /* if any error occured during transfert, - * drop the packet */ - if (sc->ic_iferrs) - goto err; - - if ((len = sc->ic_xfercnt) == 0) - break; /* ignore */ - - if (len <= ICHDRLEN) - goto err; - - len -= ICHDRLEN; - sc->ic_ifp->if_ipackets ++; - sc->ic_ifp->if_ibytes += len; - - BPF_TAP(sc->ic_ifp, sc->ic_ifbuf, len + ICHDRLEN); - - top = m_devget(sc->ic_ifbuf + ICHDRLEN, len, 0, sc->ic_ifp, 0); - - if (top) - netisr_dispatch(NETISR_IP, top); - break; - + /* if any error occured during transfert, + * drop the packet */ + if (sc->ic_iferrs) + goto err; + if ((len = sc->ic_xfercnt) == 0) + break; /* ignore */ + if (len <= ICHDRLEN) + goto err; + len -= ICHDRLEN; + sc->ic_ifp->if_ipackets++; + sc->ic_ifp->if_ibytes += len; + BPF_TAP(sc->ic_ifp, sc->ic_ifbuf, len + ICHDRLEN); + top = m_devget(sc->ic_ifbuf + ICHDRLEN, len, 0, sc->ic_ifp, 0); + if (top) + netisr_dispatch(NETISR_IP, top); + break; err: - printf("ic%d: errors (%d)!\n", unit, sc->ic_iferrs); - - sc->ic_iferrs = 0; /* reset error count */ - sc->ic_ifp->if_ierrors ++; - - break; + printf("ic%d: errors (%d)!\n", unit, sc->ic_iferrs); + sc->ic_iferrs = 0; /* reset error count */ + sc->ic_ifp->if_ierrors++; + break; case INTR_RECEIVE: if (sc->ic_xfercnt >= sc->ic_ifp->if_mtu+ICHDRLEN) { - sc->ic_iferrs ++; - + sc->ic_iferrs++; } else { *sc->ic_cp++ = *ptr; - sc->ic_xfercnt ++; + sc->ic_xfercnt++; } break; @@ -351,7 +325,7 @@ icintr (device_t dev, int event, char *ptr) break; case INTR_ERROR: - sc->ic_iferrs ++; + sc->ic_iferrs++; break; default: @@ -390,7 +364,7 @@ icoutput(struct ifnet *ifp, struct mbuf *m, /* already sending? */ if (sc->ic_sending) { - ifp->if_oerrors ++; + ifp->if_oerrors++; goto error; } @@ -403,7 +377,7 @@ icoutput(struct ifnet *ifp, struct mbuf *m, do { if (len + mm->m_len > sc->ic_ifp->if_mtu) { /* packet to large */ - ifp->if_oerrors ++; + ifp->if_oerrors++; goto error; } @@ -424,9 +398,9 @@ icoutput(struct ifnet *ifp, struct mbuf *m, if (iicbus_block_write(parent, sc->ic_addr, sc->ic_obuf, len + ICHDRLEN, &sent)) - ifp->if_oerrors ++; + ifp->if_oerrors++; else { - ifp->if_opackets ++; + ifp->if_opackets++; ifp->if_obytes += len; } |