From owner-p4-projects@FreeBSD.ORG Sun Oct 8 21:33:00 2006 Return-Path: X-Original-To: p4-projects@freebsd.org Delivered-To: p4-projects@freebsd.org Received: by hub.freebsd.org (Postfix, from userid 32767) id 4E1F216A47E; Sun, 8 Oct 2006 21:33:00 +0000 (UTC) X-Original-To: perforce@FreeBSD.org Delivered-To: perforce@FreeBSD.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 0F6A916A403 for ; Sun, 8 Oct 2006 21:33:00 +0000 (UTC) (envelope-from hselasky@FreeBSD.org) Received: from repoman.freebsd.org (repoman.freebsd.org [216.136.204.115]) by mx1.FreeBSD.org (Postfix) with ESMTP id B11F643D45 for ; Sun, 8 Oct 2006 21:32:59 +0000 (GMT) (envelope-from hselasky@FreeBSD.org) Received: from repoman.freebsd.org (localhost [127.0.0.1]) by repoman.freebsd.org (8.13.6/8.13.6) with ESMTP id k98LWxsJ079330 for ; Sun, 8 Oct 2006 21:32:59 GMT (envelope-from hselasky@FreeBSD.org) Received: (from perforce@localhost) by repoman.freebsd.org (8.13.6/8.13.4/Submit) id k98LWxMr079318 for perforce@freebsd.org; Sun, 8 Oct 2006 21:32:59 GMT (envelope-from hselasky@FreeBSD.org) Date: Sun, 8 Oct 2006 21:32:59 GMT Message-Id: <200610082132.k98LWxMr079318@repoman.freebsd.org> X-Authentication-Warning: repoman.freebsd.org: perforce set sender to hselasky@FreeBSD.org using -f From: Hans Petter Selasky To: Perforce Change Reviews Cc: Subject: PERFORCE change 107514 for review X-BeenThere: p4-projects@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: p4 projects tree changes List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 08 Oct 2006 21:33:00 -0000 http://perforce.freebsd.org/chv.cgi?CH=107514 Change 107514 by hselasky@hselasky_mini_itx on 2006/10/08 21:32:00 UCOM API change: Pass initializers to ucom_attach() instead of writing them directly to the "ucom_softc", except sc_portno. Make the UCOM-layer multi-port friendly, by allowing to specify number of "sub_units" when attaching a ucom device. Allow calls to "ucom_get_data()" and "ucom_put_data()" outside open/close. This makes supporting multi-port devices easier. Some other small changes. Affected files ... .. //depot/projects/usb/src/sys/dev/usb/ubsa.c#12 edit .. //depot/projects/usb/src/sys/dev/usb/ucom.c#11 edit .. //depot/projects/usb/src/sys/dev/usb/ucomvar.h#7 edit .. //depot/projects/usb/src/sys/dev/usb/ucycom.c#8 edit .. //depot/projects/usb/src/sys/dev/usb/ufoma.c#10 edit .. //depot/projects/usb/src/sys/dev/usb/uftdi.c#11 edit .. //depot/projects/usb/src/sys/dev/usb/umct.c#8 edit .. //depot/projects/usb/src/sys/dev/usb/umodem.c#12 edit .. //depot/projects/usb/src/sys/dev/usb/uplcom.c#11 edit .. //depot/projects/usb/src/sys/dev/usb/uvisor.c#10 edit .. //depot/projects/usb/src/sys/dev/usb/uvscom.c#13 edit Differences ... ==== //depot/projects/usb/src/sys/dev/usb/ubsa.c#12 (text+ko) ==== @@ -440,13 +440,15 @@ { 0, 0 } }; +static devclass_t ubsa_devclass; + static driver_t ubsa_driver = { - .name = "ucom", + .name = "ubsa", .methods = ubsa_methods, .size = sizeof(struct ubsa_softc), }; -DRIVER_MODULE(ubsa, uhub, ubsa_driver, ucom_devclass, usbd_driver_load, 0); +DRIVER_MODULE(ubsa, uhub, ubsa_driver, ubsa_devclass, usbd_driver_load, 0); MODULE_DEPEND(ubsa, usb, 1, 1, 1); MODULE_DEPEND(ubsa, ucom, UCOM_MINVER, UCOM_PREFVER, UCOM_MAXVER); MODULE_VERSION(ubsa, UBSA_MODVER); @@ -526,12 +528,8 @@ sc->sc_dtr = -1; sc->sc_rts = -1; - sc->sc_ucom.sc_parent = sc; - sc->sc_ucom.sc_portno = 0; - sc->sc_ucom.sc_callback = &ubsa_callback; - - error = ucom_attach(&(sc->sc_ucom), dev); - + error = ucom_attach(&(sc->sc_ucom), 1, sc, + &ubsa_callback, &Giant); if (error) { DPRINTF(0, "ucom_attach failed\n"); goto detach; @@ -551,7 +549,7 @@ DPRINTF(0, "sc=%p\n", sc); - ucom_detach(&(sc->sc_ucom)); + ucom_detach(&(sc->sc_ucom), 1); usbd_transfer_unsetup(sc->sc_xfer, UBSA_N_TRANSFER); ==== //depot/projects/usb/src/sys/dev/usb/ucom.c#11 (text+ko) ==== @@ -97,7 +97,19 @@ #define DPRINTF(...) #endif +static uint8_t +ucom_units_alloc(uint32_t sub_units, uint32_t *p_root_unit); + static void +ucom_units_free(uint32_t root_unit, uint32_t sub_units); + +static int +ucom_attach_sub(struct ucom_softc *sc); + +static void +ucom_detach_sub(struct ucom_softc *sc); + +static void ucom_shutdown(struct ucom_softc *sc); static int @@ -134,8 +146,6 @@ static void ucom_stop_write(struct tty *tp, int fflags); -devclass_t ucom_devclass; - static moduledata_t ucom_mod = { "ucom", NULL, @@ -146,25 +156,153 @@ MODULE_DEPEND(ucom, usb, 1, 1, 1); MODULE_VERSION(ucom, UCOM_MODVER); +#define UCOM_UNIT_MAX 0x1000 /* exclusive */ + +static uint8_t ucom_bitmap[(UCOM_UNIT_MAX+7)/8]; + +static uint8_t +ucom_units_alloc(uint32_t sub_units, uint32_t *p_root_unit) +{ + uint32_t n; + uint32_t o; + uint32_t x; + uint32_t max = UCOM_UNIT_MAX - (UCOM_UNIT_MAX % sub_units); + uint8_t error = 1; + + mtx_lock(&Giant); + + for (n = 0; n < max; n += sub_units) { + + /* check for free consecutive bits */ + + for (o = 0; o < sub_units; o++) { + + x = n + o; + + if (ucom_bitmap[x/8] & (1<< (x % 8))) { + goto skip; + } + } + + /* allocate */ + + for (o = 0; o < sub_units; o++) { + + x = n + o; + + ucom_bitmap[x/8] |= (1<< (x % 8)); + } + + *p_root_unit = n; + + error = 0; + + break; + + skip: ; + } + + mtx_unlock(&Giant); + + return error; +} + +static void +ucom_units_free(uint32_t root_unit, uint32_t sub_units) +{ + uint32_t x; + + mtx_lock(&Giant); + + while(sub_units--) { + x = root_unit + sub_units; + ucom_bitmap[x/8] &= ~(1<<(x%8)); + } + + mtx_unlock(&Giant); + + return; +} + +/* + * "N" sub_units are setup at a time. All sub-units will + * be given sequential unit numbers. The number of + * sub-units can be used to differentiate among + * different types of devices. + * + * The mutex pointed to by "p_mtx" is applied before all + * callbacks are called back. Also "p_mtx" must be applied + * before calling into the ucom-layer! Currently only Giant + * is supported. + */ int -ucom_attach(struct ucom_softc *sc, device_t dev) +ucom_attach(struct ucom_softc *sc, uint32_t sub_units, void *parent, + const struct ucom_callback *callback, struct mtx *p_mtx) { - struct tty *tp; + uint32_t n; + uint32_t root_unit; int error = 0; - int unit; + + if ((p_mtx != &Giant) || /* XXX TTY layer requires Giant */ + (sc == NULL) || + (sub_units == 0) || + (callback == NULL)) { + return EINVAL; + } + + if (ucom_units_alloc(sub_units, &root_unit)) { + return ENOMEM; + } + + for (n = 0; n < sub_units; n++, sc++) { + sc->sc_unit = root_unit + n; + sc->sc_parent_mtx = p_mtx; + sc->sc_parent = parent; + sc->sc_callback = callback; + + mtx_lock(&Giant); /* XXX TTY layer */ + error = ucom_attach_sub(sc); + mtx_unlock(&Giant); /* XXX TTY layer */ + + if (error) { + ucom_detach(sc - n, n); + ucom_units_free(root_unit + n, sub_units - n); + break; + } + sc->sc_flag |= UCOM_FLAG_ATTACHED; + } + return error; +} + +/* NOTE: the following function will do nothing if + * structure pointed to by "sc" is zero. + */ +void +ucom_detach(struct ucom_softc *sc, uint32_t sub_units) +{ + uint32_t n; + + for (n = 0; n < sub_units; n++, sc++) { + if (sc->sc_flag & UCOM_FLAG_ATTACHED) { + + mtx_lock(&Giant); /* XXX TTY layer */ + ucom_detach_sub(sc); + mtx_unlock(&Giant); /* XXX TTY layer */ - mtx_assert(&Giant, MA_OWNED); + ucom_units_free(sc->sc_unit, 1); - if (device_get_devclass(dev) != ucom_devclass) { - /* NOTE: if all devices are not in the same - * devclass, we get duplicate unit numbers - * which will crash the TTY layer! - */ - error = EINVAL; - goto done; + /* avoid duplicate detach: */ + sc->sc_flag &= ~UCOM_FLAG_ATTACHED; + } } + return; +} - unit = device_get_unit(dev); +static int +ucom_attach_sub(struct ucom_softc *sc) +{ + struct tty *tp; + int error = 0; tp = ttyalloc(); @@ -183,12 +321,12 @@ tp->t_modem = ucom_modem; tp->t_ioctl = ucom_ioctl; - DPRINTF(0, "tp = %p\n", tp); + DPRINTF(0, "tp = %p, unit = %d\n", tp, sc->sc_unit); #ifndef TS_CALLOUT -#define TS_CALLOUT NULL, unit, MINOR_CALLOUT /* compile fix for FreeBSD 6.x */ +#define TS_CALLOUT NULL, sc->sc_unit, MINOR_CALLOUT /* compile fix for FreeBSD 6.x */ #endif - error = ttycreate(tp, TS_CALLOUT, "U%d", unit); + error = ttycreate(tp, TS_CALLOUT, "U%d", sc->sc_unit); if (error) { ttyfree(tp); goto done; @@ -198,23 +336,22 @@ TASK_INIT(&(sc->sc_task), 0, &ucom_notify, sc); - DPRINTF(0, "ttycreate: ttyU%d\n", unit); + DPRINTF(0, "ttycreate: ttyU%d\n", sc->sc_unit); done: return error; } -void -ucom_detach(struct ucom_softc *sc) +static void +ucom_detach_sub(struct ucom_softc *sc) { struct tty *tp = sc->sc_tty; - mtx_assert(&Giant, MA_OWNED); - DPRINTF(0, "sc = %p, tp = %p\n", sc, sc->sc_tty); sc->sc_flag |= UCOM_FLAG_GONE; - + sc->sc_flag &= ~(UCOM_FLAG_READ_ON| + UCOM_FLAG_WRITE_ON); if (tp) { ttygone(tp); @@ -299,6 +436,8 @@ } } + sc->sc_flag |= UCOM_FLAG_READ_ON; + if (sc->sc_callback->ucom_start_read) { (sc->sc_callback->ucom_start_read)(sc); } @@ -321,6 +460,9 @@ ucom_shutdown(sc); + sc->sc_flag &= ~(UCOM_FLAG_READ_ON| + UCOM_FLAG_WRITE_ON); + if (sc->sc_callback->ucom_stop_read) { (sc->sc_callback->ucom_stop_read)(sc); } @@ -547,6 +689,8 @@ } #if 0 + sc->sc_flag &= ~UCOM_FLAG_READ_ON; + if (sc->sc_callback->ucom_stop_read) { (sc->sc_callback->ucom_stop_read)(sc); } @@ -570,6 +714,8 @@ ttyldoptim(tp); #if 0 + sc->sc_flag |= UCOM_FLAG_READ_ON; + if (sc->sc_callback->ucom_start_read) { (sc->sc_callback->ucom_start_read)(sc); } @@ -593,6 +739,8 @@ tp->t_state |= TS_BUSY; + sc->sc_flag |= UCOM_FLAG_WRITE_ON; + if (sc->sc_callback->ucom_start_write) { (sc->sc_callback->ucom_start_write)(sc); } @@ -645,6 +793,10 @@ actlen[0] = 0; + if (!(sc->sc_flag & UCOM_FLAG_WRITE_ON)) { + return 0; /* multiport device polling */ + } + if (tp->t_state & TS_TBLOCK) { if ((sc->sc_mcr & SER_RTS) && (sc->sc_flag & UCOM_FLAG_RTS_IFLOW)) { @@ -699,6 +851,10 @@ mtx_assert(&Giant, MA_OWNED); + if (!(sc->sc_flag & UCOM_FLAG_READ_ON)) { + return; /* multiport device polling */ + } + /* set a flag to prevent recursation */ if (len == 0) { ==== //depot/projects/usb/src/sys/dev/usb/ucomvar.h#7 (text+ko) ==== @@ -105,13 +105,19 @@ const struct ucom_callback *sc_callback; struct tty *sc_tty; + struct mtx *sc_parent_mtx; void *sc_parent; + uint32_t sc_unit; + u_int16_t sc_portno; u_int8_t sc_flag; #define UCOM_FLAG_RTS_IFLOW 0x01 /* use RTS input flow control */ #define UCOM_FLAG_GONE 0x02 /* the device is gone */ +#define UCOM_FLAG_ATTACHED 0x04 /* set if attached */ +#define UCOM_FLAG_READ_ON 0x08 /* set if read is enabled */ +#define UCOM_FLAG_WRITE_ON 0x10 /* set if write is enabled */ u_int8_t sc_lsr; u_int8_t sc_msr; @@ -120,13 +126,11 @@ u_int8_t sc_last_status; }; -extern devclass_t ucom_devclass; - extern int -ucom_attach(struct ucom_softc *sc, device_t dev); - +ucom_attach(struct ucom_softc *sc, uint32_t sub_units, void *parent, + const struct ucom_callback *callback, struct mtx *p_mtx); extern void -ucom_detach(struct ucom_softc *); +ucom_detach(struct ucom_softc *sc, uint32_t sub_units); extern void ucom_status_change(struct ucom_softc *); @@ -134,7 +138,6 @@ extern u_int8_t ucom_get_data(struct ucom_softc *sc, u_int8_t *buf, u_int32_t len, u_int32_t *actlen); - extern void ucom_put_data(struct ucom_softc *sc, u_int8_t *ptr, u_int16_t len); ==== //depot/projects/usb/src/sys/dev/usb/ucycom.c#8 (text+ko) ==== @@ -191,13 +191,15 @@ { 0, 0 } }; +static devclass_t ucycom_devclass; + static driver_t ucycom_driver = { - .name = "ucom", + .name = "ucycom", .methods = ucycom_methods, .size = sizeof(struct ucycom_softc), }; -DRIVER_MODULE(ucycom, uhub, ucycom_driver, ucom_devclass, usbd_driver_load, 0); +DRIVER_MODULE(ucycom, uhub, ucycom_driver, ucycom_devclass, usbd_driver_load, 0); MODULE_VERSION(ucycom, 1); MODULE_DEPEND(ucycom, usb, 1, 1, 1); @@ -339,12 +341,9 @@ goto detach; } - sc->sc_ucom.sc_parent = sc; - sc->sc_ucom.sc_portno = 0; - sc->sc_ucom.sc_callback = &ucycom_callback; + error = ucom_attach(&(sc->sc_ucom), 1, sc, + &ucycom_callback, &Giant); - error = ucom_attach(&(sc->sc_ucom), dev); - if (error) { goto detach; } @@ -368,7 +367,7 @@ { struct ucycom_softc *sc = device_get_softc(dev); - ucom_detach(&(sc->sc_ucom)); + ucom_detach(&(sc->sc_ucom), 1); usbd_transfer_unsetup(sc->sc_xfer, UCYCOM_ENDPT_MAX); ==== //depot/projects/usb/src/sys/dev/usb/ufoma.c#10 (text+ko) ==== @@ -397,13 +397,15 @@ { 0, 0 } }; +static devclass_t ufoma_devclass; + static driver_t ufoma_driver = { - .name = "ucom", + .name = "ufoma", .methods = ufoma_methods, .size = sizeof(struct ufoma_softc), }; -DRIVER_MODULE(ufoma, uhub, ufoma_driver, ucom_devclass, usbd_driver_load, 0); +DRIVER_MODULE(ufoma, uhub, ufoma_driver, ufoma_devclass, usbd_driver_load, 0); MODULE_DEPEND(ufoma, usb, 1, 1, 1); MODULE_DEPEND(ufoma, ucom, UCOM_MINVER, UCOM_PREFVER, UCOM_MAXVER); @@ -520,14 +522,8 @@ sc->sc_currentmode = UMCPC_ACM_MODE_UNLINKED; sc->sc_modetoactivate = mad->bMode[0]; - /* setup UCOM */ - - sc->sc_ucom.sc_parent = sc; - sc->sc_ucom.sc_portno = 0; - sc->sc_ucom.sc_callback = &ufoma_callback; - - error = ucom_attach(&(sc->sc_ucom), dev); - + error = ucom_attach(&(sc->sc_ucom), 1, sc, + &ufoma_callback, &Giant); if (error) { DPRINTF(0, "ucom_attach failed\n"); goto detach; @@ -562,7 +558,7 @@ mtx_unlock(&Giant); - ucom_detach(&(sc->sc_ucom)); + ucom_detach(&(sc->sc_ucom), 1); usbd_transfer_unsetup(sc->sc_ctrl_xfer, UFOMA_CTRL_ENDPT_MAX); ==== //depot/projects/usb/src/sys/dev/usb/uftdi.c#11 (text+ko) ==== @@ -278,13 +278,15 @@ { 0, 0 } }; +static devclass_t uftdi_devclass; + static driver_t uftdi_driver = { - .name = "ucom", + .name = "uftdi", .methods = uftdi_methods, .size = sizeof (struct uftdi_softc), }; -DRIVER_MODULE(uftdi, uhub, uftdi_driver, ucom_devclass, usbd_driver_load, 0); +DRIVER_MODULE(uftdi, uhub, uftdi_driver, uftdi_devclass, usbd_driver_load, 0); MODULE_DEPEND(uftdi, usb, 1, 1, 1); MODULE_DEPEND(uftdi, ucom, UCOM_MINVER, UCOM_PREFVER, UCOM_MAXVER); @@ -462,9 +464,7 @@ goto detach; } - sc->sc_ucom.sc_parent = sc; sc->sc_ucom.sc_portno = FTDI_PIT_SIOA; - sc->sc_ucom.sc_callback = &uftdi_callback; if (uaa->iface) { id = usbd_get_interface_descriptor(uaa->iface); @@ -476,7 +476,8 @@ sc->sc_ucom.sc_portno += id->bInterfaceNumber; } - error = ucom_attach(&(sc->sc_ucom), dev); + error = ucom_attach(&(sc->sc_ucom), 1, sc, + &uftdi_callback, &Giant); if (error) { goto detach; @@ -500,7 +501,7 @@ mtx_unlock(&Giant); - ucom_detach(&(sc->sc_ucom)); + ucom_detach(&(sc->sc_ucom), 1); usbd_transfer_unsetup(sc->sc_xfer, UFTDI_ENDPT_MAX); ==== //depot/projects/usb/src/sys/dev/usb/umct.c#8 (text+ko) ==== @@ -292,13 +292,15 @@ { 0, 0 } }; +static devclass_t umct_devclass; + static driver_t umct_driver = { - .name = "ucom", + .name = "umct", .methods = umct_methods, .size = sizeof(struct umct_softc), }; -DRIVER_MODULE(umct, uhub, umct_driver, ucom_devclass, usbd_driver_load, 0); +DRIVER_MODULE(umct, uhub, umct_driver, umct_devclass, usbd_driver_load, 0); MODULE_DEPEND(umct, usb, 1, 1, 1); MODULE_DEPEND(umct, ucom, UCOM_MINVER, UCOM_PREFVER, UCOM_MAXVER); MODULE_VERSION(umct, 1); @@ -408,12 +410,8 @@ goto detach; } - sc->sc_ucom.sc_parent = sc; - sc->sc_ucom.sc_portno = 0; - sc->sc_ucom.sc_callback = &umct_callback; - - error = ucom_attach(&(sc->sc_ucom), dev); - + error = ucom_attach(&(sc->sc_ucom), 1, sc, + &umct_callback, &Giant); if (error) { goto detach; } @@ -436,7 +434,7 @@ mtx_unlock(&Giant); - ucom_detach(&(sc->sc_ucom)); + ucom_detach(&(sc->sc_ucom), 1); usbd_transfer_unsetup(sc->sc_xfer, UMCT_ENDPT_MAX); ==== //depot/projects/usb/src/sys/dev/usb/umodem.c#12 (text+ko) ==== @@ -343,13 +343,15 @@ { 0, 0 } }; +static devclass_t umodem_devclass; + static driver_t umodem_driver = { - .name = "ucom", + .name = "umodem", .methods = umodem_methods, .size = sizeof(struct umodem_softc), }; -DRIVER_MODULE(umodem, uhub, umodem_driver, ucom_devclass, usbd_driver_load, 0); +DRIVER_MODULE(umodem, uhub, umodem_driver, umodem_devclass, usbd_driver_load, 0); MODULE_DEPEND(umodem, usb, 1, 1, 1); MODULE_DEPEND(umodem, ucom, UCOM_MINVER, UCOM_PREFVER, UCOM_MAXVER); MODULE_VERSION(umodem, UMODEM_MODVER); @@ -511,12 +513,8 @@ sc->sc_dtr = -1; sc->sc_break = -1; - sc->sc_ucom.sc_parent = sc; - sc->sc_ucom.sc_portno = 0; - sc->sc_ucom.sc_callback = &umodem_callback; - - error = ucom_attach(&(sc->sc_ucom), dev); - + error = ucom_attach(&(sc->sc_ucom), 1, sc, + &umodem_callback, &Giant); if (error) { goto detach; } @@ -1089,7 +1087,7 @@ DPRINTF(0, "sc=%p\n", sc); - ucom_detach(&(sc->sc_ucom)); + ucom_detach(&(sc->sc_ucom), 1); usbd_transfer_unsetup(sc->sc_xfer_intr, UMODEM_N_INTR_TRANSFER); ==== //depot/projects/usb/src/sys/dev/usb/uplcom.c#11 (text+ko) ==== @@ -402,13 +402,15 @@ { 0, 0 } }; +static devclass_t uplcom_devclass; + static driver_t uplcom_driver = { - .name = "ucom", + .name = "uplcom", .methods = uplcom_methods, .size = sizeof (struct uplcom_softc), }; -DRIVER_MODULE(uplcom, uhub, uplcom_driver, ucom_devclass, usbd_driver_load, 0); +DRIVER_MODULE(uplcom, uhub, uplcom_driver, uplcom_devclass, usbd_driver_load, 0); MODULE_DEPEND(uplcom, usb, 1, 1, 1); MODULE_DEPEND(uplcom, ucom, UCOM_MINVER, UCOM_PREFVER, UCOM_MAXVER); MODULE_VERSION(uplcom, UPLCOM_MODVER); @@ -547,10 +549,6 @@ sc->sc_rts = -1; sc->sc_break = -1; - sc->sc_ucom.sc_parent = sc; - sc->sc_ucom.sc_portno = 0; - sc->sc_ucom.sc_callback = &uplcom_callback; - error = uplcom_reset(sc, uaa->device); if (error) { @@ -559,8 +557,8 @@ goto detach; } - error = ucom_attach(&(sc->sc_ucom), dev); - + error = ucom_attach(&(sc->sc_ucom), 1, sc, + &uplcom_callback, &Giant); if (error) { goto detach; } @@ -589,7 +587,7 @@ DPRINTF(0, "sc=%p\n", sc); - ucom_detach(&(sc->sc_ucom)); + ucom_detach(&(sc->sc_ucom), 1); usbd_transfer_unsetup(sc->sc_xfer_intr, UPLCOM_N_INTR_TRANSFER); ==== //depot/projects/usb/src/sys/dev/usb/uvisor.c#10 (text+ko) ==== @@ -281,13 +281,15 @@ { 0, 0 } }; +static devclass_t uvisor_devclass; + static driver_t uvisor_driver = { - .name = "ucom", + .name = "uvisor", .methods = uvisor_methods, .size = sizeof (struct uvisor_softc), }; -DRIVER_MODULE(uvisor, uhub, uvisor_driver, ucom_devclass, usbd_driver_load, 0); +DRIVER_MODULE(uvisor, uhub, uvisor_driver, uvisor_devclass, usbd_driver_load, 0); MODULE_DEPEND(uvisor, usb, 1, 1, 1); MODULE_DEPEND(uvisor, ucom, UCOM_MINVER, UCOM_PREFVER, UCOM_MAXVER); MODULE_VERSION(uvisor, UVISOR_MODVER); @@ -407,12 +409,8 @@ goto detach; } - sc->sc_ucom.sc_parent = sc; - sc->sc_ucom.sc_portno = 0; - sc->sc_ucom.sc_callback = &uvisor_callback; - - error = ucom_attach(&(sc->sc_ucom), dev); - + error = ucom_attach(&(sc->sc_ucom), 1, sc, + &uvisor_callback, &Giant); if (error) { DPRINTF(0, "ucom_attach failed\n"); goto detach; @@ -432,7 +430,7 @@ DPRINTF(0, "sc=%p\n", sc); - ucom_detach(&(sc->sc_ucom)); + ucom_detach(&(sc->sc_ucom), 1); usbd_transfer_unsetup(sc->sc_xfer, UVISOR_N_TRANSFER); ==== //depot/projects/usb/src/sys/dev/usb/uvscom.c#13 (text+ko) ==== @@ -377,13 +377,15 @@ { 0, 0 } }; +static devclass_t uvscom_devclass; + static driver_t uvscom_driver = { - .name = "ucom", + .name = "uvscom", .methods = uvscom_methods, .size = sizeof (struct uvscom_softc), }; -DRIVER_MODULE(uvscom, uhub, uvscom_driver, ucom_devclass, usbd_driver_load, 0); +DRIVER_MODULE(uvscom, uhub, uvscom_driver, uvscom_devclass, usbd_driver_load, 0); MODULE_DEPEND(uvscom, usb, 1, 1, 1); MODULE_DEPEND(uvscom, ucom, UCOM_MINVER, UCOM_PREFVER, UCOM_MAXVER); MODULE_VERSION(uvscom, UVSCOM_MODVER); @@ -462,12 +464,8 @@ sc->sc_rts = -1; sc->sc_line_ctrl = UVSCOM_LINE_INIT; - sc->sc_ucom.sc_parent = sc; - sc->sc_ucom.sc_portno = 0; - sc->sc_ucom.sc_callback = &uvscom_callback; - - error = ucom_attach(&(sc->sc_ucom), dev); - + error = ucom_attach(&(sc->sc_ucom), 1, sc, + &uvscom_callback, &Giant); if (error) { goto detach; } @@ -504,7 +502,7 @@ usbd_transfer_stop(sc->sc_xfer[4]); } - ucom_detach(&(sc->sc_ucom)); + ucom_detach(&(sc->sc_ucom), 1); usbd_transfer_unsetup(sc->sc_xfer, UVSCOM_N_TRANSFER);