diff options
author | Brad Smith <brad@cvs.openbsd.org> | 2013-05-21 21:15:00 +0000 |
---|---|---|
committer | Brad Smith <brad@cvs.openbsd.org> | 2013-05-21 21:15:00 +0000 |
commit | 90b9e23a7e9a5621ea5871ec43824160851d0d45 (patch) | |
tree | 9ffa45075eb6648c3a1d2c4878201a511df26814 | |
parent | 62906cb5c88da1fcc1f2c8f0bbcbefedac674821 (diff) |
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; |