summaryrefslogtreecommitdiff
path: root/sys/dev
diff options
context:
space:
mode:
authorStuart Henderson <sthen@cvs.openbsd.org>2009-06-11 22:37:59 +0000
committerStuart Henderson <sthen@cvs.openbsd.org>2009-06-11 22:37:59 +0000
commit9d73584f5ddab153bf77106a93fa44717ed3183b (patch)
treec914c5474a48ffc5a1214b4d1cbb9f45f6ab459a /sys/dev
parente82928678ad29f95db507eed7988553cfb193f48 (diff)
Simplify the ioctl handling code. From Brad.
Tested by myself and Simon Kuhnle.
Diffstat (limited to 'sys/dev')
-rw-r--r--sys/dev/ic/hme.c58
-rw-r--r--sys/dev/ic/hmevar.h3
2 files changed, 14 insertions, 47 deletions
diff --git a/sys/dev/ic/hme.c b/sys/dev/ic/hme.c
index fb4bd9ab7d5..950ebef5cae 100644
--- a/sys/dev/ic/hme.c
+++ b/sys/dev/ic/hme.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: hme.c,v 1.56 2009/04/23 21:24:14 kettenis Exp $ */
+/* $OpenBSD: hme.c,v 1.57 2009/06/11 22:37:58 sthen Exp $ */
/* $NetBSD: hme.c,v 1.21 2001/07/07 15:59:37 thorpej Exp $ */
/*-
@@ -229,7 +229,6 @@ hme_config(sc)
ifp->if_watchdog = hme_watchdog;
ifp->if_flags =
IFF_BROADCAST | IFF_SIMPLEX | IFF_NOTRAILERS | IFF_MULTICAST;
- sc->sc_if_flags = ifp->if_flags;
IFQ_SET_READY(&ifp->if_snd);
ifp->if_capabilities = IFCAP_VLAN_MTU;
@@ -632,8 +631,8 @@ hme_init(sc)
ifp->if_flags |= IFF_RUNNING;
ifp->if_flags &= ~IFF_OACTIVE;
- sc->sc_if_flags = ifp->if_flags;
ifp->if_timer = 0;
+
hme_start(ifp);
}
@@ -1212,7 +1211,6 @@ hme_mii_statchg(dev)
v &= ~HME_MAC_TXCFG_FULLDPLX;
sc->sc_arpcom.ac_if.if_flags &= ~IFF_SIMPLEX;
}
- sc->sc_if_flags = sc->sc_arpcom.ac_if.if_flags;
bus_space_write_4(t, mac, HME_MACI_TXCFG, v);
}
@@ -1285,55 +1283,26 @@ hme_ioctl(ifp, cmd, data)
switch (cmd) {
case SIOCSIFADDR:
- switch (ifa->ifa_addr->sa_family) {
+ ifp->if_flags |= IFF_UP;
+ if (!(ifp->if_flags & IFF_RUNNING))
+ hme_init(sc);
#ifdef INET
- case AF_INET:
- if (ifp->if_flags & IFF_UP)
- hme_setladrf(sc);
- else {
- ifp->if_flags |= IFF_UP;
- hme_init(sc);
- }
+ if (ifa->ifa_addr->sa_family == AF_INET)
arp_ifinit(&sc->sc_arpcom, ifa);
- break;
#endif
- default:
- hme_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.
- */
- hme_stop(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.
- */
- hme_init(sc);
- } else if ((ifp->if_flags & IFF_UP) != 0) {
- /*
- * If setting debug or promiscuous mode, do not reset
- * the chip; for everything else, call hme_init()
- * which will trigger a reset.
- */
-#define RESETIGN (IFF_CANTCHANGE | IFF_DEBUG)
- if (ifp->if_flags == sc->sc_if_flags)
- break;
- if ((ifp->if_flags & (~RESETIGN))
- == (sc->sc_if_flags & (~RESETIGN)))
- hme_setladrf(sc);
+ if (ifp->if_flags & IFF_UP) {
+ if (ifp->if_flags & IFF_RUNNING)
+ error = ENETRESET;
else
hme_init(sc);
-#undef RESETIGN
+ } else {
+ if (ifp->if_flags & IFF_RUNNING)
+ hme_stop(sc);
}
+
#ifdef HMEDEBUG
sc->sc_debug = (ifp->if_flags & IFF_DEBUG) != 0 ? 1 : 0;
#endif
@@ -1354,7 +1323,6 @@ hme_ioctl(ifp, cmd, data)
error = 0;
}
- sc->sc_if_flags = ifp->if_flags;
splx(s);
return (error);
}
diff --git a/sys/dev/ic/hmevar.h b/sys/dev/ic/hmevar.h
index c5506600278..6194eafa0c8 100644
--- a/sys/dev/ic/hmevar.h
+++ b/sys/dev/ic/hmevar.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: hmevar.h,v 1.12 2009/04/17 20:20:18 kettenis Exp $ */
+/* $OpenBSD: hmevar.h,v 1.13 2009/06/11 22:37:58 sthen Exp $ */
/* $NetBSD: hmevar.h,v 1.6 2000/09/28 10:56:57 tsutsui Exp $ */
/*-
@@ -80,7 +80,6 @@ struct hme_softc {
int sc_debug;
void *sc_sh; /* shutdownhook cookie */
- short sc_if_flags;
/* Special hardware hooks */
void (*sc_hwreset)(struct hme_softc *);