Some clean up to the cdce / cdcef and urndis ioctl handlers to bring things
in line with the other Ethernet drivers. no functional change.

OK?


Index: if_cdce.c
===================================================================
RCS file: /home/cvs/src/sys/dev/usb/if_cdce.c,v
retrieving revision 1.57
diff -u -p -r1.57 if_cdce.c
--- if_cdce.c   15 Nov 2013 10:17:39 -0000      1.57
+++ if_cdce.c   17 Nov 2013 05:31:47 -0000
@@ -528,23 +528,24 @@ cdce_ioctl(struct ifnet *ifp, u_long com
        switch(command) {
        case SIOCSIFADDR:
                ifp->if_flags |= IFF_UP;
-               cdce_init(sc);
-               switch (ifa->ifa_addr->sa_family) {
-               case AF_INET:
+               if (!(ifp->if_flags & IFF_RUNNING))
+                       cdce_init(sc);
+#ifdef INET
+               if (ifa->ifa_addr->sa_family == AF_INET)
                        arp_ifinit(&sc->cdce_arpcom, ifa);
-                       break;
-               }
+#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
                                cdce_init(sc);
                } else {
                        if (ifp->if_flags & IFF_RUNNING)
                                cdce_stop(sc);
                }
-               error = 0;
                break;
 
        default:
@@ -579,9 +580,6 @@ cdce_init(void *xsc)
        struct cdce_chain       *c;
        usbd_status              err;
        int                      s, i;
-
-       if (ifp->if_flags & IFF_RUNNING)
-               return;
 
        s = splnet();
 
Index: if_cdcef.c
===================================================================
RCS file: /home/cvs/src/sys/dev/usb/if_cdcef.c,v
retrieving revision 1.31
diff -u -p -r1.31 if_cdcef.c
--- if_cdcef.c  11 Nov 2013 10:09:40 -0000      1.31
+++ if_cdcef.c  20 Nov 2013 03:06:34 -0000
@@ -477,23 +477,24 @@ cdcef_ioctl(struct ifnet *ifp, u_long co
        switch (command) {
        case SIOCSIFADDR:
                ifp->if_flags |= IFF_UP;
-               cdcef_init(sc);
-               switch (ifa->ifa_addr->sa_family) {
-               case AF_INET:
+               if (!(ifp->if_flags & IFF_RUNNING))
+                       cdcef_init(sc);
+#ifdef INET
+               if (ifa->ifa_addr->sa_family == AF_INET)
                        arp_ifinit(&sc->sc_arpcom, ifa);
-                       break;
-               }
+#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
                                cdcef_init(sc);
                } else {
                        if (ifp->if_flags & IFF_RUNNING)
                                cdcef_stop(sc);
                }
-               error = 0;
                break;
 
        default:
@@ -528,10 +529,9 @@ cdcef_watchdog(struct ifnet *ifp)
 void
 cdcef_init(struct cdcef_softc *sc)
 {
-       int s;
        struct ifnet    *ifp = GET_IFP(sc);
-       if (ifp->if_flags & IFF_RUNNING)
-               return;
+       int s;
+
        s = splnet();
 
        ifp->if_flags |= IFF_RUNNING;
Index: if_urndis.c
===================================================================
RCS file: /home/cvs/src/sys/dev/usb/if_urndis.c,v
retrieving revision 1.43
diff -u -p -r1.43 if_urndis.c
--- if_urndis.c 15 Nov 2013 10:17:39 -0000      1.43
+++ if_urndis.c 20 Nov 2013 03:10:53 -0000
@@ -985,13 +985,9 @@ urndis_tx_list_init(struct urndis_softc 
 int
 urndis_ioctl(struct ifnet *ifp, u_long command, caddr_t data)
 {
-       struct urndis_softc     *sc;
-       struct ifaddr           *ifa;
-       int                      s, error;
-
-       sc = ifp->if_softc;
-       ifa = (struct ifaddr *)data;
-       error = 0;
+       struct urndis_softc     *sc = ifp->if_softc;
+       struct ifaddr           *ifa = (struct ifaddr *)data;
+       int                      s, error = 0;
 
        if (usbd_is_dying(sc->sc_udev))
                return (EIO);
@@ -1001,24 +997,24 @@ urndis_ioctl(struct ifnet *ifp, u_long c
        switch(command) {
        case SIOCSIFADDR:
                ifp->if_flags |= IFF_UP;
-               urndis_init(sc);
-
-               switch (ifa->ifa_addr->sa_family) {
-               case AF_INET:
+               if (!(ifp->if_flags & IFF_RUNNING))
+                       urndis_init(sc);
+#ifdef INET
+               if (ifa->ifa_addr->sa_family == AF_INET)
                        arp_ifinit(&sc->sc_arpcom, ifa);
-                       break;
-               }
+#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
                                urndis_init(sc);
                } else {
                        if (ifp->if_flags & IFF_RUNNING)
                                urndis_stop(sc);
                }
-               error = 0;
                break;
 
        default:
@@ -1054,14 +1050,9 @@ urndis_watchdog(struct ifnet *ifp)
 void
 urndis_init(struct urndis_softc *sc)
 {
-       struct ifnet            *ifp;
+       struct ifnet            *ifp = GET_IFP(sc);
        int                      i, s;
        usbd_status              err;
-
-
-       ifp = GET_IFP(sc);
-       if (ifp->if_flags & IFF_RUNNING)
-               return;
 
        if (urndis_ctrl_init(sc) != RNDIS_STATUS_SUCCESS)
                return;

-- 
This message has been scanned for viruses and
dangerous content by MailScanner, and is
believed to be clean.

Reply via email to