Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/sys introduce usbnet_set_dying(). will be used by url(4...



details:   https://anonhg.NetBSD.org/src/rev/b95f46104257
branches:  trunk
changeset: 964724:b95f46104257
user:      mrg <mrg%NetBSD.org@localhost>
date:      Wed Aug 14 03:44:58 2019 +0000

description:
introduce usbnet_set_dying().  will be used by url(4) conversion.
bump version.

introduce USBNET_MODULE() that encompasses almost all the module
specific code for usbnet modules.  they still need to include
the relevant ioconf.c, but everything else is now just, eg,

        USBNET_MODULE(axen)

diffstat:

 sys/dev/usb/if_axe.c    |  34 ++-----------------------
 sys/dev/usb/if_axen.c   |  30 ++--------------------
 sys/dev/usb/if_cdce.c   |  21 +++++++++------
 sys/dev/usb/if_smsc.c   |  30 ++--------------------
 sys/dev/usb/if_udav.c   |  65 ++++++++++++------------------------------------
 sys/dev/usb/if_ure.c    |  12 +++++---
 sys/dev/usb/if_urndis.c |  14 ++++++---
 sys/dev/usb/usbnet.c    |  10 ++++++-
 sys/dev/usb/usbnet.h    |  39 ++++++++++++++++++++++++++++-
 sys/sys/param.h         |   4 +-
 10 files changed, 103 insertions(+), 156 deletions(-)

diffs (truncated from 568 to 300 lines):

diff -r f3cb4a0fd3ec -r b95f46104257 sys/dev/usb/if_axe.c
--- a/sys/dev/usb/if_axe.c      Wed Aug 14 01:42:08 2019 +0000
+++ b/sys/dev/usb/if_axe.c      Wed Aug 14 03:44:58 2019 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: if_axe.c,v 1.113 2019/08/11 23:55:43 mrg Exp $ */
+/*     $NetBSD: if_axe.c,v 1.114 2019/08/14 03:44:58 mrg Exp $ */
 /*     $OpenBSD: if_axe.c,v 1.137 2016/04/13 11:03:37 mpi Exp $ */
 
 /*
@@ -87,7 +87,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: if_axe.c,v 1.113 2019/08/11 23:55:43 mrg Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_axe.c,v 1.114 2019/08/14 03:44:58 mrg Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_usb.h"
@@ -95,11 +95,6 @@
 #endif
 
 #include <sys/param.h>
-#include <sys/kernel.h>
-#include <sys/module.h>
-#include <sys/socket.h>
-#include <sys/sockio.h>
-#include <sys/systm.h>
 
 #include <dev/usb/usbnet.h>
 #include <dev/usb/usbhist.h>
@@ -1391,31 +1386,8 @@
        usbnet_unlock_mii_un_locked(un);
 }
 
-MODULE(MODULE_CLASS_DRIVER, if_axe, "usbnet");
-
 #ifdef _MODULE
 #include "ioconf.c"
 #endif
 
-static int
-if_axe_modcmd(modcmd_t cmd, void *aux)
-{
-       int error = 0;
-
-       switch (cmd) {
-       case MODULE_CMD_INIT:
-#ifdef _MODULE
-               error = config_init_component(cfdriver_ioconf_axe,
-                   cfattach_ioconf_axe, cfdata_ioconf_axe);
-#endif
-               return error;
-       case MODULE_CMD_FINI:
-#ifdef _MODULE
-               error = config_fini_component(cfdriver_ioconf_axe,
-                   cfattach_ioconf_axe, cfdata_ioconf_axe);
-#endif
-               return error;
-       default:
-               return ENOTTY;
-       }
-}
+USBNET_MODULE(axe)
diff -r f3cb4a0fd3ec -r b95f46104257 sys/dev/usb/if_axen.c
--- a/sys/dev/usb/if_axen.c     Wed Aug 14 01:42:08 2019 +0000
+++ b/sys/dev/usb/if_axen.c     Wed Aug 14 03:44:58 2019 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: if_axen.c,v 1.62 2019/08/11 08:57:36 skrll Exp $       */
+/*     $NetBSD: if_axen.c,v 1.63 2019/08/14 03:44:58 mrg Exp $ */
 /*     $OpenBSD: if_axen.c,v 1.3 2013/10/21 10:10:22 yuo Exp $ */
 
 /*
@@ -23,14 +23,13 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: if_axen.c,v 1.62 2019/08/11 08:57:36 skrll Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_axen.c,v 1.63 2019/08/14 03:44:58 mrg Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_usb.h"
 #endif
 
 #include <sys/param.h>
-#include <sys/module.h>
 
 #include <netinet/in.h>                /* XXX for netinet/ip.h */
 #include <netinet/ip.h>                /* XXX for IP_MAXPACKET */
@@ -969,31 +968,8 @@
        usbnet_unlock_mii_un_locked(un);
 }
 
-MODULE(MODULE_CLASS_DRIVER, if_axen, "usbnet");
-
 #ifdef _MODULE
 #include "ioconf.c"
 #endif
 
-static int
-if_axen_modcmd(modcmd_t cmd, void *aux)
-{
-       int error = 0;
-
-       switch (cmd) {
-       case MODULE_CMD_INIT:
-#ifdef _MODULE
-               error = config_init_component(cfdriver_ioconf_axen,
-                   cfattach_ioconf_axen, cfdata_ioconf_axen);
-#endif
-               return error;
-       case MODULE_CMD_FINI:
-#ifdef _MODULE
-               error = config_fini_component(cfdriver_ioconf_axen,
-                   cfattach_ioconf_axen, cfdata_ioconf_axen);
-#endif
-               return error;
-       default:
-               return ENOTTY;
-       }
-}
+USBNET_MODULE(axen)
diff -r f3cb4a0fd3ec -r b95f46104257 sys/dev/usb/if_cdce.c
--- a/sys/dev/usb/if_cdce.c     Wed Aug 14 01:42:08 2019 +0000
+++ b/sys/dev/usb/if_cdce.c     Wed Aug 14 03:44:58 2019 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: if_cdce.c,v 1.64 2019/08/12 08:52:39 skrll Exp $ */
+/*     $NetBSD: if_cdce.c,v 1.65 2019/08/14 03:44:58 mrg Exp $ */
 
 /*
  * Copyright (c) 1997, 1998, 1999, 2000-2003 Bill Paul <wpaul%windriver.com@localhost>
@@ -40,10 +40,9 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: if_cdce.c,v 1.64 2019/08/12 08:52:39 skrll Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_cdce.c,v 1.65 2019/08/14 03:44:58 mrg Exp $");
 
 #include <sys/param.h>
-#include <sys/kernel.h>
 
 #include <dev/usb/usbnet.h>
 #include <dev/usb/usbcdc.h>
@@ -202,7 +201,7 @@
                }
                /* Find endpoints. */
                id = usbd_get_interface_descriptor(un->un_iface);
-               un->un_ed[USBNET_ENDPT_RX] = un->un_ed[USBNET_ENDPT_TX] = -1;
+               un->un_ed[USBNET_ENDPT_RX] = un->un_ed[USBNET_ENDPT_TX] = 0;
                for (i = 0; i < id->bNumEndpoints; i++) {
                        ed = usbd_interface2endpoint_descriptor(un->un_iface, i);
                        if (!ed) {
@@ -225,15 +224,15 @@
                        }
                }
                /* If we found something, try and use it... */
-               if (un->un_ed[USBNET_ENDPT_RX] != -1 && un->un_ed[USBNET_ENDPT_TX] != -1)
+               if (un->un_ed[USBNET_ENDPT_RX] != 0 && un->un_ed[USBNET_ENDPT_TX] != 0)
                        break;
        }
 
-       if (un->un_ed[USBNET_ENDPT_RX] == -1) {
+       if (un->un_ed[USBNET_ENDPT_RX] == 0) {
                aprint_error_dev(self, "could not find data bulk in\n");
                return;
        }
-       if (un->un_ed[USBNET_ENDPT_TX] == -1 ) {
+       if (un->un_ed[USBNET_ENDPT_TX] == 0) {
                aprint_error_dev(self, "could not find data bulk out\n");
                return;
        }
@@ -305,7 +304,7 @@
        if (un->un_flags & CDCE_ZAURUS)
                extra = sizeof(crc);
 
-       if (m->m_pkthdr.len > un->un_tx_bufsz - extra)
+       if ((unsigned)m->m_pkthdr.len > un->un_tx_bufsz - extra)
                return 0;
        length = m->m_pkthdr.len + extra;
 
@@ -317,3 +316,9 @@
 
        return length;
 }
+
+#ifdef _MODULE
+#include "ioconf.c"
+#endif
+
+USBNET_MODULE(cdce)
diff -r f3cb4a0fd3ec -r b95f46104257 sys/dev/usb/if_smsc.c
--- a/sys/dev/usb/if_smsc.c     Wed Aug 14 01:42:08 2019 +0000
+++ b/sys/dev/usb/if_smsc.c     Wed Aug 14 03:44:58 2019 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: if_smsc.c,v 1.56 2019/08/11 23:55:43 mrg Exp $ */
+/*     $NetBSD: if_smsc.c,v 1.57 2019/08/14 03:44:58 mrg Exp $ */
 
 /*     $OpenBSD: if_smsc.c,v 1.4 2012/09/27 12:38:11 jsg Exp $ */
 /*     $FreeBSD: src/sys/dev/usb/net/if_smsc.c,v 1.1 2012/08/15 04:03:55 gonzo Exp $ */
@@ -61,14 +61,13 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: if_smsc.c,v 1.56 2019/08/11 23:55:43 mrg Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_smsc.c,v 1.57 2019/08/14 03:44:58 mrg Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_usb.h"
 #endif
 
 #include <sys/param.h>
-#include <sys/module.h>
 
 #include <dev/usb/usbnet.h>
 #include <dev/usb/usbhist.h>
@@ -1107,31 +1106,8 @@
        return frm_len;
 }
 
-MODULE(MODULE_CLASS_DRIVER, if_smsc, "usbnet");
-
 #ifdef _MODULE
 #include "ioconf.c"
 #endif
 
-static int
-if_smsc_modcmd(modcmd_t cmd, void *aux)
-{
-       int error = 0;
-
-       switch (cmd) {
-       case MODULE_CMD_INIT:
-#ifdef _MODULE
-               error = config_init_component(cfdriver_ioconf_smsc,
-                   cfattach_ioconf_smsc, cfdata_ioconf_smsc);
-#endif
-               return error;
-       case MODULE_CMD_FINI:
-#ifdef _MODULE
-               error = config_fini_component(cfdriver_ioconf_smsc,
-                   cfattach_ioconf_smsc, cfdata_ioconf_smsc);
-#endif
-               return error;
-       default:
-               return ENOTTY;
-       }
-}
+USBNET_MODULE(smsc)
diff -r f3cb4a0fd3ec -r b95f46104257 sys/dev/usb/if_udav.c
--- a/sys/dev/usb/if_udav.c     Wed Aug 14 01:42:08 2019 +0000
+++ b/sys/dev/usb/if_udav.c     Wed Aug 14 03:44:58 2019 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: if_udav.c,v 1.66 2019/08/11 08:56:53 skrll Exp $       */
+/*     $NetBSD: if_udav.c,v 1.67 2019/08/14 03:44:58 mrg Exp $ */
 /*     $nabe: if_udav.c,v 1.3 2003/08/21 16:57:19 nabe Exp $   */
 
 /*
@@ -45,16 +45,13 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: if_udav.c,v 1.66 2019/08/11 08:56:53 skrll Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_udav.c,v 1.67 2019/08/14 03:44:58 mrg Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_usb.h"
 #endif
 
 #include <sys/param.h>
-#include <sys/systm.h>
-#include <sys/module.h>
-#include <sys/kernel.h>
 
 #include <dev/usb/usbnet.h>
 #include <dev/usb/if_udavreg.h>
@@ -468,19 +465,21 @@
 }
 
 static int
-udav_init_locked(struct ifnet *ifp)
+udav_init(struct ifnet *ifp)
 {
        struct usbnet * const un = ifp->if_softc;
        struct mii_data * const mii = usbnet_mii(un);
        uint8_t eaddr[ETHER_ADDR_LEN];
-       int rc;
+       int rc = 0;
 
        DPRINTF(("%s: %s: enter\n", device_xname(un->un_dev), __func__));
 
-       usbnet_isowned(un);
+       usbnet_lock(un);
 
-       if (usbnet_isdying(un))
+       if (usbnet_isdying(un)) {
+               usbnet_unlock(un);
                return EIO;
+       }
 
        /* Cancel pending I/O and free all TX/RX buffers */
        if (ifp->if_flags & IFF_RUNNING)



Home | Main Index | Thread Index | Old Index