Beispiel #1
0
int
xencons_close(dev_t dev, int flag, int mode, struct lwp *l)
{
    struct xencons_softc *sc = device_lookup_private(&xencons_cd,
                               XENCONS_UNIT(dev));
    struct tty *tp = sc->sc_tty;

    if (tp == NULL)
        return (0);
    (*tp->t_linesw->l_close)(tp, flag);
    ttyclose(tp);
#ifdef notyet /* XXX */
    tty_free(tp);
#endif
    return (0);
}
/*ARGSUSED*/
int
mfcsclose(dev_t dev, int flag, int mode, struct lwp *l)
{
	struct tty *tp;
	int unit;
	struct mfcs_softc *sc = device_lookup_private(&mfcs_cd, dev & 31);
	struct mfc_softc *scc= sc->sc_mfc;

	unit = dev & 31;

	tp = sc->sc_tty;
	tp->t_linesw->l_close(tp, flag);
	sc->sc_duart->ch_cr = 0x70;			/* stop break */

	scc->imask &= ~(0x7 << ((unit & 1) * 4));
	scc->sc_regs->du_imr = scc->imask;
	if (sc->flags & CT_USED) {
		--scc->ct_usecnt;
		sc->flags &= ~CT_USED;
	}

	/*
	 * If the device is closed, it's close, no matter whether we deal with
	 * modem control signals nor not.
	 */
#if 0
	if (tp->t_cflag & HUPCL || tp->t_wopen != 0 ||
	    (tp->t_state & TS_ISOPEN) == 0)
#endif
		(void) mfcsmctl(dev, 0, DMSET);
	ttyclose(tp);
#if not_yet
	if (tp != &mfcs_cons) {
		remove_vbl_function(&sc->vbl_node);
		tty_free(tp);
		sc->sc_tty = (struct tty *) NULL;
	}
#endif
	return (0);
}
Beispiel #3
0
int
ucom_detach(device_t self, int flags)
{
	struct ucom_softc *sc = device_private(self);
	struct tty *tp = sc->sc_tty;
	int maj, mn;
	int s, i;

	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;
	pmf_device_deregister(self);

	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) {
			mutex_spin_enter(&tty_lock);
			CLR(tp->t_state, TS_CARR_ON);
			CLR(tp->t_cflag, CLOCAL | MDMBUF);
			ttyflush(tp, FREAD|FWRITE);
			mutex_spin_exit(&tty_lock);
		}
		/* Wait for processes to go away. */
		usb_detach_waitold(sc->sc_dev);
	}

	softint_disestablish(sc->sc_si);
	splx(s);

	/* locate the major number */
	maj = cdevsw_lookup_major(&ucom_cdevsw);

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

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

	for (i = 0; i < UCOM_IN_BUFFS; i++) {
		if (sc->sc_ibuff[i].ub_xfer != NULL)
			usbd_free_xfer(sc->sc_ibuff[i].ub_xfer);
	}

	for (i = 0; i < UCOM_OUT_BUFFS; i++) {
		if (sc->sc_obuff[i].ub_xfer != NULL)
			usbd_free_xfer(sc->sc_obuff[i].ub_xfer);
	}

	/* Detach the random source */
	rnd_detach_source(&sc->sc_rndsource);

	return (0);
}