Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/dev/usb Generate usb events on attach and detach.
details: https://anonhg.NetBSD.org/src/rev/71a8ed23ccb5
branches: trunk
changeset: 481598:71a8ed23ccb5
user: augustss <augustss%NetBSD.org@localhost>
date: Wed Feb 02 13:21:25 2000 +0000
description:
Generate usb events on attach and detach.
Clean up detach a little.
diffstat:
sys/dev/usb/if_kue.c | 63 +++++++++++++++++++++++++++++++++++----------------
1 files changed, 43 insertions(+), 20 deletions(-)
diffs (139 lines):
diff -r ca1e594bbdfd -r 71a8ed23ccb5 sys/dev/usb/if_kue.c
--- a/sys/dev/usb/if_kue.c Wed Feb 02 13:20:59 2000 +0000
+++ b/sys/dev/usb/if_kue.c Wed Feb 02 13:21:25 2000 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: if_kue.c,v 1.5 2000/02/01 22:53:14 thorpej Exp $ */
+/* $NetBSD: if_kue.c,v 1.6 2000/02/02 13:21:25 augustss Exp $ */
/*
* Copyright (c) 1997, 1998, 1999, 2000
* Bill Paul <wpaul%ee.columbia.edu@localhost>. All rights reserved.
@@ -99,6 +99,9 @@
#elif defined(__NetBSD__) || defined(__OpenBSD__)
#include <sys/device.h>
+#if NRND > 0
+#include <sys/rnd.h>
+#endif
#endif
@@ -695,45 +698,50 @@
bpfattach(&ifp->if_bpf, ifp, DLT_EN10MB,
sizeof(struct ether_header));
#endif
-#if RND > 0
+#if NRND > 0
rnd_attach_source(&sc->rnd_source, USBDEVNAME(sc->kue_dev),
RND_TYPE_NET, 0);
#endif
#endif /* __NetBSD__ */
splx(s);
+
+ usbd_add_drv_event(USB_EVENT_DRIVER_ATTACH, sc->kue_udev,
+ USBDEV(sc->kue_dev));
+
USB_ATTACH_SUCCESS_RETURN;
}
USB_DETACH(kue)
{
USB_DETACH_START(kue, sc);
- struct ifnet *ifp;
+ struct ifnet *ifp = GET_IFP(sc);
int s;
- s = splusb();
+ s = splusb(); /* XXX why? */
-#if defined(__FreeBSD__)
- sc = device_get_softc(dev);
+ if (ifp->if_flags & IFF_RUNNING)
+ kue_stop(sc);
+
+#if defined(__NetBSD__)
+#if NRND > 0
+ rnd_detach_source(&sc->rnd_source);
#endif
- ifp = GET_IFP(sc);
-
- if (ifp != NULL) {
-#if defined(__NetBSD__)
#if NBPFILTER > 0
- bpfdetach(ifp);
+ bpfdetach(ifp);
#endif
- ether_ifdetach(ifp);
+ ether_ifdetach(ifp);
#endif /* __NetBSD__ */
- if_detach(ifp);
- }
+
+ if_detach(ifp);
- if (sc->kue_ep[KUE_ENDPT_TX] != NULL)
- usbd_abort_pipe(sc->kue_ep[KUE_ENDPT_TX]);
- if (sc->kue_ep[KUE_ENDPT_RX] != NULL)
- usbd_abort_pipe(sc->kue_ep[KUE_ENDPT_RX]);
- if (sc->kue_ep[KUE_ENDPT_INTR] != NULL)
- usbd_abort_pipe(sc->kue_ep[KUE_ENDPT_INTR]);
+#ifdef DIAGNOSTIC
+ if (sc->kue_ep[KUE_ENDPT_TX] != NULL ||
+ sc->kue_ep[KUE_ENDPT_RX] != NULL ||
+ sc->kue_ep[KUE_ENDPT_INTR] != NULL)
+ printf("%s: detach has active endpoints\n",
+ USBDEVNAME(sc->kue_dev));
+#endif
if (sc->kue_mcfilters != NULL)
free(sc->kue_mcfilters, M_USBDEV);
@@ -913,6 +921,9 @@
DPRINTFN(10,("%s: %s: enter status=%d\n", USBDEVNAME(sc->kue_dev),
__FUNCTION__, status));
+ if (sc->kue_dying)
+ return;
+
if (!(ifp->if_flags & IFF_RUNNING))
return;
@@ -1022,6 +1033,9 @@
struct ifnet *ifp = GET_IFP(sc);
int s;
+ if (sc->kue_dying)
+ return;
+
s = splimp();
DPRINTFN(10,("%s: %s: enter status=%d\n", USBDEVNAME(sc->kue_dev),
@@ -1115,6 +1129,9 @@
DPRINTFN(10,("%s: %s: enter\n", USBDEVNAME(sc->kue_dev),__FUNCTION__));
+ if (sc->kue_dying)
+ return;
+
if (ifp->if_flags & IFF_OACTIVE)
return;
@@ -1272,6 +1289,9 @@
DPRINTFN(5,("%s: %s: enter\n", USBDEVNAME(sc->kue_dev),__FUNCTION__));
+ if (sc->kue_dying)
+ return (EIO);
+
s = splimp();
switch(command) {
@@ -1365,6 +1385,9 @@
DPRINTFN(5,("%s: %s: enter\n", USBDEVNAME(sc->kue_dev),__FUNCTION__));
+ if (sc->kue_dying)
+ return;
+
ifp->if_oerrors++;
printf("%s: watchdog timeout\n", USBDEVNAME(sc->kue_dev));
Home |
Main Index |
Thread Index |
Old Index