From 3bee31de4a934dd2c7798c7a80be080f02cf0220 Mon Sep 17 00:00:00 2001 From: Markus Pfeiffer Date: Tue, 25 Feb 2014 22:14:46 +0000 Subject: [PATCH] usb4bsd: port usb_serial --- sys/bus/u4b/serial/usb_serial.c | 26 +++++++++++++++----------- sys/bus/u4b/serial/usb_serial.h | 1 + 2 files changed, 16 insertions(+), 11 deletions(-) diff --git a/sys/bus/u4b/serial/usb_serial.c b/sys/bus/u4b/serial/usb_serial.c index 789f876ac9..cc26045c63 100644 --- a/sys/bus/u4b/serial/usb_serial.c +++ b/sys/bus/u4b/serial/usb_serial.c @@ -81,7 +81,8 @@ #include #include #include - +#include + #include #include #include @@ -395,7 +396,6 @@ ucom_drain(struct ucom_super_softc *ssc) void ucom_drain_all(void *arg) { -#if XXX lockmgr(&ucom_lock, LK_EXCLUSIVE); while (ucom_close_refs > 0) { kprintf("ucom: Waiting for all detached TTY " @@ -403,7 +403,6 @@ ucom_drain_all(void *arg) usb_pause_mtx(&ucom_lock, hz); } lockmgr(&ucom_lock, LK_RELEASE); -#endif } static int @@ -411,13 +410,15 @@ ucom_attach_tty(struct ucom_super_softc *ssc, struct ucom_softc *sc) { struct tty *tp; char buf[32]; /* temporary TTY device name buffer */ + cdev_t dev; - /* - tp = tty_alloc_mutex(&ucom_class, sc, sc->sc_lock); - */ - tp = NULL; - if (tp == NULL) + lwkt_gettoken(&tty_token); + + tp = ttymalloc(sc->sc_tty); + if (tp == NULL) { + lwkt_reltoken(&tty_token); return (ENOMEM); + } /* Check if the client has a custom TTY name */ buf[0] = '\0'; @@ -437,10 +438,12 @@ ucom_attach_tty(struct ucom_super_softc *ssc, struct ucom_softc *sc) ssc->sc_unit); } } - /* - tty_makedev(tp, NULL, "%s", buf); - */ + + dev = make_dev(&ucom_ops, ssc->sc_unit | 0x80, // XXX UCOM_CALLOUT_MASK, + UID_UUCP, GID_DIALER, 0660, + buf, ssc->sc_unit); sc->sc_tty = tp; + sc->sc_dev = dev; DPRINTF("ttycreate: %s\n", buf); @@ -471,6 +474,7 @@ ucom_attach_tty(struct ucom_super_softc *ssc, struct ucom_softc *sc) UCOM_MTX_UNLOCK(ucom_cons_softc); } + lwkt_reltoken(&tty_token); return (0); } diff --git a/sys/bus/u4b/serial/usb_serial.h b/sys/bus/u4b/serial/usb_serial.h index 55b97ee9f7..13db5fe6ca 100644 --- a/sys/bus/u4b/serial/usb_serial.h +++ b/sys/bus/u4b/serial/usb_serial.h @@ -166,6 +166,7 @@ struct ucom_softc { const struct ucom_callback *sc_callback; struct ucom_super_softc *sc_super; struct tty *sc_tty; + struct dev *sc_dev; struct lock *sc_lock; void *sc_parent; int sc_subunit; -- 2.41.0