Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/netbsd-9]: src/sys/dev/usb Pull up following revision(s) (requested by s...



details:   https://anonhg.NetBSD.org/src/rev/6e4b15681240
branches:  netbsd-9
changeset: 934223:6e4b15681240
user:      martin <martin%NetBSD.org@localhost>
date:      Sun Jun 07 17:03:11 2020 +0000

description:
Pull up following revision(s) (requested by skrll in ticket #948):

        sys/dev/usb/ugensa.c: revision 1.42
        sys/dev/usb/u3g.c: revision 1.41

Remove duplicated USB_VENDOR_SIERRA USB_PRODUCT_SIERRA_USB305 entry
PR kern/55329

Replace calls to usbd_device2interface_handle in u3g_match() and
u3g_attach() with the interface already passed in uiaa->uiaa_iface and
store the interface in sc->sc_iface for later use by u3g_open()/

Also skip Direct IP interfaces in u3g_match() to avoid potential side
effects.

PR kern/55330

diffstat:

 sys/dev/usb/u3g.c    |  45 ++++++++++++++++++---------------------------
 sys/dev/usb/ugensa.c |   5 ++---
 2 files changed, 20 insertions(+), 30 deletions(-)

diffs (148 lines):

diff -r d7975d13a469 -r 6e4b15681240 sys/dev/usb/u3g.c
--- a/sys/dev/usb/u3g.c Sun Jun 07 16:59:04 2020 +0000
+++ b/sys/dev/usb/u3g.c Sun Jun 07 17:03:11 2020 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: u3g.c,v 1.37.2.1 2020/02/27 17:22:56 martin Exp $      */
+/*     $NetBSD: u3g.c,v 1.37.2.2 2020/06/07 17:03:11 martin Exp $      */
 
 /*-
  * Copyright (c) 2009 The NetBSD Foundation, Inc.
@@ -50,7 +50,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: u3g.c,v 1.37.2.1 2020/02/27 17:22:56 martin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: u3g.c,v 1.37.2.2 2020/06/07 17:03:11 martin Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -114,6 +114,7 @@
        struct usbd_device *    sc_udev;
        bool                    sc_dying;       /* We're going away */
        int                     sc_ifaceno;     /* Device interface number */
+       struct usbd_interface   *sc_iface;      /* Device interface */
 
        struct u3g_com {
                device_t        c_dev;          /* Child ucom(4) handle */
@@ -271,21 +272,12 @@
 u3g_match(device_t parent, cfdata_t match, void *aux)
 {
        struct usbif_attach_arg *uiaa = aux;
-       struct usbd_interface *iface;
+       struct usbd_interface *iface = uiaa->uiaa_iface;
        usb_interface_descriptor_t *id;
-       usbd_status error;
 
        if (!usb_lookup(u3g_devs, uiaa->uiaa_vendor, uiaa->uiaa_product))
                return UMATCH_NONE;
 
-       error = usbd_device2interface_handle(uiaa->uiaa_device,
-           uiaa->uiaa_ifaceno, &iface);
-       if (error) {
-               printf("u3g_match: failed to get interface, err=%s\n",
-                   usbd_errstr(error));
-               return UMATCH_NONE;
-       }
-
        id = usbd_get_interface_descriptor(iface);
        if (id == NULL) {
                printf("u3g_match: failed to get interface descriptor\n");
@@ -302,6 +294,16 @@
                return UMATCH_NONE;
 
        /*
+        * Sierra Wireless modems use the vendor-specific class also for
+        * Direct IP or QMI interfaces, which we should avoid attaching to.
+        */
+       if (uiaa->uiaa_vendor == USB_VENDOR_SIERRA &&
+           id->bInterfaceClass == UICLASS_VENDOR &&
+           uiaa->uiaa_product == USB_PRODUCT_SIERRA_USB305 &&
+            uiaa->uiaa_ifaceno >= 7)
+               return UMATCH_NONE;
+
+       /*
         * 3G modems generally report vendor-specific class
         *
         * XXX: this may be too generalised.
@@ -316,7 +318,7 @@
        struct u3g_softc *sc = device_private(self);
        struct usbif_attach_arg *uiaa = aux;
        struct usbd_device *dev = uiaa->uiaa_device;
-       struct usbd_interface *iface;
+       struct usbd_interface *iface = uiaa->uiaa_iface;
        usb_interface_descriptor_t *id;
        usb_endpoint_descriptor_t *ed;
        struct ucom_attach_args ucaa;
@@ -330,13 +332,6 @@
        sc->sc_dying = false;
        sc->sc_udev = dev;
 
-       error = usbd_device2interface_handle(dev, uiaa->uiaa_ifaceno, &iface);
-       if (error) {
-               aprint_error_dev(self, "failed to get interface, err=%s\n",
-                   usbd_errstr(error));
-               return;
-       }
-
        id = usbd_get_interface_descriptor(iface);
 
        ucaa.ucaa_info = "3G Modem";
@@ -352,6 +347,7 @@
        ucaa.ucaa_bulkin = ucaa.ucaa_bulkout = -1;
 
        sc->sc_ifaceno = uiaa->uiaa_ifaceno;
+       sc->sc_iface = uiaa->uiaa_iface;
        intr_address = -1;
        intr_size = 0;
 
@@ -578,7 +574,6 @@
        usb_device_request_t req;
        usb_endpoint_descriptor_t *ed;
        usb_interface_descriptor_t *id;
-       struct usbd_interface *ih;
        usbd_status err;
        struct u3g_com *com = &sc->sc_com[portno];
        int i, nin;
@@ -586,14 +581,10 @@
        if (sc->sc_dying)
                return EIO;
 
-       err = usbd_device2interface_handle(sc->sc_udev, sc->sc_ifaceno, &ih);
-       if (err)
-               return EIO;
-
-       id = usbd_get_interface_descriptor(ih);
+       id = usbd_get_interface_descriptor(sc->sc_iface);
 
        for (nin = i = 0; i < id->bNumEndpoints; i++) {
-               ed = usbd_interface2endpoint_descriptor(ih, i);
+               ed = usbd_interface2endpoint_descriptor(sc->sc_iface, i);
                if (ed == NULL)
                        return EIO;
 
diff -r d7975d13a469 -r 6e4b15681240 sys/dev/usb/ugensa.c
--- a/sys/dev/usb/ugensa.c      Sun Jun 07 16:59:04 2020 +0000
+++ b/sys/dev/usb/ugensa.c      Sun Jun 07 17:03:11 2020 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: ugensa.c,v 1.39 2019/05/09 02:43:35 mrg Exp $  */
+/*     $NetBSD: ugensa.c,v 1.39.2.1 2020/06/07 17:03:11 martin Exp $   */
 
 /*
  * Copyright (c) 2004, 2005 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: ugensa.c,v 1.39 2019/05/09 02:43:35 mrg Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ugensa.c,v 1.39.2.1 2020/06/07 17:03:11 martin Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_usb.h"
@@ -88,7 +88,6 @@
        {{ USB_VENDOR_DELL, USB_PRODUCT_DELL_HSDPA }, 0 },
        {{ USB_VENDOR_NOVATEL, USB_PRODUCT_NOVATEL_FLEXPACKGPS }, 0 },
        {{ USB_VENDOR_QUALCOMM_K, USB_PRODUCT_QUALCOMM_K_CDMA_MSM_K }, 0 },
-       {{ USB_VENDOR_SIERRA, USB_PRODUCT_SIERRA_USB305 }, 0 },
        {{ USB_VENDOR_ZTE, USB_PRODUCT_ZTE_AC8700 }, 0 },
 
        /*



Home | Main Index | Thread Index | Old Index