diff options
-rw-r--r-- | sys/dev/usb/if_atu.c | 67 | ||||
-rw-r--r-- | sys/dev/usb/if_atureg.h | 6 | ||||
-rw-r--r-- | sys/dev/usb/if_aue.c | 44 | ||||
-rw-r--r-- | sys/dev/usb/if_auereg.h | 4 | ||||
-rw-r--r-- | sys/dev/usb/if_axe.c | 31 | ||||
-rw-r--r-- | sys/dev/usb/if_axereg.h | 4 | ||||
-rw-r--r-- | sys/dev/usb/if_cue.c | 39 | ||||
-rw-r--r-- | sys/dev/usb/if_cuereg.h | 4 | ||||
-rw-r--r-- | sys/dev/usb/if_mos.c | 44 | ||||
-rw-r--r-- | sys/dev/usb/if_mosreg.h | 4 | ||||
-rw-r--r-- | sys/dev/usb/if_ral.c | 5 | ||||
-rw-r--r-- | sys/dev/usb/if_rum.c | 14 | ||||
-rw-r--r-- | sys/dev/usb/if_uath.c | 6 | ||||
-rw-r--r-- | sys/dev/usb/if_udav.c | 63 | ||||
-rw-r--r-- | sys/dev/usb/if_udavreg.h | 4 | ||||
-rw-r--r-- | sys/dev/usb/if_upgt.c | 8 | ||||
-rw-r--r-- | sys/dev/usb/if_upgtvar.h | 3 | ||||
-rw-r--r-- | sys/dev/usb/if_url.c | 67 | ||||
-rw-r--r-- | sys/dev/usb/if_urlreg.h | 4 | ||||
-rw-r--r-- | sys/dev/usb/if_urtw.c | 5 | ||||
-rw-r--r-- | sys/dev/usb/if_zyd.c | 5 | ||||
-rw-r--r-- | sys/dev/usb/udcf.c | 17 | ||||
-rw-r--r-- | sys/dev/usb/ueagle.c | 9 | ||||
-rw-r--r-- | sys/dev/usb/ueaglevar.h | 4 | ||||
-rw-r--r-- | sys/dev/usb/uhub.c | 6 | ||||
-rw-r--r-- | sys/dev/usb/umbg.c | 11 |
26 files changed, 214 insertions, 264 deletions
diff --git a/sys/dev/usb/if_atu.c b/sys/dev/usb/if_atu.c index c57953dfb70..eabe9665798 100644 --- a/sys/dev/usb/if_atu.c +++ b/sys/dev/usb/if_atu.c @@ -1,4 +1,4 @@ -/* $OpenBSD: if_atu.c,v 1.96 2010/10/27 17:51:11 jakemsr Exp $ */ +/* $OpenBSD: if_atu.c,v 1.97 2010/12/06 04:41:39 jakemsr Exp $ */ /* * Copyright (c) 2003, 2004 * Daan Vreeken <Danovitsch@Vitsch.net>. All rights reserved. @@ -902,7 +902,7 @@ atu_internal_firmware(void *arg) if (err != 0) { printf("%s: %s loadfirmware error %d\n", sc->atu_dev.dv_xname, name, err); - return; + goto fail; } ptr = firm; @@ -918,7 +918,7 @@ atu_internal_firmware(void *arg) DPRINTF(("%s: dfu_getstatus failed!\n", sc->atu_dev.dv_xname)); free(firm, M_DEVBUF); - return; + goto fail; } /* success means state => DnLoadIdle */ state = DFUState_DnLoadIdle; @@ -940,7 +940,7 @@ atu_internal_firmware(void *arg) DPRINTF(("%s: dfu_dnload failed\n", sc->atu_dev.dv_xname)); free(firm, M_DEVBUF); - return; + goto fail; } ptr += block_size; @@ -969,14 +969,14 @@ atu_internal_firmware(void *arg) if (err) { DPRINTF(("%s: dfu_getstatus failed!\n", sc->atu_dev.dv_xname)); - return; + goto fail; } DPRINTFN(15, ("%s: sending remap\n", sc->atu_dev.dv_xname)); err = atu_usb_request(sc, DFU_REMAP, 0, 0, 0, NULL); if ((err) && (!ISSET(sc->atu_quirk, ATU_QUIRK_NO_REMAP))) { DPRINTF(("%s: remap failed!\n", sc->atu_dev.dv_xname)); - return; + goto fail; } /* after a lot of trying and measuring I found out the device needs @@ -989,6 +989,9 @@ atu_internal_firmware(void *arg) printf("%s: reattaching after firmware upload\n", sc->atu_dev.dv_xname); usb_needs_reattach(sc->atu_udev); + +fail: + usbd_deactivate(sc->atu_udev); } void @@ -1169,7 +1172,7 @@ atu_task(void *arg) DPRINTFN(10, ("%s: atu_task\n", sc->atu_dev.dv_xname)); - if (sc->sc_state != ATU_S_OK) + if (usbd_is_dying(sc->atu_udev)) return; switch (sc->sc_cmd) { @@ -1259,25 +1262,23 @@ atu_attach(struct device *parent, struct device *self, void *aux) u_int8_t mode, channel; int i; - sc->sc_state = ATU_S_UNCONFIG; + sc->atu_unit = self->dv_unit; + sc->atu_udev = dev; err = usbd_set_config_no(dev, ATU_CONFIG_NO, 1); if (err) { printf("%s: setting config no failed\n", sc->atu_dev.dv_xname); - return; + goto fail; } err = usbd_device2interface_handle(dev, ATU_IFACE_IDX, &sc->atu_iface); if (err) { printf("%s: getting interface handle failed\n", sc->atu_dev.dv_xname); - return; + goto fail; } - sc->atu_unit = self->dv_unit; - sc->atu_udev = dev; - /* * look up the radio_type for the device * basically does the same as USB_MATCH @@ -1361,6 +1362,8 @@ atu_attach(struct device *parent, struct device *self, void *aux) /* all the firmwares are in place, so complete the attach */ atu_complete_attach(sc); } +fail: + usbd_deactivate(sc->atu_udev); } void @@ -1386,7 +1389,7 @@ atu_complete_attach(struct atu_softc *sc) sc->atu_iface->idesc->bNumEndpoints)); DPRINTF(("%s: couldn't get ep %d\n", sc->atu_dev.dv_xname, i)); - return; + goto fail; } if (UE_GET_DIR(ed->bEndpointAddress) == UE_DIR_IN && UE_GET_XFERTYPE(ed->bmAttributes) == UE_BULK) { @@ -1402,7 +1405,7 @@ atu_complete_attach(struct atu_softc *sc) if (err) { printf("%s: could not get card cfg!\n", sc->atu_dev.dv_xname); - return; + goto fail; } #ifdef ATU_DEBUG @@ -1482,7 +1485,8 @@ atu_complete_attach(struct atu_softc *sc) sc->sc_txtap.rt_ihdr.it_present = htole32(ATU_TX_RADIOTAP_PRESENT); #endif - sc->sc_state = ATU_S_OK; +fail: + usbd_deactivate(sc->atu_udev); } int @@ -1491,23 +1495,21 @@ atu_detach(struct device *self, int flags) struct atu_softc *sc = (struct atu_softc *)self; struct ifnet *ifp = &sc->sc_ic.ic_if; - DPRINTFN(10, ("%s: atu_detach state=%d\n", sc->atu_dev.dv_xname, - sc->sc_state)); + DPRINTFN(10, ("%s: atu_detach\n", sc->atu_dev.dv_xname)); - if (sc->sc_state != ATU_S_UNCONFIG) { + if (ifp->if_flags & IFF_RUNNING) atu_stop(ifp, 1); - usb_rem_task(sc->atu_udev, &sc->sc_task); + usb_rem_task(sc->atu_udev, &sc->sc_task); - if (sc->atu_ep[ATU_ENDPT_TX] != NULL) - usbd_abort_pipe(sc->atu_ep[ATU_ENDPT_TX]); - if (sc->atu_ep[ATU_ENDPT_RX] != NULL) - usbd_abort_pipe(sc->atu_ep[ATU_ENDPT_RX]); + if (sc->atu_ep[ATU_ENDPT_TX] != NULL) + usbd_abort_pipe(sc->atu_ep[ATU_ENDPT_TX]); + if (sc->atu_ep[ATU_ENDPT_RX] != NULL) + usbd_abort_pipe(sc->atu_ep[ATU_ENDPT_RX]); - if (ifp->if_softc != NULL) { - ieee80211_ifdetach(ifp); - if_detach(ifp); - } + if (ifp->if_softc != NULL) { + ieee80211_ifdetach(ifp); + if_detach(ifp); } return(0); @@ -1522,8 +1524,7 @@ atu_activate(struct device *self, int act) case DVACT_ACTIVATE: break; case DVACT_DEACTIVATE: - if (sc->sc_state != ATU_S_UNCONFIG) - sc->sc_state = ATU_S_DEAD; + usbd_deactivate(sc->atu_udev); break; } return (0); @@ -1665,7 +1666,7 @@ atu_rxeof(usbd_xfer_handle xfer, usbd_private_handle priv, usbd_status status) DPRINTFN(25, ("%s: atu_rxeof\n", sc->atu_dev.dv_xname)); - if (sc->sc_state != ATU_S_OK) + if (usbd_is_dying(sc->atu_udev)) return; if ((ifp->if_flags & (IFF_RUNNING|IFF_UP)) != (IFF_RUNNING|IFF_UP)) @@ -1859,7 +1860,7 @@ atu_tx_start(struct atu_softc *sc, struct ieee80211_node *ni, DPRINTFN(25, ("%s: atu_tx_start\n", sc->atu_dev.dv_xname)); /* Don't try to send when we're shutting down the driver */ - if (sc->sc_state != ATU_S_OK) { + if (usbd_is_dying(sc->atu_udev)) { m_freem(m); return(EIO); } @@ -2256,7 +2257,7 @@ atu_watchdog(struct ifnet *ifp) if ((ifp->if_flags & (IFF_RUNNING|IFF_UP)) != (IFF_RUNNING|IFF_UP)) return; - if (sc->sc_state != ATU_S_OK) + if (usbd_is_dying(sc->atu_udev)) return; sc = ifp->if_softc; diff --git a/sys/dev/usb/if_atureg.h b/sys/dev/usb/if_atureg.h index f0e885d2a9b..a8d6c724873 100644 --- a/sys/dev/usb/if_atureg.h +++ b/sys/dev/usb/if_atureg.h @@ -1,4 +1,4 @@ -/* $OpenBSD: if_atureg.h,v 1.31 2007/11/27 16:22:13 martynas Exp $ */ +/* $OpenBSD: if_atureg.h,v 1.32 2010/12/06 04:41:39 jakemsr Exp $ */ /* * Copyright (c) 2003 * Daan Vreeken <Danovitsch@Vitsch.net>. All rights reserved. @@ -173,10 +173,6 @@ struct atu_softc { int (*sc_newstate)(struct ieee80211com *, enum ieee80211_state, int); - char sc_state; -#define ATU_S_DEAD 0 -#define ATU_S_OK 1 -#define ATU_S_UNCONFIG 2 char sc_cmd; #define ATU_C_NONE 0 #define ATU_C_SCAN 1 diff --git a/sys/dev/usb/if_aue.c b/sys/dev/usb/if_aue.c index babfa422240..3b4ec433d84 100644 --- a/sys/dev/usb/if_aue.c +++ b/sys/dev/usb/if_aue.c @@ -1,4 +1,4 @@ -/* $OpenBSD: if_aue.c,v 1.82 2010/10/27 17:51:11 jakemsr Exp $ */ +/* $OpenBSD: if_aue.c,v 1.83 2010/12/06 04:41:39 jakemsr Exp $ */ /* $NetBSD: if_aue.c,v 1.82 2003/03/05 17:37:36 shiba Exp $ */ /* * Copyright (c) 1997, 1998, 1999, 2000 @@ -277,7 +277,7 @@ aue_csr_read_1(struct aue_softc *sc, int reg) usbd_status err; uByte val = 0; - if (sc->aue_dying) + if (usbd_is_dying(sc->aue_udev)) return (0); req.bmRequestType = UT_READ_VENDOR_DEVICE; @@ -304,7 +304,7 @@ aue_csr_read_2(struct aue_softc *sc, int reg) usbd_status err; uWord val; - if (sc->aue_dying) + if (usbd_is_dying(sc->aue_udev)) return (0); req.bmRequestType = UT_READ_VENDOR_DEVICE; @@ -331,7 +331,7 @@ aue_csr_write_1(struct aue_softc *sc, int reg, int aval) usbd_status err; uByte val; - if (sc->aue_dying) + if (usbd_is_dying(sc->aue_udev)) return (0); val = aval; @@ -359,7 +359,7 @@ aue_csr_write_2(struct aue_softc *sc, int reg, int aval) usbd_status err; uWord val; - if (sc->aue_dying) + if (usbd_is_dying(sc->aue_udev)) return (0); USETW(val, aval); @@ -446,7 +446,7 @@ aue_miibus_readreg(struct device *dev, int phy, int reg) int i; u_int16_t val; - if (sc->aue_dying) { + if (usbd_is_dying(sc->aue_udev)) { #ifdef DIAGNOSTIC printf("%s: dying\n", sc->aue_dev.dv_xname); #endif @@ -557,7 +557,7 @@ aue_miibus_statchg(struct device *dev) * This turns on the 'dual link LED' bin in the auxmode * register of the Broadcom PHY. */ - if (!sc->aue_dying && (sc->aue_flags & LSYS)) { + if (!usbd_is_dying(sc->aue_udev) && (sc->aue_flags & LSYS)) { u_int16_t auxmode; auxmode = aue_miibus_readreg(dev, 0, 0x1b); aue_miibus_writereg(dev, 0, 0x1b, auxmode | 0x04); @@ -727,6 +727,8 @@ aue_attach(struct device *parent, struct device *self, void *aux) DPRINTFN(5,(" : aue_attach: sc=%p", sc)); + sc->aue_udev = dev; + err = usbd_set_config_no(dev, AUE_CONFIG_NO, 1); if (err) { printf("%s: setting config no failed\n", @@ -749,7 +751,6 @@ aue_attach(struct device *parent, struct device *self, void *aux) sc->aue_flags = aue_lookup(uaa->vendor, uaa->product)->aue_flags; - sc->aue_udev = dev; sc->aue_iface = iface; sc->aue_product = uaa->product; sc->aue_vendor = uaa->vendor; @@ -835,7 +836,6 @@ aue_attach(struct device *parent, struct device *self, void *aux) timeout_set(&sc->aue_stat_ch, aue_tick, sc); - sc->aue_attached = 1; splx(s); usbd_add_drv_event(USB_EVENT_DRIVER_ATTACH, sc->aue_udev, @@ -851,10 +851,6 @@ aue_detach(struct device *self, int flags) DPRINTFN(2,("%s: %s: enter\n", sc->aue_dev.dv_xname, __func__)); - /* Detached before attached finished, so just bail out. */ - if (!sc->aue_attached) - return (0); - if (timeout_initialized(&sc->aue_stat_ch)) timeout_del(&sc->aue_stat_ch); @@ -885,8 +881,6 @@ aue_detach(struct device *self, int flags) sc->aue_dev.dv_xname); #endif - sc->aue_attached = 0; - if (--sc->aue_refcnt >= 0) { /* Wait for processes to go away. */ usb_detach_wait(&sc->aue_dev); @@ -911,7 +905,7 @@ aue_activate(struct device *self, int act) break; case DVACT_DEACTIVATE: - sc->aue_dying = 1; + usbd_deactivate(sc->aue_udev); break; } return (0); @@ -1021,7 +1015,7 @@ aue_intr(usbd_xfer_handle xfer, usbd_private_handle priv, usbd_status status) DPRINTFN(15,("%s: %s: enter\n", sc->aue_dev.dv_xname,__func__)); - if (sc->aue_dying) + if (usbd_is_dying(sc->aue_udev)) return; if (!(ifp->if_flags & IFF_RUNNING)) @@ -1067,7 +1061,7 @@ aue_rxeof(usbd_xfer_handle xfer, usbd_private_handle priv, usbd_status status) DPRINTFN(10,("%s: %s: enter\n", sc->aue_dev.dv_xname,__func__)); - if (sc->aue_dying) + if (usbd_is_dying(sc->aue_udev)) return; if (!(ifp->if_flags & IFF_RUNNING)) @@ -1165,7 +1159,7 @@ aue_txeof(usbd_xfer_handle xfer, usbd_private_handle priv, usbd_status status) struct ifnet *ifp = GET_IFP(sc); int s; - if (sc->aue_dying) + if (usbd_is_dying(sc->aue_udev)) return; s = splnet(); @@ -1211,7 +1205,7 @@ aue_tick(void *xsc) if (sc == NULL) return; - if (sc->aue_dying) + if (usbd_is_dying(sc->aue_udev)) return; /* Perform periodic stuff in process context. */ @@ -1228,7 +1222,7 @@ aue_tick_task(void *xsc) DPRINTFN(15,("%s: %s: enter\n", sc->aue_dev.dv_xname,__func__)); - if (sc->aue_dying) + if (usbd_is_dying(sc->aue_udev)) return; ifp = GET_IFP(sc); @@ -1311,7 +1305,7 @@ aue_start(struct ifnet *ifp) DPRINTFN(5,("%s: %s: enter, link=%d\n", sc->aue_dev.dv_xname, __func__, sc->aue_link)); - if (sc->aue_dying) + if (usbd_is_dying(sc->aue_udev)) return; if (!sc->aue_link) @@ -1359,7 +1353,7 @@ aue_init(void *xsc) DPRINTFN(5,("%s: %s: enter\n", sc->aue_dev.dv_xname, __func__)); - if (sc->aue_dying) + if (usbd_is_dying(sc->aue_udev)) return; if (ifp->if_flags & IFF_RUNNING) @@ -1479,7 +1473,7 @@ aue_ifmedia_upd(struct ifnet *ifp) DPRINTFN(5,("%s: %s: enter\n", sc->aue_dev.dv_xname, __func__)); - if (sc->aue_dying) + if (usbd_is_dying(sc->aue_udev)) return (0); sc->aue_link = 0; @@ -1519,7 +1513,7 @@ aue_ioctl(struct ifnet *ifp, u_long command, caddr_t data) struct mii_data *mii; int s, error = 0; - if (sc->aue_dying) + if (usbd_is_dying(sc->aue_udev)) return (EIO); s = splnet(); diff --git a/sys/dev/usb/if_auereg.h b/sys/dev/usb/if_auereg.h index ffcec2231e4..ab5a0dc886a 100644 --- a/sys/dev/usb/if_auereg.h +++ b/sys/dev/usb/if_auereg.h @@ -1,4 +1,4 @@ -/* $OpenBSD: if_auereg.h,v 1.14 2009/08/10 20:02:19 deraadt Exp $ */ +/* $OpenBSD: if_auereg.h,v 1.15 2010/12/06 04:41:39 jakemsr Exp $ */ /* $NetBSD: if_auereg.h,v 1.16 2001/10/10 02:14:17 augustss Exp $ */ /* * Copyright (c) 1997, 1998, 1999 @@ -247,8 +247,6 @@ struct aue_softc { u_int16_t aue_flags; int aue_refcnt; - char aue_dying; - char aue_attached; u_int aue_rx_errs; u_int aue_intr_errs; struct timeval aue_rx_notice; diff --git a/sys/dev/usb/if_axe.c b/sys/dev/usb/if_axe.c index 13a94acb8c0..9420b0376c1 100644 --- a/sys/dev/usb/if_axe.c +++ b/sys/dev/usb/if_axe.c @@ -1,4 +1,4 @@ -/* $OpenBSD: if_axe.c,v 1.103 2010/11/14 20:38:43 weerd Exp $ */ +/* $OpenBSD: if_axe.c,v 1.104 2010/12/06 04:41:39 jakemsr Exp $ */ /* * Copyright (c) 2005, 2006, 2007 Jonathan Gray <jsg@openbsd.org> @@ -244,7 +244,7 @@ axe_cmd(struct axe_softc *sc, int cmd, int index, int val, void *buf) usb_device_request_t req; usbd_status err; - if (sc->axe_dying) + if (usbd_is_dying(sc->axe_udev)) return(0); if (AXE_CMD_DIR(cmd)) @@ -274,7 +274,7 @@ axe_miibus_readreg(struct device *dev, int phy, int reg) uWord val; int ival; - if (sc->axe_dying) { + if (usbd_is_dying(sc->axe_udev)) { DPRINTF(("axe: dying\n")); return(0); } @@ -332,7 +332,7 @@ axe_miibus_writereg(struct device *dev, int phy, int reg, int val) usbd_status err; uWord uval; - if (sc->axe_dying) + if (usbd_is_dying(sc->axe_udev)) return; if (sc->axe_phyno != phy) return; @@ -465,7 +465,7 @@ axe_setmulti(struct axe_softc *sc) u_int16_t rxmode; u_int8_t hashtbl[8] = { 0, 0, 0, 0, 0, 0, 0, 0 }; - if (sc->axe_dying) + if (usbd_is_dying(sc->axe_udev)) return; ifp = GET_IFP(sc); @@ -502,7 +502,7 @@ allmulti: void axe_reset(struct axe_softc *sc) { - if (sc->axe_dying) + if (usbd_is_dying(sc->axe_udev)) return; /* XXX What to reset? */ @@ -666,6 +666,7 @@ axe_attach(struct device *parent, struct device *self, void *aux) int i, s; sc->axe_unit = self->dv_unit; /*device_get_unit(self);*/ + sc->axe_udev = dev; err = usbd_set_config_no(dev, AXE_CONFIG_NO, 1); if (err) { @@ -689,7 +690,6 @@ axe_attach(struct device *parent, struct device *self, void *aux) return; } - sc->axe_udev = dev; sc->axe_product = uaa->product; sc->axe_vendor = uaa->vendor; @@ -813,7 +813,6 @@ axe_attach(struct device *parent, struct device *self, void *aux) timeout_set(&sc->axe_stat_ch, axe_tick, sc); - sc->axe_attached = 1; splx(s); usbd_add_drv_event(USB_EVENT_DRIVER_ATTACH, sc->axe_udev, @@ -829,10 +828,6 @@ axe_detach(struct device *self, int flags) DPRINTFN(2,("%s: %s: enter\n", sc->axe_dev.dv_xname, __func__)); - /* Detached before attached finished, so just bail out. */ - if (!sc->axe_attached) - return (0); - if (timeout_initialized(&sc->axe_stat_ch)) timeout_del(&sc->axe_stat_ch); @@ -875,8 +870,6 @@ axe_detach(struct device *self, int flags) sc->axe_dev.dv_xname); #endif - sc->axe_attached = 0; - if (--sc->axe_refcnt >= 0) { /* Wait for processes to go away. */ usb_detach_wait(&sc->axe_dev); @@ -901,7 +894,7 @@ axe_activate(struct device *self, int act) break; case DVACT_DEACTIVATE: - sc->axe_dying = 1; + usbd_deactivate(sc->axe_udev); break; } return (0); @@ -1009,7 +1002,7 @@ axe_rxeof(usbd_xfer_handle xfer, usbd_private_handle priv, usbd_status status) DPRINTFN(10,("%s: %s: enter\n", sc->axe_dev.dv_xname,__func__)); - if (sc->axe_dying) + if (usbd_is_dying(sc->axe_udev)) return; if (!(ifp->if_flags & IFF_RUNNING)) @@ -1122,7 +1115,7 @@ axe_txeof(usbd_xfer_handle xfer, usbd_private_handle priv, usbd_status status) sc = c->axe_sc; ifp = &sc->arpcom.ac_if; - if (sc->axe_dying) + if (usbd_is_dying(sc->axe_udev)) return; s = splnet(); @@ -1166,7 +1159,7 @@ axe_tick(void *xsc) DPRINTFN(0xff, ("%s: %s: enter\n", sc->axe_dev.dv_xname, __func__)); - if (sc->axe_dying) + if (usbd_is_dying(sc->axe_udev)) return; /* Perform periodic stuff in process context */ @@ -1187,7 +1180,7 @@ axe_tick_task(void *xsc) if (sc == NULL) return; - if (sc->axe_dying) + if (usbd_is_dying(sc->axe_udev)) return; ifp = GET_IFP(sc); diff --git a/sys/dev/usb/if_axereg.h b/sys/dev/usb/if_axereg.h index 47e1a488f8b..7e8ecab44f4 100644 --- a/sys/dev/usb/if_axereg.h +++ b/sys/dev/usb/if_axereg.h @@ -1,4 +1,4 @@ -/* $OpenBSD: if_axereg.h,v 1.19 2010/09/21 08:02:49 jsg Exp $ */ +/* $OpenBSD: if_axereg.h,v 1.20 2010/12/06 04:41:39 jakemsr Exp $ */ /* * Copyright (c) 1997, 1998, 1999, 2000-2003 @@ -226,8 +226,6 @@ struct axe_softc { struct timeout axe_stat_ch; int axe_refcnt; - char axe_dying; - char axe_attached; struct usb_task axe_tick_task; struct usb_task axe_stop_task; diff --git a/sys/dev/usb/if_cue.c b/sys/dev/usb/if_cue.c index 645031c1e82..401c775544b 100644 --- a/sys/dev/usb/if_cue.c +++ b/sys/dev/usb/if_cue.c @@ -1,4 +1,4 @@ -/* $OpenBSD: if_cue.c,v 1.56 2010/10/27 17:51:11 jakemsr Exp $ */ +/* $OpenBSD: if_cue.c,v 1.57 2010/12/06 04:41:39 jakemsr Exp $ */ /* $NetBSD: if_cue.c,v 1.40 2002/07/11 21:14:26 augustss Exp $ */ /* * Copyright (c) 1997, 1998, 1999, 2000 @@ -166,7 +166,7 @@ cue_csr_read_1(struct cue_softc *sc, int reg) usbd_status err; u_int8_t val = 0; - if (sc->cue_dying) + if (usbd_is_dying(sc->cue_udev)) return (0); req.bmRequestType = UT_READ_VENDOR_DEVICE; @@ -196,7 +196,7 @@ cue_csr_read_2(struct cue_softc *sc, int reg) usbd_status err; uWord val; - if (sc->cue_dying) + if (usbd_is_dying(sc->cue_udev)) return (0); req.bmRequestType = UT_READ_VENDOR_DEVICE; @@ -225,7 +225,7 @@ cue_csr_write_1(struct cue_softc *sc, int reg, int val) usb_device_request_t req; usbd_status err; - if (sc->cue_dying) + if (usbd_is_dying(sc->cue_udev)) return (0); DPRINTFN(10,("%s: cue_csr_write_1 reg=0x%x val=0x%x\n", @@ -260,7 +260,7 @@ cue_csr_write_2(struct cue_softc *sc, int reg, int aval) uWord val; int s; - if (sc->cue_dying) + if (usbd_is_dying(sc->cue_udev)) return (0); DPRINTFN(10,("%s: cue_csr_write_2 reg=0x%x val=0x%x\n", @@ -405,7 +405,7 @@ cue_reset(struct cue_softc *sc) DPRINTFN(2,("%s: cue_reset\n", sc->cue_dev.dv_xname)); - if (sc->cue_dying) + if (usbd_is_dying(sc->cue_udev)) return; req.bmRequestType = UT_WRITE_VENDOR_DEVICE; @@ -459,6 +459,8 @@ cue_attach(struct device *parent, struct device *self, void *aux) DPRINTFN(5,(" : cue_attach: sc=%p, dev=%p", sc, dev)); + sc->cue_udev = dev; + err = usbd_set_config_no(dev, CUE_CONFIG_NO, 1); if (err) { printf("%s: setting config no failed\n", @@ -466,7 +468,6 @@ cue_attach(struct device *parent, struct device *self, void *aux) return; } - sc->cue_udev = dev; sc->cue_product = uaa->product; sc->cue_vendor = uaa->vendor; @@ -541,7 +542,6 @@ cue_attach(struct device *parent, struct device *self, void *aux) timeout_set(&sc->cue_stat_ch, cue_tick, sc); - sc->cue_attached = 1; splx(s); usbd_add_drv_event(USB_EVENT_DRIVER_ATTACH, sc->cue_udev, @@ -557,10 +557,6 @@ cue_detach(struct device *self, int flags) DPRINTFN(2,("%s: %s: enter\n", sc->cue_dev.dv_xname, __func__)); - /* Detached before attached finished, so just bail out. */ - if (!sc->cue_attached) - return (0); - if (timeout_initialized(&sc->cue_stat_ch)) timeout_del(&sc->cue_stat_ch); @@ -589,7 +585,6 @@ cue_detach(struct device *self, int flags) sc->cue_dev.dv_xname); #endif - sc->cue_attached = 0; splx(s); usbd_add_drv_event(USB_EVENT_DRIVER_DETACH, sc->cue_udev, @@ -610,7 +605,7 @@ cue_activate(struct device *self, int act) break; case DVACT_DEACTIVATE: - sc->cue_dying = 1; + usbd_deactivate(sc->cue_udev); break; } return (0); @@ -727,7 +722,7 @@ cue_rxeof(usbd_xfer_handle xfer, usbd_private_handle priv, usbd_status status) DPRINTFN(10,("%s: %s: enter status=%d\n", sc->cue_dev.dv_xname, __func__, status)); - if (sc->cue_dying) + if (usbd_is_dying(sc->cue_udev)) return; if (!(ifp->if_flags & IFF_RUNNING)) @@ -817,7 +812,7 @@ cue_txeof(usbd_xfer_handle xfer, usbd_private_handle priv, usbd_status status) struct ifnet *ifp = GET_IFP(sc); int s; - if (sc->cue_dying) + if (usbd_is_dying(sc->cue_udev)) return; s = splnet(); @@ -861,7 +856,7 @@ cue_tick(void *xsc) if (sc == NULL) return; - if (sc->cue_dying) + if (usbd_is_dying(sc->cue_udev)) return; DPRINTFN(2,("%s: %s: enter\n", sc->cue_dev.dv_xname, __func__)); @@ -876,7 +871,7 @@ cue_tick_task(void *xsc) struct cue_softc *sc = xsc; struct ifnet *ifp; - if (sc->cue_dying) + if (usbd_is_dying(sc->cue_udev)) return; DPRINTFN(2,("%s: %s: enter\n", sc->cue_dev.dv_xname, __func__)); @@ -941,7 +936,7 @@ cue_start(struct ifnet *ifp) struct cue_softc *sc = ifp->if_softc; struct mbuf *m_head = NULL; - if (sc->cue_dying) + if (usbd_is_dying(sc->cue_udev)) return; DPRINTFN(10,("%s: %s: enter\n", sc->cue_dev.dv_xname,__func__)); @@ -985,7 +980,7 @@ cue_init(void *xsc) int i, s, ctl; u_char *eaddr; - if (sc->cue_dying) + if (usbd_is_dying(sc->cue_udev)) return; DPRINTFN(10,("%s: %s: enter\n", sc->cue_dev.dv_xname,__func__)); @@ -1106,7 +1101,7 @@ cue_ioctl(struct ifnet *ifp, u_long command, caddr_t data) struct ifaddr *ifa = (struct ifaddr *)data; int s, error = 0; - if (sc->cue_dying) + if (usbd_is_dying(sc->cue_udev)) return (EIO); s = splnet(); @@ -1171,7 +1166,7 @@ cue_watchdog(struct ifnet *ifp) DPRINTFN(5,("%s: %s: enter\n", sc->cue_dev.dv_xname,__func__)); - if (sc->cue_dying) + if (usbd_is_dying(sc->cue_udev)) return; ifp->if_oerrors++; diff --git a/sys/dev/usb/if_cuereg.h b/sys/dev/usb/if_cuereg.h index 7c344676ede..914f67db92d 100644 --- a/sys/dev/usb/if_cuereg.h +++ b/sys/dev/usb/if_cuereg.h @@ -1,4 +1,4 @@ -/* $OpenBSD: if_cuereg.h,v 1.10 2007/06/10 10:15:35 mbalmer Exp $ */ +/* $OpenBSD: if_cuereg.h,v 1.11 2010/12/06 04:41:39 jakemsr Exp $ */ /* $NetBSD: if_cuereg.h,v 1.14 2001/01/21 22:09:24 augustss Exp $ */ /* * Copyright (c) 1997, 1998, 1999, 2000 @@ -183,8 +183,6 @@ struct cue_softc { u_int16_t cue_rxfilt; struct cue_cdata cue_cdata; - char cue_dying; - char cue_attached; u_int cue_rx_errs; struct timeval cue_rx_notice; diff --git a/sys/dev/usb/if_mos.c b/sys/dev/usb/if_mos.c index ffd9d662f84..eaf49a790da 100644 --- a/sys/dev/usb/if_mos.c +++ b/sys/dev/usb/if_mos.c @@ -1,4 +1,4 @@ -/* $OpenBSD: if_mos.c,v 1.11 2010/10/27 17:51:11 jakemsr Exp $ */ +/* $OpenBSD: if_mos.c,v 1.12 2010/12/06 04:41:39 jakemsr Exp $ */ /* * Copyright (c) 2008 Johann Christian Rode <jcrode@gmx.net> @@ -208,8 +208,8 @@ mos_reg_read_1(struct mos_softc *sc, int reg) usbd_status err; uByte val = 0; - if (sc->mos_dying) - return (0); + if (usbd_is_dying(sc->mos_udev)) + return(0); req.bmRequestType = UT_READ_VENDOR_DEVICE; req.bRequest = MOS_UR_READREG; @@ -236,7 +236,7 @@ mos_reg_read_2(struct mos_softc *sc, int reg) USETW(val,0); - if (sc->mos_dying) + if (usbd_is_dying(sc->mos_udev)) return(0); req.bmRequestType = UT_READ_VENDOR_DEVICE; @@ -264,7 +264,7 @@ mos_reg_write_1(struct mos_softc *sc, int reg, int aval) val = aval; - if (sc->mos_dying) + if (usbd_is_dying(sc->mos_udev)) return(0); req.bmRequestType = UT_WRITE_VENDOR_DEVICE; @@ -292,7 +292,7 @@ mos_reg_write_2(struct mos_softc *sc, int reg, int aval) USETW(val, aval); - if (sc->mos_dying) + if (usbd_is_dying(sc->mos_udev)) return (0); req.bmRequestType = UT_WRITE_VENDOR_DEVICE; @@ -317,7 +317,7 @@ mos_readmac(struct mos_softc *sc, u_char *mac) usb_device_request_t req; usbd_status err; - if (sc->mos_dying) + if (usbd_is_dying(sc->mos_udev)) return(0); req.bmRequestType = UT_READ_VENDOR_DEVICE; @@ -342,7 +342,7 @@ mos_writemac(struct mos_softc *sc, u_char *mac) usb_device_request_t req; usbd_status err; - if (sc->mos_dying) + if (usbd_is_dying(sc->mos_udev)) return(0); req.bmRequestType = UT_WRITE_VENDOR_DEVICE; @@ -367,7 +367,7 @@ mos_write_mcast(struct mos_softc *sc, u_char *hashtbl) usb_device_request_t req; usbd_status err; - if (sc->mos_dying) + if (usbd_is_dying(sc->mos_udev)) return(0); req.bmRequestType = UT_WRITE_VENDOR_DEVICE; @@ -393,7 +393,7 @@ mos_miibus_readreg(struct device *dev, int phy, int reg) uWord val; int i,res; - if (sc->mos_dying) { + if (usbd_is_dying(sc->mos_udev)) { DPRINTF(("mos: dying\n")); return (0); } @@ -429,7 +429,7 @@ mos_miibus_writereg(struct device *dev, int phy, int reg, int val) struct mos_softc *sc = (void *)dev; int i; - if (sc->mos_dying) + if (usbd_is_dying(sc->mos_udev)) return; mos_lock_mii(sc); @@ -539,7 +539,7 @@ mos_setmulti(struct mos_softc *sc) u_int8_t rxmode; u_int8_t hashtbl[8] = { 0, 0, 0, 0, 0, 0, 0, 0 }; - if (sc->mos_dying) + if (usbd_is_dying(sc->mos_udev)) return; ifp = GET_IFP(sc); @@ -576,7 +576,7 @@ void mos_reset(struct mos_softc *sc) { u_int8_t ctl; - if (sc->mos_dying) + if (usbd_is_dying(sc->mos_udev)) return; ctl = mos_reg_read_1(sc, MOS_CTL); @@ -643,6 +643,7 @@ mos_attach(struct device *parent, struct device *self, void *aux) u_char eaddr[ETHER_ADDR_LEN]; int i,s; + sc->mos_udev = dev; sc->mos_unit = self->dv_unit; err = usbd_set_config_no(dev, MOS_CONFIG_NO, 1); @@ -665,7 +666,6 @@ mos_attach(struct device *parent, struct device *self, void *aux) return; } - sc->mos_udev = dev; sc->mos_flags = mos_lookup(uaa->vendor, uaa->product)->mos_flags; id = usbd_get_interface_descriptor(sc->mos_iface); @@ -752,7 +752,6 @@ mos_attach(struct device *parent, struct device *self, void *aux) timeout_set(&sc->mos_stat_ch, mos_tick, sc); - sc->mos_attached = 1; splx(s); usbd_add_drv_event(USB_EVENT_DRIVER_ATTACH, sc->mos_udev, @@ -768,9 +767,6 @@ mos_detach(struct device *self, int flags) DPRINTFN(2,("%s: %s: enter\n", sc->mos_dev.dv_xname, __func__)); - if (!sc->mos_attached) - return (0); - if (timeout_initialized(&sc->mos_stat_ch)) timeout_del(&sc->mos_stat_ch); @@ -812,8 +808,6 @@ mos_detach(struct device *self, int flags) sc->mos_dev.dv_xname); #endif - sc->mos_attached = 0; - if (--sc->mos_refcnt >= 0) { /* Wait for processes to go away. */ usb_detach_wait(&sc->mos_dev); @@ -839,7 +833,7 @@ mos_activate(struct device *self, int act) break; case DVACT_DEACTIVATE: - sc->mos_dying = 1; + usbd_deactivate(sc->mos_udev); break; } return (0); @@ -947,7 +941,7 @@ mos_rxeof(usbd_xfer_handle xfer, usbd_private_handle priv, usbd_status status) DPRINTFN(10,("%s: %s: enter\n", sc->mos_dev.dv_xname,__func__)); - if (sc->mos_dying) + if (usbd_is_dying(sc->mos_udev)) return; if (!(ifp->if_flags & IFF_RUNNING)) @@ -1049,7 +1043,7 @@ mos_txeof(usbd_xfer_handle xfer, usbd_private_handle priv, usbd_status status) sc = c->mos_sc; ifp = &sc->arpcom.ac_if; - if (sc->mos_dying) + if (usbd_is_dying(sc->mos_udev)) return; s = splnet(); @@ -1093,7 +1087,7 @@ mos_tick(void *xsc) DPRINTFN(0xff, ("%s: %s: enter\n", sc->mos_dev.dv_xname, __func__)); - if (sc->mos_dying) + if (usbd_is_dying(sc->mos_udev)) return; /* Perform periodic stuff in process context */ @@ -1114,7 +1108,7 @@ mos_tick_task(void *xsc) if (sc == NULL) return; - if (sc->mos_dying) + if (usbd_is_dying(sc->mos_udev)) return; ifp = GET_IFP(sc); diff --git a/sys/dev/usb/if_mosreg.h b/sys/dev/usb/if_mosreg.h index 5b873689420..34b51161ac6 100644 --- a/sys/dev/usb/if_mosreg.h +++ b/sys/dev/usb/if_mosreg.h @@ -1,4 +1,4 @@ -/* $OpenBSD: if_mosreg.h,v 1.3 2008/11/22 09:46:12 deraadt Exp $ */ +/* $OpenBSD: if_mosreg.h,v 1.4 2010/12/06 04:41:39 jakemsr Exp $ */ /* * Copyright (c) 2008 Johann Christian Rode <jcrode@gmx.net> @@ -183,8 +183,6 @@ struct mos_softc { struct timeout mos_stat_ch; int mos_refcnt; - char mos_dying; - char mos_attached; int mos_link; unsigned char mos_ipgs[2]; diff --git a/sys/dev/usb/if_ral.c b/sys/dev/usb/if_ral.c index c5dca41c525..0e8f825f9eb 100644 --- a/sys/dev/usb/if_ral.c +++ b/sys/dev/usb/if_ral.c @@ -1,4 +1,4 @@ -/* $OpenBSD: if_ral.c,v 1.116 2010/10/27 17:51:11 jakemsr Exp $ */ +/* $OpenBSD: if_ral.c,v 1.117 2010/12/06 04:41:39 jakemsr Exp $ */ /*- * Copyright (c) 2005, 2006 @@ -2209,11 +2209,14 @@ ural_amrr_update(usbd_xfer_handle xfer, usbd_private_handle priv, int ural_activate(struct device *self, int act) { + struct ural_softc *sc = (struct ural_softc *)self; + switch (act) { case DVACT_ACTIVATE: break; case DVACT_DEACTIVATE: + usbd_deactivate(sc->sc_udev); break; } diff --git a/sys/dev/usb/if_rum.c b/sys/dev/usb/if_rum.c index 6de3f817736..6312915407e 100644 --- a/sys/dev/usb/if_rum.c +++ b/sys/dev/usb/if_rum.c @@ -1,4 +1,4 @@ -/* $OpenBSD: if_rum.c,v 1.93 2010/10/27 17:51:11 jakemsr Exp $ */ +/* $OpenBSD: if_rum.c,v 1.94 2010/12/06 04:41:39 jakemsr Exp $ */ /*- * Copyright (c) 2005-2007 Damien Bergamini <damien.bergamini@free.fr> @@ -644,6 +644,9 @@ rum_next_scan(void *arg) struct ieee80211com *ic = &sc->sc_ic; struct ifnet *ifp = &ic->ic_if; + if (usbd_is_dying(sc->sc_udev)) + return; + if (ic->ic_state == IEEE80211_S_SCAN) ieee80211_next_scan(ifp); } @@ -657,6 +660,9 @@ rum_task(void *arg) struct ieee80211_node *ni; uint32_t tmp; + if (usbd_is_dying(sc->sc_udev)) + return; + ostate = ic->ic_state; switch (sc->sc_state) { @@ -2239,6 +2245,9 @@ rum_amrr_timeout(void *arg) struct rum_softc *sc = arg; usb_device_request_t req; + if (usbd_is_dying(sc->sc_udev)) + return; + /* * Asynchronously read statistic registers (cleared by read). */ @@ -2287,11 +2296,14 @@ rum_amrr_update(usbd_xfer_handle xfer, usbd_private_handle priv, int rum_activate(struct device *self, int act) { + struct rum_softc *sc = (struct rum_softc *)self; + switch (act) { case DVACT_ACTIVATE: break; case DVACT_DEACTIVATE: + usbd_deactivate(sc->sc_udev); break; } diff --git a/sys/dev/usb/if_uath.c b/sys/dev/usb/if_uath.c index c5745a41a70..7958a99ed83 100644 --- a/sys/dev/usb/if_uath.c +++ b/sys/dev/usb/if_uath.c @@ -1,4 +1,4 @@ -/* $OpenBSD: if_uath.c,v 1.46 2010/10/27 17:51:11 jakemsr Exp $ */ +/* $OpenBSD: if_uath.c,v 1.47 2010/12/06 04:41:39 jakemsr Exp $ */ /*- * Copyright (c) 2006 @@ -427,6 +427,7 @@ fail4: uath_free_tx_data_list(sc); fail3: uath_free_rx_cmd_list(sc); fail2: uath_free_tx_cmd_list(sc); fail1: uath_close_pipes(sc); + usbd_deactivate(sc->sc_udev); } int @@ -2130,11 +2131,14 @@ fail1: return error; int uath_activate(struct device *self, int act) { + struct uath_softc *sc = (struct uath_softc *)self; + switch (act) { case DVACT_ACTIVATE: break; case DVACT_DEACTIVATE: + usbd_deactivate(sc->sc_udev); break; } return 0; diff --git a/sys/dev/usb/if_udav.c b/sys/dev/usb/if_udav.c index 8587f538e4a..111ffd30a62 100644 --- a/sys/dev/usb/if_udav.c +++ b/sys/dev/usb/if_udav.c @@ -1,4 +1,4 @@ -/* $OpenBSD: if_udav.c,v 1.49 2010/10/27 17:51:11 jakemsr Exp $ */ +/* $OpenBSD: if_udav.c,v 1.50 2010/12/06 04:41:39 jakemsr Exp $ */ /* $NetBSD: if_udav.c,v 1.3 2004/04/23 17:25:25 itojun Exp $ */ /* $nabe: if_udav.c,v 1.3 2003/08/21 16:57:19 nabe Exp $ */ /* @@ -204,6 +204,8 @@ udav_attach(struct device *parent, struct device *self, void *aux) printf("%s: ", devname); + sc->sc_udev = dev; + /* Move the device into the configured state. */ err = usbd_set_config_no(dev, UDAV_CONFIG_NO, 1); if (err) { @@ -224,7 +226,6 @@ udav_attach(struct device *parent, struct device *self, void *aux) goto bad; } - sc->sc_udev = dev; sc->sc_ctl_iface = iface; sc->sc_flags = udav_lookup(uaa->vendor, uaa->product)->udav_flags; @@ -308,7 +309,7 @@ udav_attach(struct device *parent, struct device *self, void *aux) ether_ifattach(ifp); timeout_set(&sc->sc_stat_ch, udav_tick, sc); - sc->sc_attached = 1; + splx(s); usbd_add_drv_event(USB_EVENT_DRIVER_ATTACH, dev, &sc->sc_dev); @@ -316,7 +317,7 @@ udav_attach(struct device *parent, struct device *self, void *aux) return; bad: - sc->sc_dying = 1; + usbd_deactivate(sc->sc_udev); } /* detach */ @@ -329,9 +330,6 @@ udav_detach(struct device *self, int flags) DPRINTF(("%s: %s: enter\n", sc->sc_dev.dv_xname, __func__)); - /* Detached before attached finished */ - if (!sc->sc_attached) - return (0); if (timeout_initialized(&sc->sc_stat_ch)) timeout_del(&sc->sc_stat_ch); @@ -367,8 +365,6 @@ udav_detach(struct device *self, int flags) printf("%s: detach has active intr endpoint.\n", sc->sc_dev.dv_xname); #endif - sc->sc_attached = 0; - splx(s); usbd_add_drv_event(USB_EVENT_DRIVER_DETACH, sc->sc_udev, @@ -391,7 +387,7 @@ udav_mem_read(struct udav_softc *sc, int offset, void *buf, int len) DPRINTFN(0x200, ("%s: %s: enter\n", sc->sc_dev.dv_xname, __func__)); - if (sc->sc_dying) + if (usbd_is_dying(sc->sc_udev)) return (0); offset &= 0xffff; @@ -428,7 +424,7 @@ udav_mem_write(struct udav_softc *sc, int offset, void *buf, int len) DPRINTFN(0x200, ("%s: %s: enter\n", sc->sc_dev.dv_xname, __func__)); - if (sc->sc_dying) + if (usbd_is_dying(sc->sc_udev)) return (0); offset &= 0xffff; @@ -465,7 +461,7 @@ udav_mem_write1(struct udav_softc *sc, int offset, unsigned char ch) DPRINTFN(0x200, ("%s: %s: enter\n", sc->sc_dev.dv_xname, __func__)); - if (sc->sc_dying) + if (usbd_is_dying(sc->sc_udev)) return (0); offset &= 0xffff; @@ -502,7 +498,7 @@ udav_csr_read(struct udav_softc *sc, int offset, void *buf, int len) DPRINTFN(0x200, ("%s: %s: enter\n", sc->sc_dev.dv_xname, __func__)); - if (sc->sc_dying) + if (usbd_is_dying(sc->sc_udev)) return (0); offset &= 0xff; @@ -539,7 +535,7 @@ udav_csr_write(struct udav_softc *sc, int offset, void *buf, int len) DPRINTFN(0x200, ("%s: %s: enter\n", sc->sc_dev.dv_xname, __func__)); - if (sc->sc_dying) + if (usbd_is_dying(sc->sc_udev)) return (0); offset &= 0xff; @@ -574,9 +570,6 @@ udav_csr_read1(struct udav_softc *sc, int offset) DPRINTFN(0x200, ("%s: %s: enter\n", sc->sc_dev.dv_xname, __func__)); - if (sc->sc_dying) - return (0); - return (udav_csr_read(sc, offset, &val, 1) ? 0 : val); } @@ -593,7 +586,7 @@ udav_csr_write1(struct udav_softc *sc, int offset, unsigned char ch) DPRINTFN(0x200, ("%s: %s: enter\n", sc->sc_dev.dv_xname, __func__)); - if (sc->sc_dying) + if (usbd_is_dying(sc->sc_udev)) return (0); offset &= 0xff; @@ -626,9 +619,6 @@ udav_init(struct ifnet *ifp) DPRINTF(("%s: %s: enter\n", sc->sc_dev.dv_xname, __func__)); - if (sc->sc_dying) - return (EIO); - s = splnet(); /* Cancel pending I/O and free all TX/RX buffers */ @@ -700,7 +690,7 @@ udav_reset(struct udav_softc *sc) DPRINTF(("%s: %s: enter\n", sc->sc_dev.dv_xname, __func__)); - if (sc->sc_dying) + if (usbd_is_dying(sc->sc_udev)) return; /* Select PHY */ @@ -740,7 +730,7 @@ udav_activate(struct device *self, int act) break; case DVACT_DEACTIVATE: - sc->sc_dying = 1; + usbd_deactivate(sc->sc_udev); break; } return (0); @@ -762,7 +752,7 @@ udav_setmulti(struct udav_softc *sc) DPRINTF(("%s: %s: enter\n", sc->sc_dev.dv_xname, __func__)); - if (sc->sc_dying) + if (usbd_is_dying(sc->sc_udev)) return; ifp = GET_IFP(sc); @@ -811,7 +801,7 @@ udav_openpipes(struct udav_softc *sc) int i; int error = 0; - if (sc->sc_dying) + if (usbd_is_dying(sc->sc_udev)) return (EIO); sc->sc_refcnt++; @@ -976,7 +966,7 @@ udav_start(struct ifnet *ifp) DPRINTF(("%s: %s: enter, link=%d\n", sc->sc_dev.dv_xname, __func__, sc->sc_link)); - if (sc->sc_dying) + if (usbd_is_dying(sc->sc_udev)) return; if (!sc->sc_link) @@ -1067,7 +1057,7 @@ udav_txeof(usbd_xfer_handle xfer, usbd_private_handle priv, usbd_status status) struct ifnet *ifp = GET_IFP(sc); int s; - if (sc->sc_dying) + if (usbd_is_dying(sc->sc_udev)) return; s = splnet(); @@ -1119,7 +1109,7 @@ udav_rxeof(usbd_xfer_handle xfer, usbd_private_handle priv, usbd_status status) DPRINTF(("%s: %s: enter\n", sc->sc_dev.dv_xname,__func__)); - if (sc->sc_dying) + if (usbd_is_dying(sc->sc_udev)) return; if (status != USBD_NORMAL_COMPLETION) { @@ -1217,7 +1207,7 @@ udav_ioctl(struct ifnet *ifp, u_long cmd, caddr_t data) DPRINTF(("%s: %s: enter\n", sc->sc_dev.dv_xname, __func__)); - if (sc->sc_dying) + if (usbd_is_dying(sc->sc_udev)) return (EIO); s = splnet(); @@ -1256,7 +1246,7 @@ udav_ioctl(struct ifnet *ifp, u_long cmd, caddr_t data) udav_init(ifp); } else { if (ifp->if_flags & IFF_RUNNING) - udav_stop(ifp, 1); + udav_stop(ifp, 1); } error = 0; break; @@ -1400,7 +1390,7 @@ udav_ifmedia_change(struct ifnet *ifp) DPRINTF(("%s: %s: enter\n", sc->sc_dev.dv_xname, __func__)); - if (sc->sc_dying) + if (usbd_is_dying(sc->sc_udev)) return (0); sc->sc_link = 0; @@ -1423,7 +1413,7 @@ udav_ifmedia_status(struct ifnet *ifp, struct ifmediareq *ifmr) DPRINTF(("%s: %s: enter\n", sc->sc_dev.dv_xname, __func__)); - if (sc->sc_dying) + if (usbd_is_dying(sc->sc_udev)) return; if ((ifp->if_flags & IFF_RUNNING) == 0) { @@ -1448,9 +1438,6 @@ udav_tick(void *xsc) DPRINTFN(0xff, ("%s: %s: enter\n", sc->sc_dev.dv_xname, __func__)); - if (sc->sc_dying) - return; - /* Perform periodic stuff in process context */ usb_add_task(sc->sc_udev, &sc->sc_tick_task); } @@ -1469,7 +1456,7 @@ udav_tick_task(void *xsc) DPRINTFN(0xff, ("%s: %s: enter\n", sc->sc_dev.dv_xname, __func__)); - if (sc->sc_dying) + if (usbd_is_dying(sc->sc_udev)) return; ifp = GET_IFP(sc); @@ -1532,7 +1519,7 @@ udav_miibus_readreg(struct device *dev, int phy, int reg) DPRINTFN(0xff, ("%s: %s: enter, phy=%d reg=0x%04x\n", sc->sc_dev.dv_xname, __func__, phy, reg)); - if (sc->sc_dying) { + if (usbd_is_dying(sc->sc_udev)) { #ifdef DIAGNOSTIC printf("%s: %s: dying\n", sc->sc_dev.dv_xname, __func__); @@ -1588,7 +1575,7 @@ udav_miibus_writereg(struct device *dev, int phy, int reg, int data) DPRINTFN(0xff, ("%s: %s: enter, phy=%d reg=0x%04x data=0x%04x\n", sc->sc_dev.dv_xname, __func__, phy, reg, data)); - if (sc->sc_dying) { + if (usbd_is_dying(sc->sc_udev)) { #ifdef DIAGNOSTIC printf("%s: %s: dying\n", sc->sc_dev.dv_xname, __func__); diff --git a/sys/dev/usb/if_udavreg.h b/sys/dev/usb/if_udavreg.h index 9b692b67588..f3034334c78 100644 --- a/sys/dev/usb/if_udavreg.h +++ b/sys/dev/usb/if_udavreg.h @@ -1,4 +1,4 @@ -/* $OpenBSD: if_udavreg.h,v 1.10 2007/11/25 16:40:03 jmc Exp $ */ +/* $OpenBSD: if_udavreg.h,v 1.11 2010/12/06 04:41:39 jakemsr Exp $ */ /* $NetBSD: if_udavreg.h,v 1.2 2003/09/04 15:17:39 tsutsui Exp $ */ /* $nabe: if_udavreg.h,v 1.2 2003/08/21 16:26:40 nabe Exp $ */ /* @@ -185,8 +185,6 @@ struct udav_softc { #define sc_media udav_mii.mii_media struct udav_cdata sc_cdata; - int sc_attached; - int sc_dying; int sc_refcnt; struct usb_task sc_tick_task; diff --git a/sys/dev/usb/if_upgt.c b/sys/dev/usb/if_upgt.c index f2ad877c507..7ef4965a571 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.53 2010/10/27 17:51:11 jakemsr Exp $ */ +/* $OpenBSD: if_upgt.c,v 1.54 2010/12/06 04:41:39 jakemsr Exp $ */ /* * Copyright (c) 2007 Marcus Glocker <mglocker@openbsd.org> @@ -454,9 +454,6 @@ upgt_attach_hook(void *arg) printf("%s: address %s\n", sc->sc_dev.dv_xname, ether_sprintf(ic->ic_myaddr)); - /* device attached */ - sc->sc_flags |= UPGT_DEVICE_ATTACHED; - return; fail: printf("%s: %s failed!\n", sc->sc_dev.dv_xname, __func__); @@ -515,10 +512,13 @@ upgt_detach(struct device *self, int flags) int upgt_activate(struct device *self, int act) { + struct upgt_softc *sc = (struct upgt_softc *)self; + switch (act) { case DVACT_ACTIVATE: break; case DVACT_DEACTIVATE: + usbd_deactivate(sc->sc_udev); break; } diff --git a/sys/dev/usb/if_upgtvar.h b/sys/dev/usb/if_upgtvar.h index 434f7ff188e..2f444812dae 100644 --- a/sys/dev/usb/if_upgtvar.h +++ b/sys/dev/usb/if_upgtvar.h @@ -1,4 +1,4 @@ -/* $OpenBSD: if_upgtvar.h,v 1.15 2009/08/10 20:02:19 deraadt Exp $ */ +/* $OpenBSD: if_upgtvar.h,v 1.16 2010/12/06 04:41:39 jakemsr Exp $ */ /* * Copyright (c) 2007 Marcus Glocker <mglocker@openbsd.org> @@ -421,7 +421,6 @@ struct upgt_softc { unsigned sc_cur_chan; uint8_t sc_cur_rateset[8]; - int sc_flags; uint8_t *sc_fw; size_t sc_fw_size; int sc_fw_type; diff --git a/sys/dev/usb/if_url.c b/sys/dev/usb/if_url.c index fd37071acab..ff4a10df4b3 100644 --- a/sys/dev/usb/if_url.c +++ b/sys/dev/usb/if_url.c @@ -1,4 +1,4 @@ -/* $OpenBSD: if_url.c,v 1.59 2010/10/27 17:51:11 jakemsr Exp $ */ +/* $OpenBSD: if_url.c,v 1.60 2010/12/06 04:41:39 jakemsr Exp $ */ /* $NetBSD: if_url.c,v 1.6 2002/09/29 10:19:21 martin Exp $ */ /* * Copyright (c) 2001, 2002 @@ -201,6 +201,8 @@ url_attach(struct device *parent, struct device *self, void *aux) u_char eaddr[ETHER_ADDR_LEN]; int i, s; + sc->sc_udev = dev; + /* Move the device into the configured state. */ err = usbd_set_config_no(dev, URL_CONFIG_NO, 1); if (err) { @@ -222,7 +224,6 @@ url_attach(struct device *parent, struct device *self, void *aux) goto bad; } - sc->sc_udev = dev; sc->sc_ctl_iface = iface; sc->sc_flags = url_lookup(uaa->vendor, uaa->product)->url_flags; @@ -314,7 +315,7 @@ url_attach(struct device *parent, struct device *self, void *aux) ether_ifattach(ifp); timeout_set(&sc->sc_stat_ch, url_tick, sc); - sc->sc_attached = 1; + splx(s); usbd_add_drv_event(USB_EVENT_DRIVER_ATTACH, dev, &sc->sc_dev); @@ -322,7 +323,7 @@ url_attach(struct device *parent, struct device *self, void *aux) return; bad: - sc->sc_dying = 1; + usbd_deactivate(sc->sc_udev); } /* detach */ @@ -335,10 +336,6 @@ url_detach(struct device *self, int flags) DPRINTF(("%s: %s: enter\n", sc->sc_dev.dv_xname, __func__)); - /* Detached before attached finished */ - if (!sc->sc_attached) - return (0); - if (timeout_initialized(&sc->sc_stat_ch)) timeout_del(&sc->sc_stat_ch); @@ -375,8 +372,6 @@ url_detach(struct device *self, int flags) sc->sc_dev.dv_xname); #endif - sc->sc_attached = 0; - splx(s); usbd_add_drv_event(USB_EVENT_DRIVER_DETACH, sc->sc_udev, @@ -398,7 +393,7 @@ url_mem(struct url_softc *sc, int cmd, int offset, void *buf, int len) DPRINTFN(0x200, ("%s: %s: enter\n", sc->sc_dev.dv_xname, __func__)); - if (sc->sc_dying) + if (usbd_is_dying(sc->sc_udev)) return (0); if (cmd == URL_CMD_READMEM) @@ -433,9 +428,6 @@ url_csr_read_1(struct url_softc *sc, int reg) DPRINTFN(0x100, ("%s: %s: enter\n", sc->sc_dev.dv_xname, __func__)); - if (sc->sc_dying) - return (0); - return (url_mem(sc, URL_CMD_READMEM, reg, &val, 1) ? 0 : val); } @@ -448,9 +440,6 @@ url_csr_read_2(struct url_softc *sc, int reg) DPRINTFN(0x100, ("%s: %s: enter\n", sc->sc_dev.dv_xname, __func__)); - if (sc->sc_dying) - return (0); - USETW(val, 0); return (url_mem(sc, URL_CMD_READMEM, reg, &val, 2) ? 0 : UGETW(val)); } @@ -464,9 +453,6 @@ url_csr_write_1(struct url_softc *sc, int reg, int aval) DPRINTFN(0x100, ("%s: %s: enter\n", sc->sc_dev.dv_xname, __func__)); - if (sc->sc_dying) - return (0); - return (url_mem(sc, URL_CMD_WRITEMEM, reg, &val, 1) ? -1 : 0); } @@ -481,9 +467,6 @@ url_csr_write_2(struct url_softc *sc, int reg, int aval) USETW(val, aval); - if (sc->sc_dying) - return (0); - return (url_mem(sc, URL_CMD_WRITEMEM, reg, &val, 2) ? -1 : 0); } @@ -498,9 +481,6 @@ url_csr_write_4(struct url_softc *sc, int reg, int aval) USETDW(val, aval); - if (sc->sc_dying) - return (0); - return (url_mem(sc, URL_CMD_WRITEMEM, reg, &val, 4) ? -1 : 0); } @@ -514,9 +494,6 @@ url_init(struct ifnet *ifp) DPRINTF(("%s: %s: enter\n", sc->sc_dev.dv_xname, __func__)); - if (sc->sc_dying) - return (EIO); - s = splnet(); /* Cancel pending I/O and free all TX/RX buffers */ @@ -592,7 +569,7 @@ url_reset(struct url_softc *sc) DPRINTF(("%s: %s: enter\n", sc->sc_dev.dv_xname, __func__)); - if (sc->sc_dying) + if (usbd_is_dying(sc->sc_udev)) return; URL_SETBIT(sc, URL_CR, URL_CR_SOFT_RST); @@ -619,7 +596,7 @@ url_activate(struct device *self, int act) break; case DVACT_DEACTIVATE: - sc->sc_dying = 1; + usbd_deactivate(sc->sc_udev); break; } @@ -641,7 +618,7 @@ url_setmulti(struct url_softc *sc) DPRINTF(("%s: %s: enter\n", sc->sc_dev.dv_xname, __func__)); - if (sc->sc_dying) + if (usbd_is_dying(sc->sc_udev)) return; ifp = GET_IFP(sc); @@ -698,7 +675,7 @@ url_openpipes(struct url_softc *sc) int i; int error = 0; - if (sc->sc_dying) + if (usbd_is_dying(sc->sc_udev)) return (EIO); sc->sc_refcnt++; @@ -863,7 +840,7 @@ url_start(struct ifnet *ifp) DPRINTF(("%s: %s: enter, link=%d\n", sc->sc_dev.dv_xname, __func__, sc->sc_link)); - if (sc->sc_dying) + if (usbd_is_dying(sc->sc_udev)) return; if (!sc->sc_link) @@ -947,7 +924,7 @@ url_txeof(usbd_xfer_handle xfer, usbd_private_handle priv, usbd_status status) struct ifnet *ifp = GET_IFP(sc); int s; - if (sc->sc_dying) + if (usbd_is_dying(sc->sc_udev)) return; s = splnet(); @@ -999,7 +976,7 @@ url_rxeof(usbd_xfer_handle xfer, usbd_private_handle priv, usbd_status status) DPRINTF(("%s: %s: enter\n", sc->sc_dev.dv_xname,__func__)); - if (sc->sc_dying) + if (usbd_is_dying(sc->sc_udev)) return; if (status != USBD_NORMAL_COMPLETION) { @@ -1101,7 +1078,7 @@ url_ioctl(struct ifnet *ifp, u_long cmd, caddr_t data) DPRINTF(("%s: %s: enter\n", sc->sc_dev.dv_xname, __func__)); - if (sc->sc_dying) + if (usbd_is_dying(sc->sc_udev)) return (EIO); s = splnet(); @@ -1284,7 +1261,7 @@ url_ifmedia_change(struct ifnet *ifp) DPRINTF(("%s: %s: enter\n", sc->sc_dev.dv_xname, __func__)); - if (sc->sc_dying) + if (usbd_is_dying(sc->sc_udev)) return (0); sc->sc_link = 0; @@ -1307,7 +1284,7 @@ url_ifmedia_status(struct ifnet *ifp, struct ifmediareq *ifmr) DPRINTF(("%s: %s: enter\n", sc->sc_dev.dv_xname, __func__)); - if (sc->sc_dying) + if (usbd_is_dying(sc->sc_udev)) return; if ((ifp->if_flags & IFF_RUNNING) == 0) { @@ -1332,7 +1309,7 @@ url_tick(void *xsc) DPRINTFN(0xff, ("%s: %s: enter\n", sc->sc_dev.dv_xname, __func__)); - if (sc->sc_dying) + if (usbd_is_dying(sc->sc_udev)) return; /* Perform periodic stuff in process context */ @@ -1353,7 +1330,7 @@ url_tick_task(void *xsc) DPRINTFN(0xff, ("%s: %s: enter\n", sc->sc_dev.dv_xname, __func__)); - if (sc->sc_dying) + if (usbd_is_dying(sc->sc_udev)) return; ifp = GET_IFP(sc); @@ -1415,7 +1392,7 @@ url_int_miibus_readreg(struct device *dev, int phy, int reg) DPRINTFN(0xff, ("%s: %s: enter, phy=%d reg=0x%04x\n", sc->sc_dev.dv_xname, __func__, phy, reg)); - if (sc->sc_dying) { + if (usbd_is_dying(sc->sc_udev)) { #ifdef DIAGNOSTIC printf("%s: %s: dying\n", sc->sc_dev.dv_xname, __func__); @@ -1487,7 +1464,7 @@ url_int_miibus_writereg(struct device *dev, int phy, int reg, int data) DPRINTFN(0xff, ("%s: %s: enter, phy=%d reg=0x%04x data=0x%04x\n", sc->sc_dev.dv_xname, __func__, phy, reg, data)); - if (sc->sc_dying) { + if (usbd_is_dying(sc->sc_udev)) { #ifdef DIAGNOSTIC printf("%s: %s: dying\n", sc->sc_dev.dv_xname, __func__); @@ -1569,7 +1546,7 @@ url_ext_miibus_redreg(struct device *dev, int phy, int reg) DPRINTF(("%s: %s: enter, phy=%d reg=0x%04x\n", sc->sc_dev.dv_xname, __func__, phy, reg)); - if (sc->sc_dying) { + if (usbd_is_dying(sc->sc_udev)) { #ifdef DIAGNOSTIC printf("%s: %s: dying\n", sc->sc_dev.dv_xname, __func__); @@ -1612,7 +1589,7 @@ url_ext_miibus_writereg(struct device *dev, int phy, int reg, int data) DPRINTF(("%s: %s: enter, phy=%d reg=0x%04x data=0x%04x\n", sc->sc_dev.dv_xname, __func__, phy, reg, data)); - if (sc->sc_dying) { + if (usbd_is_dying(sc->sc_udev)) { #ifdef DIAGNOSTIC printf("%s: %s: dying\n", sc->sc_dev.dv_xname, __func__); diff --git a/sys/dev/usb/if_urlreg.h b/sys/dev/usb/if_urlreg.h index 52c82059a8a..87cd7fa6e89 100644 --- a/sys/dev/usb/if_urlreg.h +++ b/sys/dev/usb/if_urlreg.h @@ -1,4 +1,4 @@ -/* $OpenBSD: if_urlreg.h,v 1.12 2007/11/25 16:40:03 jmc Exp $ */ +/* $OpenBSD: if_urlreg.h,v 1.13 2010/12/06 04:41:39 jakemsr Exp $ */ /* $NetBSD: if_urlreg.h,v 1.1 2002/03/28 21:09:11 ichiro Exp $ */ /* * Copyright (c) 2001, 2002 @@ -175,8 +175,6 @@ struct url_softc { #define sc_media url_mii.mii_media struct url_cdata sc_cdata; - int sc_attached; - int sc_dying; int sc_refcnt; struct usb_task sc_tick_task; diff --git a/sys/dev/usb/if_urtw.c b/sys/dev/usb/if_urtw.c index ed7746a7360..460db9fa6a7 100644 --- a/sys/dev/usb/if_urtw.c +++ b/sys/dev/usb/if_urtw.c @@ -1,4 +1,4 @@ -/* $OpenBSD: if_urtw.c,v 1.34 2010/10/27 17:51:11 jakemsr Exp $ */ +/* $OpenBSD: if_urtw.c,v 1.35 2010/12/06 04:41:39 jakemsr Exp $ */ /*- * Copyright (c) 2009 Martynas Venckus <martynas@openbsd.org> @@ -803,10 +803,13 @@ urtw_detach(struct device *self, int flags) int urtw_activate(struct device *self, int act) { + struct urtw_softc *sc = (struct urtw_softc *)self; + switch (act) { case DVACT_ACTIVATE: break; case DVACT_DEACTIVATE: + usbd_deactivate(sc->sc_udev); break; } diff --git a/sys/dev/usb/if_zyd.c b/sys/dev/usb/if_zyd.c index 9f505f119e3..09ac920088b 100644 --- a/sys/dev/usb/if_zyd.c +++ b/sys/dev/usb/if_zyd.c @@ -1,4 +1,4 @@ -/* $OpenBSD: if_zyd.c,v 1.85 2010/10/27 17:51:11 jakemsr Exp $ */ +/* $OpenBSD: if_zyd.c,v 1.86 2010/12/06 04:41:39 jakemsr Exp $ */ /*- * Copyright (c) 2006 by Damien Bergamini <damien.bergamini@free.fr> @@ -2588,11 +2588,14 @@ zyd_newassoc(struct ieee80211com *ic, struct ieee80211_node *ni, int isnew) int zyd_activate(struct device *self, int act) { + struct zyd_softc *sc = (struct zyd_softc *)self; + switch (act) { case DVACT_ACTIVATE: break; case DVACT_DEACTIVATE: + usbd_deactivate(sc->sc_udev); break; } return 0; diff --git a/sys/dev/usb/udcf.c b/sys/dev/usb/udcf.c index 0d42aa2bf2c..6ae19f8e996 100644 --- a/sys/dev/usb/udcf.c +++ b/sys/dev/usb/udcf.c @@ -1,4 +1,4 @@ -/* $OpenBSD: udcf.c,v 1.50 2010/10/23 16:14:07 jakemsr Exp $ */ +/* $OpenBSD: udcf.c,v 1.51 2010/12/06 04:41:40 jakemsr Exp $ */ /* * Copyright (c) 2006, 2007, 2008 Marc Balmer <mbalmer@openbsd.org> @@ -68,7 +68,6 @@ struct udcf_softc { struct device sc_dev; /* base device */ usbd_device_handle sc_udev; /* USB device */ usbd_interface_handle sc_iface; /* data interface */ - u_char sc_dying; /* disconnecting */ struct timeout sc_to; struct usb_task sc_task; @@ -326,7 +325,7 @@ udcf_attach(struct device *parent, struct device *self, void *aux) fishy: DPRINTF(("udcf_attach failed\n")); - sc->sc_dying = 1; + usbd_deactivate(sc->sc_udev); } int @@ -519,7 +518,7 @@ udcf_probe(void *xsc) struct timespec now; int data; - if (sc->sc_dying) + if (usbd_is_dying(sc->sc_udev)) return; data = sc->sc_signal(sc); @@ -594,7 +593,7 @@ udcf_bv_probe(void *xsc) struct udcf_softc *sc = xsc; int data; - if (sc->sc_dying) + if (usbd_is_dying(sc->sc_udev)) return; data = sc->sc_signal(sc); @@ -751,7 +750,7 @@ udcf_sl_probe(void *xsc) { struct udcf_softc *sc = xsc; - if (sc->sc_dying) + if (usbd_is_dying(sc->sc_udev)) return; DPRINTF(("no signal\n")); @@ -766,7 +765,7 @@ udcf_it_intr(void *xsc) { struct udcf_softc *sc = xsc; - if (sc->sc_dying) + if (usbd_is_dying(sc->sc_udev)) return; if (sc->sc_sensor.status == SENSOR_S_OK) { @@ -789,7 +788,7 @@ udcf_ct_probe(void *xsc) struct udcf_softc *sc = xsc; int data; - if (sc->sc_dying) + if (usbd_is_dying(sc->sc_udev)) return; data = sc->sc_signal(sc); @@ -812,7 +811,7 @@ udcf_activate(struct device *self, int act) case DVACT_ACTIVATE: break; case DVACT_DEACTIVATE: - sc->sc_dying = 1; + usbd_deactivate(sc->sc_udev); break; } return 0; diff --git a/sys/dev/usb/ueagle.c b/sys/dev/usb/ueagle.c index 4cb390e2df3..4416d07d9f5 100644 --- a/sys/dev/usb/ueagle.c +++ b/sys/dev/usb/ueagle.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ueagle.c,v 1.29 2010/10/23 15:42:09 jakemsr Exp $ */ +/* $OpenBSD: ueagle.c,v 1.30 2010/12/06 04:41:40 jakemsr Exp $ */ /*- * Copyright (c) 2003-2006 @@ -318,6 +318,9 @@ ueagle_loadpage(void *xsc) uint8_t *p; int i; + if (usbd_is_dying(sc->sc_udev)) + return; + p = sc->dsp; pagecount = *p++; @@ -576,6 +579,8 @@ ueagle_stat_thread(void *arg) break; usbd_delay_ms(sc->sc_udev, 5000); + if (usbd_is_dying(sc->sc_udev)) + break; } wakeup(sc->stat_thread); @@ -1467,7 +1472,7 @@ ueagle_activate(struct device *self, int act) break; case DVACT_DEACTIVATE: - sc->gone = 1; + usbd_deactivate(sc->sc_udev); break; } diff --git a/sys/dev/usb/ueaglevar.h b/sys/dev/usb/ueaglevar.h index f22448b2ccb..f5c39281568 100644 --- a/sys/dev/usb/ueaglevar.h +++ b/sys/dev/usb/ueaglevar.h @@ -1,4 +1,4 @@ -/* $OpenBSD: ueaglevar.h,v 1.2 2007/06/06 19:25:49 mk Exp $ */ +/* $OpenBSD: ueaglevar.h,v 1.3 2010/12/06 04:41:40 jakemsr Exp $ */ /*- * Copyright (c) 2003-2005 @@ -184,8 +184,6 @@ struct ueagle_softc { uint16_t isize; char ibuf[32]; - int gone; - uint16_t index; uint32_t data; }; diff --git a/sys/dev/usb/uhub.c b/sys/dev/usb/uhub.c index 75bc3325dee..57d8a0003df 100644 --- a/sys/dev/usb/uhub.c +++ b/sys/dev/usb/uhub.c @@ -1,4 +1,4 @@ -/* $OpenBSD: uhub.c,v 1.55 2010/09/23 05:44:15 jakemsr Exp $ */ +/* $OpenBSD: uhub.c,v 1.56 2010/12/06 04:41:40 jakemsr Exp $ */ /* $NetBSD: uhub.c,v 1.64 2003/02/08 03:32:51 ichiro Exp $ */ /* $FreeBSD: src/sys/dev/usb/uhub.c,v 1.18 1999/11/17 22:33:43 n_hibma Exp $ */ @@ -353,8 +353,8 @@ uhub_explore(usbd_device_handle dev) DPRINTFN(10, ("uhub_explore dev=%p addr=%d\n", dev, dev->address)); - if (dev->bus->dying) { - DPRINTF(("%s: root hub gone at start\n", __func__)); + if (usbd_is_dying(dev)) { + DPRINTF(("%s: dying\n", __func__)); return (USBD_IOERROR); } diff --git a/sys/dev/usb/umbg.c b/sys/dev/usb/umbg.c index 029694bb01b..11e64070b30 100644 --- a/sys/dev/usb/umbg.c +++ b/sys/dev/usb/umbg.c @@ -1,4 +1,4 @@ -/* $OpenBSD: umbg.c,v 1.14 2010/10/23 16:14:07 jakemsr Exp $ */ +/* $OpenBSD: umbg.c,v 1.15 2010/12/06 04:41:40 jakemsr Exp $ */ /* * Copyright (c) 2007 Marc Balmer <mbalmer@openbsd.org> @@ -53,7 +53,6 @@ struct umbg_softc { struct device sc_dev; /* base device */ usbd_device_handle sc_udev; /* USB device */ usbd_interface_handle sc_iface; /* data interface */ - u_char sc_dying; /* disconnecting */ int sc_bulkin_no; usbd_pipe_handle sc_bulkin_pipe; @@ -287,7 +286,7 @@ umbg_attach(struct device *parent, struct device *self, void *aux) return; fishy: - sc->sc_dying = 1; + usbd_deactivate(sc->sc_udev); } int @@ -350,7 +349,7 @@ umbg_task(void *arg) int64_t tlocal, trecv; int signal; - if (sc->sc_dying) + if (usbd_is_dying(sc->sc_udev)) return; if (umbg_read(sc, MBG_GET_TIME_HR, (char *)&tframe, sizeof(tframe), @@ -438,7 +437,7 @@ umbg_it_intr(void *xsc) { struct umbg_softc *sc = xsc; - if (sc->sc_dying) + if (usbd_is_dying(sc->sc_udev)) return; if (sc->sc_timedelta.status == SENSOR_S_OK) { @@ -461,7 +460,7 @@ umbg_activate(struct device *self, int act) case DVACT_ACTIVATE: break; case DVACT_DEACTIVATE: - sc->sc_dying = 1; + usbd_deactivate(sc->sc_udev); break; } return 0; |