diff options
author | 2013-05-21 21:14:59 +0000 | |
---|---|---|
committer | 2013-05-21 21:14:59 +0000 | |
commit | c37efeca38b754b76ddd001fd82266a1c15fba66 (patch) | |
tree | 007c8b2a0ff19db308ddfce0e01dbb79e7796493 | |
parent | de-static-ize prototypes as well, which makes these functions not-static (diff) | |
download | wireguard-openbsd-c37efeca38b754b76ddd001fd82266a1c15fba66.tar.xz wireguard-openbsd-c37efeca38b754b76ddd001fd82266a1c15fba66.zip |
Rewrite ioctl handling bits.
ok sthen@
-rw-r--r-- | sys/dev/ic/dp8390.c | 58 |
1 files changed, 19 insertions, 39 deletions
diff --git a/sys/dev/ic/dp8390.c b/sys/dev/ic/dp8390.c index 5f8aa6697a2..2fa0d013526 100644 --- a/sys/dev/ic/dp8390.c +++ b/sys/dev/ic/dp8390.c @@ -1,4 +1,4 @@ -/* $OpenBSD: dp8390.c,v 1.43 2010/08/29 18:01:21 deraadt Exp $ */ +/* $OpenBSD: dp8390.c,v 1.44 2013/05/21 21:14:59 brad Exp $ */ /* $NetBSD: dp8390.c,v 1.13 1998/07/05 06:49:11 jonathan Exp $ */ /* @@ -805,9 +805,6 @@ dp8390_intr(void *arg) } } -/* - * Process an ioctl request. This code needs some work - it looks pretty ugly. - */ int dp8390_ioctl(struct ifnet *ifp, u_long cmd, caddr_t data) { @@ -823,46 +820,29 @@ dp8390_ioctl(struct ifnet *ifp, u_long cmd, caddr_t data) if ((error = dp8390_enable(sc)) != 0) break; ifp->if_flags |= IFF_UP; - - switch (ifa->ifa_addr->sa_family) { -#ifdef INET - case AF_INET: + if (!(ifp->if_flags & IFF_RUNNING)) dp8390_init(sc); +#ifdef INET + if (ifa->ifa_addr->sa_family == AF_INET) arp_ifinit(&sc->sc_arpcom, ifa); - break; #endif - default: - dp8390_init(sc); - break; - } 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. - */ - dp8390_stop(sc); - ifp->if_flags &= ~IFF_RUNNING; - dp8390_disable(sc); - } 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. - */ - if ((error = dp8390_enable(sc)) != 0) - break; - dp8390_init(sc); - } else if ((ifp->if_flags & IFF_UP) != 0) { - /* - * Reset the interface to pick up changes in any other - * flags that affect hardware registers. - */ - dp8390_stop(sc); - dp8390_init(sc); + if (ifp->if_flags & IFF_UP) { + if (ifp->if_flags & IFF_RUNNING) + error = ENETRESET; + else { + if ((error = dp8390_enable(sc)) != 0) + break; + dp8390_init(sc); + } + } else { + if (ifp->if_flags & IFF_RUNNING) { + dp8390_stop(sc); + ifp->if_flags &= ~IFF_RUNNING; + dp8390_disable(sc); + } } break; @@ -877,7 +857,7 @@ dp8390_ioctl(struct ifnet *ifp, u_long cmd, caddr_t data) if (error == ENETRESET) { if (ifp->if_flags & IFF_RUNNING) { - dp8390_stop(sc); /* XXX for ds_setmcaf? */ + dp8390_stop(sc); dp8390_init(sc); } error = 0; |