From 658d4b51ac3dbb6a7b6e686d4199c8318339cd36 Mon Sep 17 00:00:00 2001 From: Sam Leffler Date: Tue, 25 Mar 2008 23:46:24 +0000 Subject: [PATCH] split out tty create part of ucom_attach into ucom_attach_tty so derived drivers can use it Submitted by: Jared Go MFC after: 3 weeks --- sys/dev/usb/ucom.c | 19 ++++++++++++------- sys/dev/usb/ucomvar.h | 1 + 2 files changed, 13 insertions(+), 7 deletions(-) diff --git a/sys/dev/usb/ucom.c b/sys/dev/usb/ucom.c index 20fb7ea6e9a4..f99a73ab4ad7 100644 --- a/sys/dev/usb/ucom.c +++ b/sys/dev/usb/ucom.c @@ -161,12 +161,9 @@ ucom_modevent(module_t mod, int type, void *data) } int -ucom_attach(struct ucom_softc *sc) +ucom_attach_tty(struct ucom_softc *sc, int flags, char* fmt, int unit) { struct tty *tp; - int unit; - - unit = device_get_unit(sc->sc_dev); sc->sc_tty = tp = ttyalloc(); tp->t_sc = sc; @@ -179,10 +176,18 @@ ucom_attach(struct ucom_softc *sc) tp->t_modem = ucommodem; tp->t_ioctl = ucomioctl; - DPRINTF(("ucom_attach: tty_attach tp = %p\n", tp)); + return ttycreate(tp, flags, fmt, unit); +} - ttycreate(tp, TS_CALLOUT, "U%d", unit); - DPRINTF(("ucom_attach: ttycreate: ttyU%d\n", unit)); +int +ucom_attach(struct ucom_softc *sc) +{ + + ucom_attach_tty(sc, TS_CALLOUT, + "U%d", device_get_unit(sc->sc_dev)); + + DPRINTF(("ucom_attach: ttycreate: tp = %p, %s\n", + sc->sc_tty, sc->sc_tty->t_dev->si_name)); return (0); } diff --git a/sys/dev/usb/ucomvar.h b/sys/dev/usb/ucomvar.h index 25cbc53d70e4..4a5ddd211902 100644 --- a/sys/dev/usb/ucomvar.h +++ b/sys/dev/usb/ucomvar.h @@ -159,6 +159,7 @@ struct ucom_softc { extern devclass_t ucom_devclass; +int ucom_attach_tty(struct ucom_softc *, int, char*, int); int ucom_attach(struct ucom_softc *); int ucom_detach(struct ucom_softc *); void ucom_status_change(struct ucom_softc *);