Ejemplo n.º 1
0
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;
	}
}
Ejemplo n.º 2
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;
		}
	}
}
Ejemplo n.º 3
0
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);
}
Ejemplo n.º 4
0
int
ulpt_detach(struct device *self, int flags)
{
	struct ulpt_softc *sc = (struct ulpt_softc *)self;
	int s;
	int maj, mn;

	DPRINTF(("ulpt_detach: sc=%p\n", sc));

	if (sc->sc_out_pipe != NULL)
		usbd_abort_pipe(sc->sc_out_pipe);
	if (sc->sc_in_pipe != NULL)
		usbd_abort_pipe(sc->sc_in_pipe);

	s = splusb();
	if (--sc->sc_refcnt >= 0) {
		/* There is noone to wake, aborting the pipe is enough */
		/* Wait for processes to go away. */
		usb_detach_wait(&sc->sc_dev);
	}
	splx(s);

	/* locate the major number */
	for (maj = 0; maj < nchrdev; maj++)
		if (cdevsw[maj].d_open == ulptopen)
			break;

	/* Nuke the vnodes for any open instances (calls close). */
	mn = self->dv_unit;
	vdevgone(maj, mn, mn, VCHR);
	vdevgone(maj, mn | ULPT_NOPRIME , mn | ULPT_NOPRIME, VCHR);

	return (0);
}
Ejemplo n.º 5
0
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;
	}
}
Ejemplo n.º 6
0
void cdc_abort_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);

    if (sc->bulk_pipe_out)
        usbd_abort_pipe(sc->bulk_pipe_out);
}
Ejemplo n.º 7
0
/*
 * 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;
		}
	}
}
Ejemplo n.º 8
0
/* 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;
}
Ejemplo n.º 9
0
int
ucom_detach(struct device *self, int flags)
{
	struct ucom_softc *sc = (struct ucom_softc *)self;
	struct tty *tp = sc->sc_tty;
	int maj, mn;
	int s;

	DPRINTF(("ucom_detach: sc=%p flags=%d tp=%p, pipe=%d,%d\n",
		 sc, flags, tp, sc->sc_bulkin_no, sc->sc_bulkout_no));

	sc->sc_dying = 1;

	if (sc->sc_bulkin_pipe != NULL)
		usbd_abort_pipe(sc->sc_bulkin_pipe);
	if (sc->sc_bulkout_pipe != NULL)
		usbd_abort_pipe(sc->sc_bulkout_pipe);

	s = splusb();
	if (--sc->sc_refcnt >= 0) {
		/* Wake up anyone waiting */
		if (tp != NULL) {
			CLR(tp->t_state, TS_CARR_ON);
			CLR(tp->t_cflag, CLOCAL | MDMBUF);
			ttyflush(tp, FREAD|FWRITE);
		}
		/* Wait for processes to go away. */
		usb_detach_wait(&sc->sc_dev);
	}
	splx(s);

	/* locate the major number */
	for (maj = 0; maj < nchrdev; maj++)
		if (cdevsw[maj].d_open == ucomopen)
			break;

	/* Nuke the vnodes for any open instances. */
	mn = self->dv_unit;
	DPRINTF(("ucom_detach: maj=%d mn=%d\n", maj, mn));
	vdevgone(maj, mn, mn, VCHR);
	vdevgone(maj, mn | UCOMCUA_MASK, mn | UCOMCUA_MASK, VCHR);

	/* Detach and free the tty. */
	if (tp != NULL) {
		ttyfree(tp);
		sc->sc_tty = NULL;
	}

	return (0);
}
Ejemplo n.º 10
0
Archivo: uhid.c Proyecto: MarginC/kame
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);
}
Ejemplo n.º 11
0
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);
}
Ejemplo n.º 12
0
int
uhidev_detach(device_t self, int flags)
{
	struct uhidev_softc *sc = device_private(self);
	int i, rv;
	struct uhidev *csc;

	DPRINTF(("uhidev_detach: sc=%p flags=%d\n", sc, flags));

	sc->sc_dying = 1;
	if (sc->sc_ipipe != NULL)
		usbd_abort_pipe(sc->sc_ipipe);

	if (sc->sc_repdesc != NULL)
		kmem_free(sc->sc_repdesc, sc->sc_repdesc_size);

	rv = 0;
	for (i = 0; i < sc->sc_nrepid; i++) {
		if (sc->sc_subdevs[i] != NULL) {
			csc = device_private(sc->sc_subdevs[i]);
			rnd_detach_source(&csc->rnd_source);
			rv |= config_detach(sc->sc_subdevs[i], flags);
		}
	}

	usbd_add_drv_event(USB_EVENT_DRIVER_DETACH, sc->sc_udev, sc->sc_dev);

	pmf_device_deregister(self);
	mutex_destroy(&sc->sc_lock);

	return rv;
}
Ejemplo n.º 13
0
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;
	}
}
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;
}
Ejemplo n.º 15
0
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;
	}
}
Ejemplo n.º 16
0
usbd_status
usbd_intr_transfer(usbd_xfer_handle xfer, usbd_pipe_handle pipe,
    u_int16_t flags, u_int32_t timeout, void *buf, u_int32_t *size, char *lbl)
{
	usbd_status err;
	int s, error;

	usbd_setup_xfer(xfer, pipe, 0, buf, *size, flags, timeout,
	    usbd_intr_transfer_cb);
	DPRINTFN(1, ("usbd_intr_transfer: start transfer %d bytes\n", *size));
	s = splusb();		/* don't want callback until tsleep() */
	err = usbd_transfer(xfer);
	if (err != USBD_IN_PROGRESS) {
		splx(s);
		return (err);
	}
	error = tsleep(xfer, PZERO | PCATCH, lbl, 0);
	splx(s);
	if (error) {
		DPRINTF(("usbd_intr_transfer: tsleep=%d\n", error));
		usbd_abort_pipe(pipe);
		return (USBD_INTERRUPTED);
	}
	usbd_get_xfer_status(xfer, NULL, NULL, size, &err);
	DPRINTFN(1,("usbd_intr_transfer: transferred %d\n", *size));
	if (err) {
		DPRINTF(("usbd_intr_transfer: error=%d\n", err));
		usbd_clear_endpoint_stall(pipe);
	}
	return (err);
}
Ejemplo n.º 17
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;
}
Ejemplo n.º 18
0
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);
}
Ejemplo n.º 19
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, 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);
}
Ejemplo n.º 20
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);
}
Ejemplo n.º 21
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;
	}
}
Ejemplo n.º 22
0
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);
}
Ejemplo n.º 23
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);
}
Ejemplo n.º 24
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);
}
Ejemplo n.º 25
0
int
uhidev_detach(struct device *self, int flags)
{
	struct uhidev_softc *sc = (struct uhidev_softc *)self;
	int i, rv;

	DPRINTF(("uhidev_detach: sc=%p flags=%d\n", sc, flags));

	sc->sc_dying = 1;
	if (sc->sc_ipipe != NULL)
		usbd_abort_pipe(sc->sc_ipipe);

	if (sc->sc_repdesc != NULL)
		free(sc->sc_repdesc, M_USBDEV);

	rv = 0;
	for (i = 0; i < sc->sc_nrepid; i++) {
		if (sc->sc_subdevs[i] != NULL) {
			rv |= config_detach(&sc->sc_subdevs[i]->sc_dev, flags);
			sc->sc_subdevs[i] = NULL;
		}
	}

	usbd_add_drv_event(USB_EVENT_DRIVER_DETACH, sc->sc_udev,
			   &sc->sc_dev);

	return (rv);
}
Ejemplo n.º 26
0
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;
	}
}
Ejemplo n.º 27
0
/*
 ****************************************************************
 *	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 */
Ejemplo n.º 28
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;
}
Ejemplo n.º 29
0
/* Comment    : Must be called before any other devi_hid... function                */
void devi_unregister_usb_client(void * h)
{
   int rc;
   pModule_data_t pModule = (pModule_data_t)h;
   struct timespec t;
   
   assert(pModule);

   
   if(pModule -> ep_int)
     {
     usbd_reset_pipe(pModule -> ep_int);
     usbd_abort_pipe(pModule -> ep_int);
     }

   if(pModule -> ep_cntl)
     usbd_abort_pipe(pModule -> ep_cntl);

   if(pModule -> urb)
     usbd_free_urb(pModule -> urb);
   
   if(pModule -> ep_int_buf)
     usbd_free(pModule -> ep_int_buf);
   
   if(pModule -> ep_cnt_buf)
     usbd_free(pModule -> ep_cnt_buf);

   sleep(1);
   
   if(EOK != (rc = usbd_detach(pModule -> pDevice)))
     {
     if(verbosity)
	fprintf(stderr, "Detach device: error %i\n", rc);
     }
   
   clock_gettime(CLOCK_REALTIME, &t);
   t.tv_sec += MAX_TIME_WAIT;
   if(EOK !=  pthread_mutex_timedlock(&mod_mutex, &t))
      return ;
   
   LIST_REMOVE(pModule, lst_conn);
  
   pthread_mutex_unlock(&mod_mutex);

   free(pModule);

}
Ejemplo n.º 30
0
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;
    }
}