From: brad Date: Mon, 29 Dec 2014 02:33:13 +0000 (+0000) Subject: Some cleaning up of the ioctl handling bits to bring things in line X-Git-Url: http://artulab.com/gitweb/?a=commitdiff_plain;h=7fb16931aff7add0ba6075109ea2a75c04d32363;p=openbsd Some cleaning up of the ioctl handling bits to bring things in line with the other drivers. --- diff --git a/sys/dev/ic/elink3.c b/sys/dev/ic/elink3.c index 71b72788143..5dbc6bf35db 100644 --- a/sys/dev/ic/elink3.c +++ b/sys/dev/ic/elink3.c @@ -1,4 +1,4 @@ -/* $OpenBSD: elink3.c,v 1.81 2014/12/22 02:28:51 tedu Exp $ */ +/* $OpenBSD: elink3.c,v 1.82 2014/12/29 02:33:13 brad Exp $ */ /* $NetBSD: elink3.c,v 1.32 1997/05/14 00:22:00 thorpej Exp $ */ /* @@ -1440,48 +1440,29 @@ epioctl(struct ifnet *ifp, u_long cmd, caddr_t data) switch (cmd) { case SIOCSIFADDR: ifp->if_flags |= IFF_UP; - - switch (ifa->ifa_addr->sa_family) { - case AF_INET: + if (!(ifp->if_flags & IFF_RUNNING)) epinit(sc); + if (ifa->ifa_addr->sa_family == AF_INET) arp_ifinit(&sc->sc_arpcom, ifa); - break; - default: - epinit(sc); - break; - } break; + case SIOCSIFFLAGS: + if (ifp->if_flags & IFF_UP) { + if (ifp->if_flags & IFF_RUNNING) + error = ENETRESET; + else + epinit(sc); + } else { + if (ifp->if_flags & IFF_RUNNING) + epstop(sc); + } + break; + case SIOCSIFMEDIA: case SIOCGIFMEDIA: error = ifmedia_ioctl(ifp, ifr, &sc->sc_mii.mii_media, cmd); break; - case SIOCSIFFLAGS: - if ((ifp->if_flags & IFF_UP) == 0 && - (ifp->if_flags & IFF_RUNNING) != 0) { - /* - * If interface is marked down and it is running, then - * stop it. - */ - epstop(sc); - ifp->if_flags &= ~IFF_RUNNING; - } else if ((ifp->if_flags & IFF_UP) != 0 && - (ifp->if_flags & IFF_RUNNING) == 0) { - /* - * If interface is marked up and it is stopped, then - * start it. - */ - epinit(sc); - } else if ((ifp->if_flags & IFF_UP) != 0) { - /* - * Reset the interface to pick up changes in any other - * flags that affect hardware registers. - */ - epinit(sc); - } - break; - default: error = ether_ioctl(ifp, &sc->sc_arpcom, cmd, data); } @@ -1520,9 +1501,12 @@ epwatchdog(struct ifnet *ifp) void epstop(struct ep_softc *sc) { + struct ifnet *ifp = &sc->sc_arpcom.ac_if; bus_space_tag_t iot = sc->sc_iot; bus_space_handle_t ioh = sc->sc_ioh; + ifp->if_flags &= ~(IFF_RUNNING | IFF_OACTIVE); + if (sc->ep_flags & EP_FLAGS_MII) { mii_down(&sc->sc_mii); }