void ubcmtp_disable(void *v) { struct ubcmtp_softc *sc = v; if (usbd_is_dying(sc->sc_udev) || !(sc->sc_status & UBCMTP_ENABLED)) return; sc->sc_status &= ~UBCMTP_ENABLED; ubcmtp_raw_mode(sc, 0); if (sc->sc_tp_pipe != NULL) { usbd_abort_pipe(sc->sc_tp_pipe); usbd_close_pipe(sc->sc_tp_pipe); sc->sc_tp_pipe = NULL; } if (sc->sc_bt_pipe != NULL) { usbd_abort_pipe(sc->sc_bt_pipe); usbd_close_pipe(sc->sc_bt_pipe); sc->sc_bt_pipe = NULL; } if (sc->tp_pkt != NULL) { free(sc->tp_pkt, M_USBDEV, 0); sc->tp_pkt = NULL; } if (sc->bt_pkt != NULL) { free(sc->bt_pkt, M_USBDEV, 0); sc->bt_pkt = NULL; } }
void ucom_cleanup(struct ucom_softc *sc) { DPRINTF(("ucom_cleanup: closing pipes\n")); sc->sc_open = 0; ucom_shutdown(sc); if (sc->sc_bulkin_pipe != NULL) { usbd_abort_pipe(sc->sc_bulkin_pipe); usbd_close_pipe(sc->sc_bulkin_pipe); sc->sc_bulkin_pipe = NULL; } if (sc->sc_bulkout_pipe != NULL) { usbd_abort_pipe(sc->sc_bulkout_pipe); usbd_close_pipe(sc->sc_bulkout_pipe); sc->sc_bulkout_pipe = NULL; } if (sc->sc_ixfer != NULL) { if (sc->sc_uhidev == NULL) usbd_free_xfer(sc->sc_ixfer); sc->sc_ixfer = NULL; } if (sc->sc_oxfer != NULL) { usbd_free_buffer(sc->sc_oxfer); if (sc->sc_uhidev == NULL) usbd_free_xfer(sc->sc_oxfer); sc->sc_oxfer = NULL; } }
int uirda_close(void *h, int flag, int mode, struct lwp *l) { struct uirda_softc *sc = h; DPRINTF(("%s: sc=%p\n", __func__, sc)); if (sc->sc_rd_pipe != NULL) { usbd_abort_pipe(sc->sc_rd_pipe); usbd_close_pipe(sc->sc_rd_pipe); sc->sc_rd_pipe = NULL; } if (sc->sc_wr_pipe != NULL) { usbd_abort_pipe(sc->sc_wr_pipe); usbd_close_pipe(sc->sc_wr_pipe); sc->sc_wr_pipe = NULL; } if (sc->sc_rd_xfer != NULL) { usbd_free_xfer(sc->sc_rd_xfer); sc->sc_rd_xfer = NULL; sc->sc_rd_buf = NULL; } if (sc->sc_wr_xfer != NULL) { usbd_free_xfer(sc->sc_wr_xfer); sc->sc_wr_xfer = NULL; sc->sc_wr_buf = NULL; } return (0); }
static void ucom_cleanup(struct ucom_softc *sc) { struct ucom_buffer *ub; DPRINTF(("ucom_cleanup: closing pipes\n")); ucom_shutdown(sc); if (sc->sc_bulkin_pipe != NULL) { usbd_abort_pipe(sc->sc_bulkin_pipe); usbd_close_pipe(sc->sc_bulkin_pipe); sc->sc_bulkin_pipe = NULL; } if (sc->sc_bulkout_pipe != NULL) { usbd_abort_pipe(sc->sc_bulkout_pipe); usbd_close_pipe(sc->sc_bulkout_pipe); sc->sc_bulkout_pipe = NULL; } for (ub = &sc->sc_ibuff[0]; ub != &sc->sc_ibuff[UCOM_IN_BUFFS]; ub++) { if (ub->ub_xfer != NULL) { usbd_free_xfer(ub->ub_xfer); ub->ub_xfer = NULL; ub->ub_data = NULL; } } for (ub = &sc->sc_obuff[0]; ub != &sc->sc_obuff[UCOM_OUT_BUFFS]; ub++){ if (ub->ub_xfer != NULL) { usbd_free_xfer(ub->ub_xfer); ub->ub_xfer = NULL; ub->ub_data = NULL; } } }
/* * Stop the adapter and free any mbufs allocated to the * RX and TX lists. */ void ugl_stop(struct ugl_softc *sc) { struct ifnet *ifp; int i; DPRINTFN(10,("%s: %s: enter\n", sc->sc_dev.dv_xname,__func__)); ifp = GET_IFP(sc); ifp->if_timer = 0; ifp->if_flags &= ~(IFF_RUNNING | IFF_OACTIVE); /* Stop transfers. */ if (sc->sc_ep[UGL_ENDPT_RX] != NULL) { usbd_abort_pipe(sc->sc_ep[UGL_ENDPT_RX]); usbd_close_pipe(sc->sc_ep[UGL_ENDPT_RX]); sc->sc_ep[UGL_ENDPT_RX] = NULL; } if (sc->sc_ep[UGL_ENDPT_TX] != NULL) { usbd_abort_pipe(sc->sc_ep[UGL_ENDPT_TX]); usbd_close_pipe(sc->sc_ep[UGL_ENDPT_TX]); sc->sc_ep[UGL_ENDPT_TX] = NULL; } if (sc->sc_ep[UGL_ENDPT_INTR] != NULL) { usbd_abort_pipe(sc->sc_ep[UGL_ENDPT_INTR]); usbd_close_pipe(sc->sc_ep[UGL_ENDPT_INTR]); sc->sc_ep[UGL_ENDPT_INTR] = NULL; } /* Free RX resources. */ for (i = 0; i < UGL_RX_LIST_CNT; i++) { if (sc->sc_cdata.ugl_rx_chain[i].ugl_mbuf != NULL) { m_freem(sc->sc_cdata.ugl_rx_chain[i].ugl_mbuf); sc->sc_cdata.ugl_rx_chain[i].ugl_mbuf = NULL; } if (sc->sc_cdata.ugl_rx_chain[i].ugl_xfer != NULL) { usbd_free_xfer(sc->sc_cdata.ugl_rx_chain[i].ugl_xfer); sc->sc_cdata.ugl_rx_chain[i].ugl_xfer = NULL; } } /* Free TX resources. */ for (i = 0; i < UGL_TX_LIST_CNT; i++) { if (sc->sc_cdata.ugl_tx_chain[i].ugl_mbuf != NULL) { m_freem(sc->sc_cdata.ugl_tx_chain[i].ugl_mbuf); sc->sc_cdata.ugl_tx_chain[i].ugl_mbuf = NULL; } if (sc->sc_cdata.ugl_tx_chain[i].ugl_xfer != NULL) { usbd_free_xfer(sc->sc_cdata.ugl_tx_chain[i].ugl_xfer); sc->sc_cdata.ugl_tx_chain[i].ugl_xfer = NULL; } } }
/* ARGSUSED */ static int udsir_close(void *h, int flag, int mode, struct lwp *l) { struct udsir_softc *sc = h; DPRINTFN(0, ("%s: sc=%p\n", __func__, sc)); sc->sc_refcnt++; sc->sc_rd_readinprogress = 1; sc->sc_closing = 1; wakeup(&sc->sc_thread); while (sc->sc_thread != NULL) tsleep(&sc->sc_closing, PWAIT, "usircl", 0); if (sc->sc_rd_pipe != NULL) { usbd_abort_pipe(sc->sc_rd_pipe); } if (sc->sc_wr_pipe != NULL) { usbd_abort_pipe(sc->sc_wr_pipe); } if (sc->sc_rd_xfer != NULL) { usbd_destroy_xfer(sc->sc_rd_xfer); sc->sc_rd_xfer = NULL; sc->sc_rd_buf = NULL; } if (sc->sc_wr_xfer != NULL) { usbd_destroy_xfer(sc->sc_wr_xfer); sc->sc_wr_xfer = NULL; sc->sc_wr_buf = NULL; } if (sc->sc_rd_pipe != NULL) { usbd_close_pipe(sc->sc_rd_pipe); sc->sc_rd_pipe = NULL; } if (sc->sc_wr_pipe != NULL) { usbd_close_pipe(sc->sc_wr_pipe); sc->sc_wr_pipe = NULL; } if (sc->sc_ur_buf != NULL) { kmem_free(sc->sc_ur_buf, IRDA_MAX_FRAME_SIZE); sc->sc_ur_buf = NULL; } if (--sc->sc_refcnt < 0) usb_detach_wakeupold(sc->sc_dev); return 0; }
static void xboxcontroller_wsmouse_disable(void *opaque) { struct xboxcontroller_softc *sc; sc = (struct xboxcontroller_softc *)opaque; if (!sc->sc_enabled) { aprint_error_dev(sc->sc_dev, "already disabled!\n"); return; } if (sc->sc_ep != NULL) { usbd_abort_pipe(sc->sc_ep); usbd_close_pipe(sc->sc_ep); sc->sc_ep = NULL; } if (sc->sc_buf != NULL) { free(sc->sc_buf, M_USBDEV); sc->sc_buf = NULL; } sc->sc_enabled = 0; return; }
static void uplcom_close(void *addr, int portno) { struct uplcom_softc *sc = addr; int err; if (sc->sc_ucom.sc_dying) return; DPRINTF(("uplcom_close: close\n")); if (sc->sc_intr_pipe != NULL) { err = usbd_abort_pipe(sc->sc_intr_pipe); if (err) printf("%s: abort interrupt pipe failed: %s\n", device_get_nameunit(sc->sc_ucom.sc_dev), usbd_errstr(err)); err = usbd_close_pipe(sc->sc_intr_pipe); if (err) printf("%s: close interrupt pipe failed: %s\n", device_get_nameunit(sc->sc_ucom.sc_dev), usbd_errstr(err)); free(sc->sc_intr_buf, M_USBDEV); sc->sc_intr_pipe = NULL; } }
void ubsa_close(void *addr, int portno) { struct ubsa_softc *sc = addr; int err; if (sc->sc_dying) return; DPRINTF(("ubsa_close: close\n")); if (sc->sc_intr_pipe != NULL) { err = usbd_abort_pipe(sc->sc_intr_pipe); if (err) printf("%s: abort interrupt pipe failed: %s\n", sc->sc_dev.dv_xname, usbd_errstr(err)); err = usbd_close_pipe(sc->sc_intr_pipe); if (err) printf("%s: close interrupt pipe failed: %s\n", sc->sc_dev.dv_xname, usbd_errstr(err)); free(sc->sc_intr_buf, M_USBDEV); sc->sc_intr_pipe = NULL; } }
jresult_t cdc_open_data_pipes(uwh_cdc_dev_h dev_ctx) { jresult_t rc = 0; jcdc_dev_softc_t *sc = (jcdc_dev_softc_t *)dev_ctx; DECLARE_FNAME("cdc_open_data_pipes"); DBG_V(DHOST_CDC_GENERAL, ("%s: Entered\n", fname)); /* Open bulk pipes */ rc = usbd_open_pipe(sc->d_iface, sc->bulk_ep_in, USBD_EXCLUSIVE_USE, &sc->bulk_pipe_in); if (rc) { DBG_E(DHOST_CDC_GENERAL, ("%s: Error opening bulk in pipe.\n", fname)); return rc; } rc = usbd_open_pipe(sc->d_iface, sc->bulk_ep_out, USBD_EXCLUSIVE_USE, &sc->bulk_pipe_out); if (rc) { DBG_E(DHOST_CDC_GENERAL, ("%s: Error opening bulk out pipe.\n", fname)); usbd_close_pipe(sc->bulk_pipe_in); } return rc; }
/* * Called from process context when the hub is gone. * Detach all devices on active ports. */ int uhub_detach(struct device *self, int flags) { struct uhub_softc *sc = (struct uhub_softc *)self; struct usbd_hub *hub = sc->sc_hub->hub; struct usbd_port *rup; int port, nports; DPRINTF(("uhub_detach: sc=%p flags=%d\n", sc, flags)); if (hub == NULL) /* Must be partially working */ return (0); usbd_abort_pipe(sc->sc_ipipe); usbd_close_pipe(sc->sc_ipipe); nports = hub->hubdesc.bNbrPorts; for(port = 0; port < nports; port++) { rup = &hub->ports[port]; if (rup->device) usb_disconnect_port(rup, self); } usbd_add_drv_event(USB_EVENT_DRIVER_DETACH, sc->sc_hub, &sc->sc_dev); if (hub->ports[0].tt) free(hub->ports[0].tt, M_USBDEV); free(hub, M_USBDEV); sc->sc_hub->hub = NULL; return (0); }
static int ndisusb_detach(device_t self) { int i, error; struct ndis_softc *sc = device_get_softc(self); struct usb_attach_arg *uaa = device_get_ivars(self); wlan_serialize_enter(); sc->ndisusb_status |= NDISUSB_STATUS_DETACH; for (i = 0; i < NDISUSB_ENDPT_MAX; i++) { if (sc->ndisusb_ep[i] == NULL) continue; usbd_abort_pipe(sc->ndisusb_ep[i]); usbd_close_pipe(sc->ndisusb_ep[i]); sc->ndisusb_ep[i] = NULL; } if (sc->ndisusb_iin_buf != NULL) { kfree(sc->ndisusb_iin_buf, M_USBDEV); sc->ndisusb_iin_buf = NULL; } ndis_pnpevent_nic(self, NDIS_PNP_EVENT_SURPRISE_REMOVED); usbd_add_drv_event(USB_EVENT_DRIVER_DETACH, uaa->device, self); error = ndis_detach(self); wlan_serialize_exit(); return error; }
int uticom_detach(struct device *self, int flags) { struct uticom_softc *sc = (struct uticom_softc *)self; DPRINTF(("%s: uticom_detach: sc = %p\n", sc->sc_dev.dv_xname, sc)); sc->sc_dying = 1; if (sc->sc_subdev != NULL) { config_detach(sc->sc_subdev, flags); sc->sc_subdev = NULL; } if (sc->sc_intr_pipe != NULL) { usbd_abort_pipe(sc->sc_intr_pipe); usbd_close_pipe(sc->sc_intr_pipe); free(sc->sc_intr_buf, M_USBDEV); sc->sc_intr_pipe = NULL; } usbd_add_drv_event(USB_EVENT_DRIVER_DETACH, sc->sc_udev, &sc->sc_dev); return (0); }
int uhidclose(dev_t dev, int flag, int mode, usb_proc_ptr p) { struct uhid_softc *sc; USB_GET_SC(uhid, UHIDUNIT(dev), sc); DPRINTF(("uhidclose: sc=%p\n", sc)); /* Disable interrupts. */ usbd_abort_pipe(sc->sc_intrpipe); usbd_close_pipe(sc->sc_intrpipe); sc->sc_intrpipe = 0; ndflush(&sc->sc_q, sc->sc_q.c_cc); clfree(&sc->sc_q); free(sc->sc_ibuf, M_USBDEV); free(sc->sc_obuf, M_USBDEV); sc->sc_state &= ~UHID_OPEN; sc->sc_async = 0; return (0); }
static void ubsa_close(void *addr, int portno) { struct ubsa_softc *sc; int err; sc = addr; if (sc->sc_ucom.sc_dying) return; DPRINTF(("ubsa_close: close\n")); if (sc->sc_intr_pipe != NULL) { err = usbd_abort_pipe(sc->sc_intr_pipe); if (err) device_printf(sc->sc_ucom.sc_dev, "abort interrupt " "pipe failed: %s\n", usbd_errstr(err)); err = usbd_close_pipe(sc->sc_intr_pipe); if (err) device_printf(sc->sc_ucom.sc_dev, "close interrupt " "pipe failed: %s\n", usbd_errstr(err)); kfree(sc->sc_intr_buf, M_USBDEV); sc->sc_intr_pipe = NULL; } }
static int ukbd_enable_intr(keyboard_t *kbd, int on, usbd_intr_t *func) { ukbd_state_t *state = (ukbd_state_t *)kbd->kb_data; usbd_status err; if (on) { /* Set up interrupt pipe. */ if (state->ks_ifstate & INTRENABLED) { return EBUSY; } state->ks_ifstate |= INTRENABLED; err = usbd_open_pipe_intr(state->ks_iface, state->ks_ep_addr, USBD_SHORT_XFER_OK | USBD_CALLBACK_LAST, &state->ks_intrpipe, kbd, &state->ks_ndata, sizeof(state->ks_ndata), func, USBD_DEFAULT_INTERVAL); if (err) { return (EIO); } } else { /* Disable interrupts. */ usbd_abort_pipe(state->ks_intrpipe); usbd_close_pipe(state->ks_intrpipe); state->ks_ifstate &= ~INTRENABLED; } return (0); }
/* * Called from process context when the hub is gone. * Detach all devices on active ports. */ int uhub_detach(struct device *self, int flags) { struct uhub_softc *sc = (struct uhub_softc *)self; struct usbd_hub *hub = sc->sc_hub->hub; struct usbd_port *rup; int port; if (hub == NULL) /* Must be partially working */ return (0); usbd_abort_pipe(sc->sc_ipipe); usbd_close_pipe(sc->sc_ipipe); for (port = 0; port < hub->nports; port++) { rup = &hub->ports[port]; if (rup->device != NULL) { usbd_detach(rup->device, self); rup->device = NULL; } } if (hub->ports[0].tt) free(hub->ports[0].tt, M_USBDEV, 0); if (sc->sc_statusbuf) free(sc->sc_statusbuf, M_USBDEV, 0); if (hub->ports) free(hub->ports, M_USBDEV, 0); free(hub, M_USBDEV, 0); sc->sc_hub->hub = NULL; return (0); }
int umct_detach(struct device *self, int flags) { struct umct_softc *sc = (struct umct_softc *)self; int rv = 0; DPRINTF(("umct_detach: sc=%p flags=%d\n", sc, flags)); if (sc->sc_intr_pipe != NULL) { usbd_abort_pipe(sc->sc_intr_pipe); usbd_close_pipe(sc->sc_intr_pipe); free(sc->sc_intr_buf, M_USBDEV); sc->sc_intr_pipe = NULL; } sc->sc_dying = 1; if (sc->sc_subdev != NULL) { rv = config_detach(sc->sc_subdev, flags); sc->sc_subdev = NULL; } usbd_add_drv_event(USB_EVENT_DRIVER_DETACH, sc->sc_udev, &sc->sc_dev); return (rv); }
/* **************************************************************** * Função de "detach" * **************************************************************** */ int uhub_detach (struct device *dev) { struct uhub_softc *sc = dev->softc; struct usbd_hub *hub; struct usbd_port *rup; int port, nports; if ((hub = sc->sc_hub->hub) == NULL) return (0); usbd_abort_pipe (sc->sc_ipipe); usbd_close_pipe (sc->sc_ipipe); nports = hub->hubdesc.bNbrPorts; for (port = 0; port < nports; port++) { rup = &hub->ports[port]; if (rup->device) usb_disconnect_port (rup, dev); } free_byte (hub); sc->sc_hub->hub = NULL; return (0); } /* end uhub_detach */
Static void uvscom_close(void *addr, int portno) { struct uvscom_softc *sc = addr; int err; if (sc->sc_dying) return; DPRINTF(("uvscom_close: close\n")); uvscom_shutdown(sc); if (sc->sc_intr_pipe != NULL) { err = usbd_abort_pipe(sc->sc_intr_pipe); if (err) printf("%s: abort interrupt pipe failed: %s\n", USBDEVNAME(sc->sc_dev), usbd_errstr(err)); err = usbd_close_pipe(sc->sc_intr_pipe); if (err) printf("%s: close interrupt pipe failed: %s\n", USBDEVNAME(sc->sc_dev), usbd_errstr(err)); free(sc->sc_intr_buf, M_USBDEV); sc->sc_intr_pipe = NULL; } }
int ubsa_detach(device_t self, int flags) { struct ubsa_softc *sc = device_private(self); int i; int rv = 0; DPRINTF(("ubsa_detach: sc = %p\n", sc)); if (sc->sc_intr_pipe != NULL) { usbd_abort_pipe(sc->sc_intr_pipe); usbd_close_pipe(sc->sc_intr_pipe); free(sc->sc_intr_buf, M_USBDEV); sc->sc_intr_pipe = NULL; } sc->sc_dying = 1; for (i = 0; i < sc->sc_numif; i++) { if (sc->sc_subdevs[i] != NULL) rv |= config_detach(sc->sc_subdevs[i], flags); } usbd_add_drv_event(USB_EVENT_DRIVER_DETACH, sc->sc_udev, sc->sc_dev); return (rv); }
int urioopen(dev_t dev, int flag, int mode, struct lwp *l) { struct urio_softc *sc; usbd_status err; sc = device_lookup_private(&urio_cd, URIOUNIT(dev)); if (sc == NULL) return ENXIO; DPRINTFN(5, ("urioopen: flag=%d, mode=%d, unit=%d\n", flag, mode, URIOUNIT(dev))); if (sc->sc_dying) return (EIO); if (sc->sc_in_pipe != NULL) return (EBUSY); if ((flag & (FWRITE|FREAD)) != (FWRITE|FREAD)) return (EACCES); err = usbd_open_pipe(sc->sc_iface, sc->sc_in_addr, 0, &sc->sc_in_pipe); if (err) return (EIO); err = usbd_open_pipe(sc->sc_iface, sc->sc_out_addr,0,&sc->sc_out_pipe); if (err) { usbd_close_pipe(sc->sc_in_pipe); sc->sc_in_pipe = NULL; return (EIO); } return (0); }
static int u3g_detach(device_t self, int flags) { struct u3g_softc *sc = device_private(self); int rv; if (sc->sc_dying) return 0; pmf_device_deregister(self); if (sc->sc_ucom != NULL) { rv = config_detach(sc->sc_ucom, flags); if (rv != 0) { aprint_verbose_dev(self, "Can't deallocate " "port (%d)", rv); } } if (sc->sc_intr_pipe != NULL) { (void) usbd_abort_pipe(sc->sc_intr_pipe); (void) usbd_close_pipe(sc->sc_intr_pipe); sc->sc_intr_pipe = NULL; } if (sc->sc_intr_buff != NULL) { free(sc->sc_intr_buff, M_USBDEV); sc->sc_intr_buff = NULL; } return (0); }
static int udsir_detach(device_t self, int flags) { struct udsir_softc *sc = device_private(self); int s; int rv = 0; DPRINTFN(0, ("udsir_detach: sc=%p flags=%d\n", sc, flags)); sc->sc_closing = sc->sc_dying = 1; wakeup(&sc->sc_thread); while (sc->sc_thread != NULL) tsleep(&sc->sc_closing, PWAIT, "usircl", 0); /* Abort all pipes. Causes processes waiting for transfer to wake. */ if (sc->sc_rd_pipe != NULL) { usbd_abort_pipe(sc->sc_rd_pipe); usbd_close_pipe(sc->sc_rd_pipe); sc->sc_rd_pipe = NULL; } if (sc->sc_wr_pipe != NULL) { usbd_abort_pipe(sc->sc_wr_pipe); usbd_close_pipe(sc->sc_wr_pipe); sc->sc_wr_pipe = NULL; } wakeup(&sc->sc_ur_framelen); wakeup(&sc->sc_wr_buf); s = splusb(); if (--sc->sc_refcnt >= 0) { /* Wait for processes to go away. */ usb_detach_waitold(sc->sc_dev); } splx(s); if (sc->sc_child != NULL) rv = config_detach(sc->sc_child, flags); usbd_add_drv_event(USB_EVENT_DRIVER_DETACH, sc->sc_udev, sc->sc_dev); seldestroy(&sc->sc_rd_sel); seldestroy(&sc->sc_wr_sel); return rv; }
static void free_pipe(struct umidi_endpoint *ep) { DPRINTF(("%s: %s %p\n", ep->sc->sc_dev.dv_xname, __func__, ep)); usbd_abort_pipe(ep->pipe); usbd_close_pipe(ep->pipe); usbd_free_xfer(ep->xfer); }
void cdc_close_data_pipes(uwh_cdc_dev_h dev_ctx) { jcdc_dev_softc_t *sc = (jcdc_dev_softc_t *)dev_ctx; if (sc->bulk_pipe_in) { usbd_abort_pipe(sc->bulk_pipe_in); usbd_close_pipe(sc->bulk_pipe_in); sc->bulk_pipe_in = NULL; } if (sc->bulk_pipe_out) { usbd_abort_pipe(sc->bulk_pipe_out); usbd_close_pipe(sc->bulk_pipe_out); sc->bulk_pipe_out = NULL; } }
Static void cdce_stop(struct cdce_softc *sc) { usbd_status err; struct ifnet *ifp; CDCE_LOCK(sc); cdce_reset(sc); ifp = GET_IFP(sc); ifp->if_timer = 0; if (sc->cdce_bulkin_pipe != NULL) { err = usbd_abort_pipe(sc->cdce_bulkin_pipe); if (err) printf("%s: abort rx pipe failed: %s\n", USBDEVNAME(sc->cdce_dev), usbd_errstr(err)); err = usbd_close_pipe(sc->cdce_bulkin_pipe); if (err) printf("%s: close rx pipe failed: %s\n", USBDEVNAME(sc->cdce_dev), usbd_errstr(err)); sc->cdce_bulkin_pipe = NULL; } if (sc->cdce_bulkout_pipe != NULL) { err = usbd_abort_pipe(sc->cdce_bulkout_pipe); if (err) printf("%s: abort tx pipe failed: %s\n", USBDEVNAME(sc->cdce_dev), usbd_errstr(err)); err = usbd_close_pipe(sc->cdce_bulkout_pipe); if (err) printf("%s: close tx pipe failed: %s\n", USBDEVNAME(sc->cdce_dev), usbd_errstr(err)); sc->cdce_bulkout_pipe = NULL; } usb_ether_rx_list_free(&sc->cdce_cdata); usb_ether_tx_list_free(&sc->cdce_cdata); ifp->if_flags &= ~(IFF_RUNNING | IFF_OACTIVE); CDCE_UNLOCK(sc); return; }
void uhidev_close(struct uhidev *scd) { struct uhidev_softc *sc = scd->sc_parent; if (!(scd->sc_state & UHIDEV_OPEN)) return; scd->sc_state &= ~UHIDEV_OPEN; if (--sc->sc_refcnt) return; DPRINTF(("uhidev_close: close pipe\n")); if (sc->sc_oxfer != NULL) { usbd_free_xfer(sc->sc_oxfer); sc->sc_oxfer = NULL; } if (sc->sc_owxfer != NULL) { usbd_free_xfer(sc->sc_owxfer); sc->sc_owxfer = NULL; } if (sc->sc_ixfer != NULL) { usbd_free_xfer(sc->sc_ixfer); sc->sc_ixfer = NULL; } /* Disable interrupts. */ if (sc->sc_opipe != NULL) { usbd_abort_pipe(sc->sc_opipe); usbd_close_pipe(sc->sc_opipe); sc->sc_opipe = NULL; } if (sc->sc_ipipe != NULL) { usbd_abort_pipe(sc->sc_ipipe); usbd_close_pipe(sc->sc_ipipe); sc->sc_ipipe = NULL; } if (sc->sc_ibuf != NULL) { free(sc->sc_ibuf, M_USBDEV, 0); sc->sc_ibuf = NULL; } }
static void free_pipe(struct umidi_endpoint *ep) { DPRINTF(("%s: free_pipe %p\n", USBDEVNAME(ep->sc->sc_dev), ep)); usbd_abort_pipe(ep->pipe); usbd_close_pipe(ep->pipe); usbd_free_xfer(ep->xfer); softint_disestablish(ep->solicit_cookie); }
static int atausb_detach(device_t dev) { struct atausb_softc *sc = device_get_softc(dev); usbd_device_handle udev; device_t *children; int nchildren, i; /* signal that device is going away */ sc->state = ATAUSB_S_DETACH; /* abort all the pipes in case there are active transfers */ usbd_interface2device_handle(sc->iface, &udev); usbd_abort_pipe(udev->default_pipe); if (sc->bulkout_pipe) usbd_abort_pipe(sc->bulkout_pipe); if (sc->bulkin_pipe) usbd_abort_pipe(sc->bulkin_pipe); if (sc->bulkirq_pipe) usbd_abort_pipe(sc->bulkirq_pipe); /* detach & delete all children */ if (!device_get_children(dev, &children, &nchildren)) { for (i = 0; i < nchildren; i++) device_delete_child(dev, children[i]); kfree(children, M_TEMP); } /* free the transfers */ for (i = 0; i < ATAUSB_T_MAX; i++) if (sc->transfer[i]) usbd_free_xfer(sc->transfer[i]); /* remove all the pipes */ if (sc->bulkout_pipe) usbd_close_pipe(sc->bulkout_pipe); if (sc->bulkin_pipe) usbd_close_pipe(sc->bulkin_pipe); if (sc->bulkirq_pipe) usbd_close_pipe(sc->bulkirq_pipe); spin_uninit(&sc->locked_mtx); return 0; }