summaryrefslogtreecommitdiff
path: root/sys/dev/usb/if_upgt.c
diff options
context:
space:
mode:
Diffstat (limited to 'sys/dev/usb/if_upgt.c')
-rw-r--r--sys/dev/usb/if_upgt.c29
1 files changed, 24 insertions, 5 deletions
diff --git a/sys/dev/usb/if_upgt.c b/sys/dev/usb/if_upgt.c
index 010b1315cee..e4b00b9d55e 100644
--- a/sys/dev/usb/if_upgt.c
+++ b/sys/dev/usb/if_upgt.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: if_upgt.c,v 1.25 2008/01/20 23:34:12 mglocker Exp $ */
+/* $OpenBSD: if_upgt.c,v 1.26 2008/01/21 19:37:36 mglocker Exp $ */
/*
* Copyright (c) 2007 Marcus Glocker <mglocker@openbsd.org>
@@ -81,7 +81,8 @@ int upgt_debug = 2;
*/
int upgt_match(struct device *, void *, void *);
void upgt_attach(struct device *, struct device *, void *);
-void upgt_attachhook(void *);
+void upgt_attach_hook(void *);
+void upgt_shutdown_hook(void *);
int upgt_detach(struct device *, int);
int upgt_activate(struct device *, enum devact);
@@ -280,9 +281,9 @@ upgt_attach(struct device *parent, struct device *self, void *aux)
* We need the firmware loaded to complete the attach.
*/
if (rootvp == NULL)
- mountroothook_establish(upgt_attachhook, sc);
+ mountroothook_establish(upgt_attach_hook, sc);
else
- upgt_attachhook(sc);
+ upgt_attach_hook(sc);
return;
fail:
@@ -290,7 +291,7 @@ fail:
}
void
-upgt_attachhook(void *arg)
+upgt_attach_hook(void *arg)
{
struct upgt_softc *sc = arg;
struct ieee80211com *ic = &sc->sc_ic;
@@ -423,6 +424,9 @@ upgt_attachhook(void *arg)
printf("%s: address %s\n",
sc->sc_dev.dv_xname, ether_sprintf(ic->ic_myaddr));
+ /* setup shutdown hook */
+ sc->sc_sdhook = shutdownhook_establish(upgt_shutdown_hook, sc);
+
/* device attached */
sc->sc_flags |= UPGT_DEVICE_ATTACHED;
@@ -431,6 +435,18 @@ fail:
printf("%s: %s failed!\n", sc->sc_dev.dv_xname, __func__);
}
+void
+upgt_shutdown_hook(void *arg)
+{
+ struct upgt_softc *sc = (struct upgt_softc *)arg;
+
+ DPRINTF(1, "%s: %s\n", sc->sc_dev.dv_xname, __func__);
+
+ /* reset device */
+ upgt_set_led(sc, UPGT_LED_OFF);
+ (void)upgt_device_init(sc);
+}
+
int
upgt_detach(struct device *self, int flags)
{
@@ -472,6 +488,9 @@ upgt_detach(struct device *self, int flags)
if_detach(ifp);
}
+ if (sc->sc_sdhook != NULL)
+ shutdownhook_disestablish(sc->sc_sdhook);
+
splx(s);
usbd_add_drv_event(USB_EVENT_DRIVER_DETACH, sc->sc_udev, &sc->sc_dev);