All the "non Gobi" Qualcomm based devices handled by this
driver share a common standard Sierra Wireless specific
layout. Adding code specifically for this layout allow
us to reduce the number of match entries per device from
three to one.

This change will result in a penalty wrt stable backports,
but simplifies new Sierra device addtitions in the long
term.

Signed-off-by: Bjørn Mork <bj...@mork.no>
---
 drivers/usb/serial/qcserial.c | 77 ++++++++++++++++++++++++++-----------------
 1 file changed, 47 insertions(+), 30 deletions(-)

diff --git a/drivers/usb/serial/qcserial.c b/drivers/usb/serial/qcserial.c
index 23cc274727bc..42c246acec20 100644
--- a/drivers/usb/serial/qcserial.c
+++ b/drivers/usb/serial/qcserial.c
@@ -26,10 +26,13 @@
 enum qcserial_layouts {
        QCSERIAL_G2K = 0,       /* Gobi 2000 */
        QCSERIAL_G1K = 1,       /* Gobi 1000 */
+       QCSERIAL_SWI = 2,       /* Sierra Wireless */
 };
 
 #define DEVICE_G1K(v, p) \
        USB_DEVICE(v, p), .driver_info = QCSERIAL_G1K
+#define DEVICE_SWI(v, p) \
+       USB_DEVICE(v, p), .driver_info = QCSERIAL_SWI
 
 static const struct usb_device_id id_table[] = {
        /* Gobi 1000 devices */
@@ -132,31 +135,15 @@ static const struct usb_device_id id_table[] = {
        {USB_DEVICE(0x12D1, 0x14F1)},   /* Sony Gobi 3000 Composite */
        {USB_DEVICE(0x0AF0, 0x8120)},   /* Option GTM681W */
 
-       /* non Gobi Qualcomm serial devices */
-       {USB_DEVICE_INTERFACE_NUMBER(0x0f3d, 0x68a2, 0)},       /* Sierra 
Wireless MC7700 Device Management */
-       {USB_DEVICE_INTERFACE_NUMBER(0x0f3d, 0x68a2, 2)},       /* Sierra 
Wireless MC7700 NMEA */
-       {USB_DEVICE_INTERFACE_NUMBER(0x0f3d, 0x68a2, 3)},       /* Sierra 
Wireless MC7700 Modem */
-       {USB_DEVICE_INTERFACE_NUMBER(0x114f, 0x68a2, 0)},       /* Sierra 
Wireless MC7750 Device Management */
-       {USB_DEVICE_INTERFACE_NUMBER(0x114f, 0x68a2, 2)},       /* Sierra 
Wireless MC7750 NMEA */
-       {USB_DEVICE_INTERFACE_NUMBER(0x114f, 0x68a2, 3)},       /* Sierra 
Wireless MC7750 Modem */
-       {USB_DEVICE_INTERFACE_NUMBER(0x1199, 0x68a2, 0)},       /* Sierra 
Wireless MC7710 Device Management */
-       {USB_DEVICE_INTERFACE_NUMBER(0x1199, 0x68a2, 2)},       /* Sierra 
Wireless MC7710 NMEA */
-       {USB_DEVICE_INTERFACE_NUMBER(0x1199, 0x68a2, 3)},       /* Sierra 
Wireless MC7710 Modem */
-       {USB_DEVICE_INTERFACE_NUMBER(0x1199, 0x68c0, 0)},       /* Sierra 
Wireless MC73xx Device Management */
-       {USB_DEVICE_INTERFACE_NUMBER(0x1199, 0x68c0, 2)},       /* Sierra 
Wireless MC73xx NMEA */
-       {USB_DEVICE_INTERFACE_NUMBER(0x1199, 0x68c0, 3)},       /* Sierra 
Wireless MC73xx Modem */
-       {USB_DEVICE_INTERFACE_NUMBER(0x1199, 0x901c, 0)},       /* Sierra 
Wireless EM7700 Device Management */
-       {USB_DEVICE_INTERFACE_NUMBER(0x1199, 0x901c, 2)},       /* Sierra 
Wireless EM7700 NMEA */
-       {USB_DEVICE_INTERFACE_NUMBER(0x1199, 0x901c, 3)},       /* Sierra 
Wireless EM7700 Modem */
-       {USB_DEVICE_INTERFACE_NUMBER(0x1199, 0x901f, 0)},       /* Sierra 
Wireless EM7355 Device Management */
-       {USB_DEVICE_INTERFACE_NUMBER(0x1199, 0x901f, 2)},       /* Sierra 
Wireless EM7355 NMEA */
-       {USB_DEVICE_INTERFACE_NUMBER(0x1199, 0x901f, 3)},       /* Sierra 
Wireless EM7355 Modem */
-       {USB_DEVICE_INTERFACE_NUMBER(0x1199, 0x9041, 0)},       /* Sierra 
Wireless MC7305/MC7355 Device Management */
-       {USB_DEVICE_INTERFACE_NUMBER(0x1199, 0x9041, 2)},       /* Sierra 
Wireless MC7305/MC7355 NMEA */
-       {USB_DEVICE_INTERFACE_NUMBER(0x1199, 0x9041, 3)},       /* Sierra 
Wireless MC7305/MC7355 Modem */
-       {USB_DEVICE_INTERFACE_NUMBER(0x1199, 0x9051, 0)},       /* Netgear 
AirCard 340U Device Management */
-       {USB_DEVICE_INTERFACE_NUMBER(0x1199, 0x9051, 2)},       /* Netgear 
AirCard 340U NMEA */
-       {USB_DEVICE_INTERFACE_NUMBER(0x1199, 0x9051, 3)},       /* Netgear 
AirCard 340U Modem */
+       /* non-Gobi Sierra Wireless devices */
+       {DEVICE_SWI(0x0f3d, 0x68a2)},   /* Sierra Wireless MC7700 */
+       {DEVICE_SWI(0x114f, 0x68a2)},   /* Sierra Wireless MC7750 */
+       {DEVICE_SWI(0x1199, 0x68a2)},   /* Sierra Wireless MC7710 */
+       {DEVICE_SWI(0x1199, 0x68c0)},   /* Sierra Wireless MC73xx */
+       {DEVICE_SWI(0x1199, 0x901c)},   /* Sierra Wireless EM7700 */
+       {DEVICE_SWI(0x1199, 0x901f)},   /* Sierra Wireless EM7355 */
+       {DEVICE_SWI(0x1199, 0x9041)},   /* Sierra Wireless MC7305/MC7355 */
+       {DEVICE_SWI(0x1199, 0x9051)},   /* Netgear AirCard 340U */
 
        { }                             /* Terminating entry */
 };
@@ -205,11 +192,6 @@ static int qcprobe(struct usb_serial *serial, const struct 
usb_device_id *id)
                goto done;
        }
 
-       if (nintf < 3 || nintf > 4) {
-               dev_err(dev, "unknown number of interfaces: %d\n", nintf);
-               goto done;
-       }
-
        /* default to enabling interface */
        altsetting = 0;
 
@@ -225,6 +207,12 @@ static int qcprobe(struct usb_serial *serial, const struct 
usb_device_id *id)
                 * 2: AT-capable modem port
                 * 3: QMI/net
                 */
+               if (nintf < 3 || nintf > 4) {
+                       dev_err(dev, "unknown number of interfaces: %d\n", 
nintf);
+                       altsetting = -1;
+                       goto done;
+               }
+
                if (ifnum == 0) {
                        dev_dbg(dev, "Gobi 1K DM/DIAG interface found\n");
                        altsetting = 1;
@@ -240,6 +228,12 @@ static int qcprobe(struct usb_serial *serial, const struct 
usb_device_id *id)
                 * 2: AT-capable modem port
                 * 3: NMEA
                 */
+               if (nintf < 3 || nintf > 4) {
+                       dev_err(dev, "unknown number of interfaces: %d\n", 
nintf);
+                       altsetting = -1;
+                       goto done;
+               }
+
                switch (ifnum) {
                case 0:
                        /* Don't claim the QMI/net interface */
@@ -261,6 +255,29 @@ static int qcprobe(struct usb_serial *serial, const struct 
usb_device_id *id)
                        break;
                }
                break;
+       case QCSERIAL_SWI:
+               /* Sierra Wireless layout:
+                  0: DM/DIAG (use libqcdm from ModemManager for communication)
+                  2: NMEA
+                  3: AT-capable modem port
+                  8: QMI/net
+               */
+               switch (ifnum) {
+               case 0:
+                       dev_dbg(dev, "DM/DIAG interface found\n");
+                       break;
+               case 2:
+                       dev_dbg(dev, "NMEA GPS interface found\n");
+                       break;
+               case 3:
+                       dev_dbg(dev, "Modem port found\n");
+                       break;
+               default:
+                       /* don't claim any unsupported interface */
+                       altsetting = -1;
+                       break;
+               }
+               break;
        default:
                dev_err(dev, "unsupported device layout type: %lu\n",
                        id->driver_info);
-- 
2.0.0.rc0

--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to