From owner-p4-projects@FreeBSD.ORG Sun Sep 14 19:45:08 2008 Return-Path: Delivered-To: p4-projects@freebsd.org Received: by hub.freebsd.org (Postfix, from userid 32767) id 6C3111065676; Sun, 14 Sep 2008 19:45:08 +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 305BC1065673 for ; Sun, 14 Sep 2008 19:45:08 +0000 (UTC) (envelope-from thompsa@freebsd.org) Received: from repoman.freebsd.org (repoman.freebsd.org [IPv6:2001:4f8:fff6::29]) by mx1.freebsd.org (Postfix) with ESMTP id 1BB998FC29 for ; Sun, 14 Sep 2008 19:45:08 +0000 (UTC) (envelope-from thompsa@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 m8EJj7BY057049 for ; Sun, 14 Sep 2008 19:45:07 GMT (envelope-from thompsa@freebsd.org) Received: (from perforce@localhost) by repoman.freebsd.org (8.14.3/8.14.3/Submit) id m8EJj7BX057045 for perforce@freebsd.org; Sun, 14 Sep 2008 19:45:07 GMT (envelope-from thompsa@freebsd.org) Date: Sun, 14 Sep 2008 19:45:07 GMT Message-Id: <200809141945.m8EJj7BX057045@repoman.freebsd.org> X-Authentication-Warning: repoman.freebsd.org: perforce set sender to thompsa@freebsd.org using -f From: Andrew Thompson To: Perforce Change Reviews Cc: Subject: PERFORCE change 149771 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, 14 Sep 2008 19:45:08 -0000 http://perforce.freebsd.org/chv.cgi?CH=149771 Change 149771 by thompsa@thompsa_burger on 2008/09/14 19:44:38 Check the interface class before claiming it. Some 3G cards have a microSD reader built in which should not be attached as a serial port, also by not claiming the interface it can be attached by umass. Some code reshuffling was needed to do this. Affected files ... .. //depot/projects/usb/src/sys/dev/usb2/serial/ugensa2.c#7 edit Differences ... ==== //depot/projects/usb/src/sys/dev/usb2/serial/ugensa2.c#7 (text+ko) ==== @@ -244,41 +244,38 @@ struct usb2_attach_arg *uaa = device_get_ivars(dev); struct ugensa_softc *sc = device_get_softc(dev); struct ugensa_sub_softc *ssc; + struct usb2_interface *iface; int32_t error; - uint8_t x; uint8_t iface_index; + int x, cnt; - if (sc == NULL) { + if (sc == NULL) return (ENOMEM); - } + device_set_usb2_desc(dev); /* Figure out how many interfaces this device has got */ - for (x = 0; x < UGENSA_IFACE_MAX; x++) { - if ((usb2_get_pipe(uaa->device, x, ugensa_xfer_config + 0) == NULL) || - (usb2_get_pipe(uaa->device, x, ugensa_xfer_config + 1) == NULL)) { + for (cnt = 0; cnt < UGENSA_IFACE_MAX; cnt++) { + if ((usb2_get_pipe(uaa->device, cnt, ugensa_xfer_config + 0) == NULL) || + (usb2_get_pipe(uaa->device, cnt, ugensa_xfer_config + 1) == NULL)) { /* we have reached the end */ break; } } - if (x == 0) { + if (cnt == 0) { device_printf(dev, "No interfaces!\n"); goto detach; - } else { - device_printf(dev, "Found %d interfaces.\n", x); - sc->sc_niface = x; - for (x = 1; x != sc->sc_niface; x++) { - usb2_set_parent_iface(uaa->device, - x, uaa->info.bIfaceIndex); - } } - for (x = 0; x < sc->sc_niface; x++) { + for (x = 0; x < cnt; x++) { + iface = usb2_get_iface(uaa->device, x); + if (iface->idesc->bInterfaceClass != UICLASS_VENDOR) + /* Not a serial port, most likely a SD reader */ + continue; - ssc = sc->sc_sub + x; - - ssc->sc_usb2_com_ptr = sc->sc_ucom + x; + ssc = sc->sc_sub + sc->sc_niface; + ssc->sc_usb2_com_ptr = sc->sc_ucom + sc->sc_niface; iface_index = (UGENSA_IFACE_INDEX + x); error = usb2_transfer_setup(uaa->device, @@ -295,8 +292,13 @@ UGENSA_FLAG_BULK_READ_STALL); /* initialize port number */ - ssc->sc_usb2_com_ptr->sc_portno = x; + ssc->sc_usb2_com_ptr->sc_portno = sc->sc_niface; + sc->sc_niface++; + if (x != uaa->info.bIfaceIndex) + usb2_set_parent_iface(uaa->device, x, + uaa->info.bIfaceIndex); } + device_printf(dev, "Found %d interfaces.\n", sc->sc_niface); error = usb2_com_attach(&sc->sc_super_ucom, sc->sc_ucom, sc->sc_niface, sc, &ugensa_callback, &Giant);