From owner-svn-src-stable@FreeBSD.ORG Tue Apr 13 19:43:17 2010 Return-Path: Delivered-To: svn-src-stable@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 5663A106566C; Tue, 13 Apr 2010 19:43:17 +0000 (UTC) (envelope-from n_hibma@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 44A3A8FC18; Tue, 13 Apr 2010 19:43:17 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id o3DJhHGO046060; Tue, 13 Apr 2010 19:43:17 GMT (envelope-from n_hibma@svn.freebsd.org) Received: (from n_hibma@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id o3DJhHJm046058; Tue, 13 Apr 2010 19:43:17 GMT (envelope-from n_hibma@svn.freebsd.org) Message-Id: <201004131943.o3DJhHJm046058@svn.freebsd.org> From: Nick Hibma Date: Tue, 13 Apr 2010 19:43:17 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-7@freebsd.org X-SVN-Group: stable-7 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r206561 - stable/7/sys/dev/usb X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 13 Apr 2010 19:43:17 -0000 Author: n_hibma Date: Tue Apr 13 19:43:16 2010 New Revision: 206561 URL: http://svn.freebsd.org/changeset/base/206561 Log: Make the list of allocated ports dynamic. The Option GTM382 has 10 serial ports (yes, 10, it has a built in GPS and other stuff) and we need to access the last one for PPP access to the card. Other ports are HSO (Option specific protocol; see Linux driver). Reviewed by: thompsa Modified: stable/7/sys/dev/usb/u3g.c Modified: stable/7/sys/dev/usb/u3g.c ============================================================================== --- stable/7/sys/dev/usb/u3g.c Tue Apr 13 18:53:39 2010 (r206560) +++ stable/7/sys/dev/usb/u3g.c Tue Apr 13 19:43:16 2010 (r206561) @@ -58,10 +58,8 @@ SYSCTL_INT(_hw_usb_u3g, OID_AUTO, debug, &u3gdebug, 0, "u3g debug level"); #define DPRINTF(x...) if (u3gdebug) device_printf(sc->sc_dev, ##x) -#define U3G_MAXPORTS 6 - struct u3g_softc { - struct ucom_softc sc_ucom[U3G_MAXPORTS]; + struct ucom_softc *sc_ucom; device_t sc_dev; usbd_device_handle sc_udev; u_int8_t sc_speed; @@ -254,9 +252,8 @@ u3g_attach(device_t self) sc->sc_init = u3g_dev_type->init; sc->sc_speed = u3g_dev_type->speed; - sprintf(devnamefmt,"U%d.%%d", device_get_unit(self)); int portno = 0; - for (i = 0; i < uaa->nifaces && portno < U3G_MAXPORTS; i++) { + for (i = 0; i < uaa->nifaces; i++) { DPRINTF("Interface %d of %d, %sin use\n", i, uaa->nifaces, (uaa->ifaces[i]? "not ":"")); @@ -279,7 +276,7 @@ u3g_attach(device_t self) int bulkin_no = -1, bulkout_no = -1; int claim_iface = 0; - for (n = 0; n < id->bNumEndpoints && portno < U3G_MAXPORTS; n++) { + for (n = 0; n < id->bNumEndpoints; n++) { ed = usbd_interface2endpoint_descriptor(uaa->ifaces[i], n); DPRINTF(" Endpoint %d of %d%s\n", n, id->bNumEndpoints, @@ -298,6 +295,7 @@ u3g_attach(device_t self) * the bulk-in and bulk-out endpoints appear in pairs. */ if (bulkin_no != -1 && bulkout_no != -1) { + sc->sc_ucom = realloc(sc->sc_ucom, (portno+1)*sizeof(struct ucom_softc), M_USBDEV, M_WAITOK); struct ucom_softc *ucom = &sc->sc_ucom[portno]; ucom->sc_dev = self; @@ -318,13 +316,6 @@ u3g_attach(device_t self) portno, i, ucom->sc_bulkin_no, ucom->sc_bulkout_no); -#if __FreeBSD_version < 700000 - ucom_attach_tty(ucom, MINOR_CALLOUT, devnamefmt, portno); -#elif __FreeBSD_version < 800000 - ucom_attach_tty(ucom, TS_CALLOUT, devnamefmt, portno); -#else - ucom_attach_tty(ucom, devnamefmt, portno); -#endif claim_iface = 1; portno++; @@ -336,6 +327,19 @@ u3g_attach(device_t self) } sc->sc_numports = portno; + sprintf(devnamefmt,"U%d.%%d", device_get_unit(self)); + for (portno = 0; portno < sc->sc_numports; portno++) { + struct ucom_softc *ucom = &sc->sc_ucom[portno]; + +#if __FreeBSD_version < 700000 + ucom_attach_tty(ucom, MINOR_CALLOUT, devnamefmt, portno); +#elif __FreeBSD_version < 800000 + ucom_attach_tty(ucom, TS_CALLOUT, devnamefmt, portno); +#else + ucom_attach_tty(ucom, devnamefmt, portno); +#endif + } + device_printf(self, "configured %d serial ports (%s)\n", sc->sc_numports, devnamefmt); return 0; @@ -357,6 +361,9 @@ u3g_detach(device_t self) } } + if (sc->sc_ucom) + free(sc->sc_ucom, M_USBDEV); + return 0; }