diff options
author | Brad Smith <brad@cvs.openbsd.org> | 2013-12-11 01:12:02 +0000 |
---|---|---|
committer | Brad Smith <brad@cvs.openbsd.org> | 2013-12-11 01:12:02 +0000 |
commit | fafa031d9f2892aedc48f4340d0dabe8fcb08da1 (patch) | |
tree | f361b8e9a07717c22e79ff545eb2d35e925e615e /sys | |
parent | 4f982ea8f879219b840214b398eb316a8c5b6e57 (diff) |
Clean up the ioctl handler to be in line with most of the other
Ethernet drivers.
ok sasano@
Diffstat (limited to 'sys')
-rw-r--r-- | sys/dev/usb/if_ugl.c | 36 |
1 files changed, 14 insertions, 22 deletions
diff --git a/sys/dev/usb/if_ugl.c b/sys/dev/usb/if_ugl.c index 281116ecaf1..4cc893941f1 100644 --- a/sys/dev/usb/if_ugl.c +++ b/sys/dev/usb/if_ugl.c @@ -1,4 +1,4 @@ -/* $OpenBSD: if_ugl.c,v 1.3 2013/12/05 20:53:15 sasano Exp $ */ +/* $OpenBSD: if_ugl.c,v 1.4 2013/12/11 01:12:01 brad Exp $ */ /* $NetBSD: if_upl.c,v 1.19 2002/07/11 21:14:26 augustss Exp $ */ /* * Copyright (c) 2013 SASANO Takayoshi <uaa@uaa.org.uk> @@ -298,6 +298,7 @@ ugl_attach(struct device *parent, struct device *self, void *aux) /* Initialize interface info.*/ ifp = GET_IFP(sc); ifp->if_softc = sc; + ifp->if_hardmtu = UGL_MAX_MTU; ifp->if_flags = IFF_BROADCAST | IFF_SIMPLEX | IFF_MULTICAST; ifp->if_ioctl = ugl_ioctl; ifp->if_start = ugl_start; @@ -710,9 +711,6 @@ ugl_init(void *xsc) DPRINTFN(10,("%s: %s: enter\n", sc->sc_dev.dv_xname,__func__)); - if (ifp->if_flags & IFF_RUNNING) - return; - s = splnet(); /* Init TX ring. */ @@ -830,7 +828,6 @@ ugl_ioctl(struct ifnet *ifp, u_long command, caddr_t data) { struct ugl_softc *sc = ifp->if_softc; struct ifaddr *ifa = (struct ifaddr *)data; - struct ifreq *ifr = (struct ifreq *)data; int s, error = 0; if (usbd_is_dying(sc->sc_udev)) @@ -844,39 +841,34 @@ ugl_ioctl(struct ifnet *ifp, u_long command, caddr_t data) switch(command) { case SIOCSIFADDR: ifp->if_flags |= IFF_UP; - ugl_init(sc); - - switch (ifa->ifa_addr->sa_family) { + if (!(ifp->if_flags & IFF_RUNNING)) + ugl_init(sc); #ifdef INET - case AF_INET: + if (ifa->ifa_addr->sa_family == AF_INET) arp_ifinit(&sc->sc_arpcom, ifa); - break; -#endif /* INET */ - } - break; - - case SIOCSIFMTU: - if (ifr->ifr_mtu > UGL_MAX_MTU) - error = EINVAL; - else - ifp->if_mtu = ifr->ifr_mtu; +#endif break; case SIOCSIFFLAGS: if (ifp->if_flags & IFF_UP) { - if (!(ifp->if_flags & IFF_RUNNING)) + if (ifp->if_flags & IFF_RUNNING) + error = ENETRESET; + else ugl_init(sc); } else { if (ifp->if_flags & IFF_RUNNING) ugl_stop(sc); } - error = 0; break; + default: - error = ENOTTY; + error = ether_ioctl(ifp, &sc->sc_arpcom, command, data); break; } + if (error == ENETRESET) + error = 0; + splx(s); return (error); } |