From owner-p4-projects@FreeBSD.ORG Wed Feb 4 17:29:36 2009 Return-Path: Delivered-To: p4-projects@freebsd.org Received: by hub.freebsd.org (Postfix, from userid 32767) id 8A51C10656FD; Wed, 4 Feb 2009 17:29:35 +0000 (UTC) Delivered-To: perforce@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id E9D8710656F9 for ; Wed, 4 Feb 2009 17:29:34 +0000 (UTC) (envelope-from hselasky@FreeBSD.org) Received: from repoman.freebsd.org (repoman.freebsd.org [IPv6:2001:4f8:fff6::29]) by mx1.freebsd.org (Postfix) with ESMTP id D3A978FC36 for ; Wed, 4 Feb 2009 17:29:34 +0000 (UTC) (envelope-from hselasky@FreeBSD.org) Received: from repoman.freebsd.org (localhost [127.0.0.1]) by repoman.freebsd.org (8.14.3/8.14.3) with ESMTP id n14HTYw2070747 for ; Wed, 4 Feb 2009 17:29:34 GMT (envelope-from hselasky@FreeBSD.org) Received: (from perforce@localhost) by repoman.freebsd.org (8.14.3/8.14.3/Submit) id n14HTYSE070745 for perforce@freebsd.org; Wed, 4 Feb 2009 17:29:34 GMT (envelope-from hselasky@FreeBSD.org) Date: Wed, 4 Feb 2009 17:29:34 GMT Message-Id: <200902041729.n14HTYSE070745@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 157145 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: Wed, 04 Feb 2009 17:29:40 -0000 http://perforce.freebsd.org/chv.cgi?CH=157145 Change 157145 by hselasky@hselasky_laptop001 on 2009/02/04 17:28:49 USB serial patches. Fix multiport modem naming scheme, so that modems are named /dev/cuaU%u.%u when there is more than one port. Update U3G driver to put all modems into the same interface, and make the other interfaces slave interfaces. This affects the naming scheme. Affected files ... .. //depot/projects/usb/src/sys/dev/usb2/serial/u3g2.c#11 edit .. //depot/projects/usb/src/sys/dev/usb2/serial/usb2_serial.c#26 edit Differences ... ==== //depot/projects/usb/src/sys/dev/usb2/serial/u3g2.c#11 (text+ko) ==== @@ -98,11 +98,8 @@ struct usb2_xfer *sc_xfer[U3G_MAXPORTS][U3G_N_TRANSFER]; struct usb2_device *sc_udev; - uint8_t sc_iface_no; /* interface number */ - uint8_t sc_iface_index; /* interface index */ uint8_t sc_lsr; /* local status register */ uint8_t sc_msr; /* U3G status register */ - struct u3g_speeds_s sc_speed; uint8_t sc_numports; }; @@ -148,6 +145,7 @@ .usb2_com_stop_write = &u3g_stop_write, }; +#if 0 static const struct u3g_speeds_s u3g_speeds[U3GSP_MAX] = { [U3GSP_GPRS] = {64000, 64000}, [U3GSP_EDGE] = {384000, 64000}, @@ -157,6 +155,7 @@ [U3GSP_HSUPA] = {1200000, 384000}, [U3GSP_HSPA] = {7200000, 384000}, }; +#endif static device_method_t u3g_methods[] = { DEVMETHOD(device_probe, u3g_probe), @@ -385,8 +384,12 @@ struct usb2_config u3g_config_tmp[U3G_N_TRANSFER]; struct usb2_attach_arg *uaa = device_get_ivars(dev); struct u3g_softc *sc = device_get_softc(dev); + struct usb2_interface *iface; + struct usb2_interface_descriptor *id; + uint8_t m; uint8_t n; - uint8_t m; + uint8_t i; + uint8_t x; int error; DPRINTF("sc=%p\n", sc); @@ -398,30 +401,56 @@ device_set_usb2_desc(dev); sc->sc_udev = uaa->device; - sc->sc_iface_no = uaa->info.bIfaceNum; - sc->sc_iface_index = uaa->info.bIfaceIndex; - sc->sc_speed = u3g_speeds[U3G_GET_SPEED(uaa)]; + + x = 0; /* interface index */ + i = 0; /* endpoint index */ + m = 0; /* number of ports */ - for (m = 0; m != U3G_MAXPORTS; m++) { + while (m != U3G_MAXPORTS) { /* update BULK endpoint index */ for (n = 0; n != U3G_N_TRANSFER; n++) - u3g_config_tmp[n].ep_index = m; + u3g_config_tmp[n].ep_index = i; + + iface = usb2_get_iface(uaa->device, x); + if (iface == NULL) { + if (m != 0) + break; /* end of interfaces */ + DPRINTF("did not find any modem endpoints\n"); + goto detach; + } + + id = usb2_get_interface_descriptor(iface); + if ((id == NULL) || + (id->bInterfaceClass != UICLASS_VENDOR)) { + /* next interface */ + x++; + i = 0; + continue; + } /* try to allocate a set of BULK endpoints */ - error = usb2_transfer_setup(uaa->device, &sc->sc_iface_index, + error = usb2_transfer_setup(uaa->device, &x, sc->sc_xfer[m], u3g_config_tmp, U3G_N_TRANSFER, &sc->sc_ucom[m], &Giant); - if (error) { - if (m != 0) - break; /* end of endpoints */ - DPRINTF("could not allocate all pipes\n"); - goto detach; + /* next interface */ + x++; + i = 0; + continue; } + + /* grab other interface, if any */ + if (x != uaa->info.bIfaceIndex) + usb2_set_parent_iface(uaa->device, x, + uaa->info.bIfaceIndex); + /* set stall by default */ usb2_transfer_set_stall(sc->sc_xfer[m][U3G_BULK_WR]); usb2_transfer_set_stall(sc->sc_xfer[m][U3G_BULK_RD]); + + m++; /* found one port */ + i++; /* next endpoint index */ } sc->sc_numports = m; ==== //depot/projects/usb/src/sys/dev/usb2/serial/usb2_serial.c#26 (text+ko) ==== @@ -101,7 +101,7 @@ static uint8_t usb2_com_units_alloc(uint32_t, uint32_t *); static void usb2_com_units_free(uint32_t, uint32_t); -static int usb2_com_attach_tty(struct usb2_com_softc *); +static int usb2_com_attach_tty(struct usb2_com_softc *, uint32_t); static void usb2_com_detach_tty(struct usb2_com_softc *); static void usb2_com_queue_command(struct usb2_com_softc *, usb2_proc_callback_t *, struct termios *pt, @@ -249,7 +249,7 @@ sc->sc_parent = parent; sc->sc_callback = callback; - error = usb2_com_attach_tty(sc); + error = usb2_com_attach_tty(sc, sub_units); if (error) { usb2_com_detach(ssc, sc - n, n); usb2_com_units_free(root_unit + n, sub_units - n); @@ -287,7 +287,7 @@ } static int -usb2_com_attach_tty(struct usb2_com_softc *sc) +usb2_com_attach_tty(struct usb2_com_softc *sc, uint32_t sub_units) { struct tty *tp; int error = 0; @@ -309,8 +309,18 @@ } if (buf[0] == 0) { /* Use default TTY name */ - if (snprintf(buf, sizeof(buf), "U%u", sc->sc_unit)) { - /* ignore */ + if (sub_units > 1) { + /* multiple modems in one */ + if (snprintf(buf, sizeof(buf), "U%u.%u", + sc->sc_unit - sc->sc_local_unit, + sc->sc_local_unit)) { + /* ignore */ + } + } else { + /* single modem */ + if (snprintf(buf, sizeof(buf), "U%u", sc->sc_unit)) { + /* ignore */ + } } } tty_makedev(tp, NULL, "%s", buf);