Problems compiling Linux QMI drivers on new kernels

Hello, just thought I’d share that I ran into some errors compiling the linux QMI kernel modules (version S2.25N2.38 found at source.sierrawireless.com/resour … n2,-d-,38/) on Linux kernel 4.8.6 with gcc 6.2.1.

Here are the errors I get:
With GobiSerial

/usr/src/S2.26N2.38/GobiSerial/GobiSerial.c:325:14: error: initialization from incompatible pointer type [-Werror=incompatible-pointer-types]
        .resume = usb_serial_generic_resume,
                  ^~~~~~~~~~~~~~~~~~~~~~~~~
    /usr/src/S2.26N2.38/GobiSerial/GobiSerial.c:325:14: note: (near initialization for ‘GobiDriver.resume’)
    /usr/src/S2.26N2.38/GobiSerial/GobiSerial.c:326:20: error: initialization from incompatible pointer type [-Werror=incompatible-pointer-types]
        .reset_resume = usb_serial_generic_resume,
                         ^~~~~~~~~~~~~~~~~~~~~~~~~
    /usr/src/S2.26N2.38/GobiSerial/GobiSerial.c:326:20: note: (near initialization for ‘GobiDriver.reset_resume’)
    cc1: some warnings being treated as errors
    make[2]: *** [scripts/Makefile.build:296: /usr/src/S2.26N2.38/GobiSerial/GobiSerial.o] Error 1
    make[1]: *** [Makefile:1471: _module_/usr/src/S2.26N2.38/GobiSerial] Error 2
    make[1]: Leaving directory '/usr/lib/modules/4.8.6-1-ARCH/build'
    make: *** [Makefile:16: all] Error 2

With GobiNet:

/usr/src/S2.26N2.38/GobiNet/GobiUSBNet.c: In function ‘GobiUSBNetStartXmit’:
    /usr/src/S2.26N2.38/GobiNet/GobiUSBNet.c:1329:8: error: ‘struct net_device’ has no member named ‘trans_start’; did you mean  mem_start’?
        pNet->trans_start = jiffies;
            ^~
    make[2]: *** [scripts/Makefile.build:290: /usr/src/S2.26N2.38/GobiNet/GobiUSBNet.o] Error 1
    make[1]: *** [Makefile:1471: _module_/usr/src/S2.26N2.38/GobiNet] Error 2
    make[1]: Leaving directory '/usr/lib/modules/4.8.6-1-ARCH/build'
    make: *** [Makefile:37: all] Error 2

The following patch fixes these issues:

--- GobiSerial/GobiSerial.c.orig        2016-09-28 09:42:27.000000000 +0000
+++ GobiSerial/GobiSerial.c     2016-11-03 21:00:47.760637058 +0000
@@ -322,8 +322,7 @@
    .id_table   = GobiVIDPIDTable,
 #ifdef CONFIG_PM
    .suspend    = usb_serial_suspend,
-   .resume = usb_serial_generic_resume,
-   .reset_resume = usb_serial_generic_resume,
+   .resume     = usb_serial_resume,
    .supports_autosuspend = true,
 #else
    .suspend    = NULL,
--- GobiNet/GobiUSBNet.c.orig   2016-09-28 09:42:27.000000000 +0000
+++ GobiNet/GobiUSBNet.c        2016-11-03 21:05:12.407319285 +0000
@@ -1326,7 +1326,11 @@
    complete( &pAutoPM->mThreadDoWork );

    // Start transfer timer
+#if LINUX_VERSION_CODE >= KERNEL_VERSION( 4,7,0)
+   netif_trans_update(pNet);
+#else
    pNet->trans_start = jiffies;
+#endif
    // Free SKB
    if (pSKB)
       dev_kfree_skb_any ( pSKB );

In GobiSerial.c, this drivers incorrectly assign usb_serial_generic_resume to a struct usb_driver.resume when it can only be assigned to a struct usb_serial_driver (and this drive provides one for that, see GobiUSBSerialResume()). Instead, the struct usb_driver.resume should get usb_serial_resume from the generic usb-serial driver which does the delegation to the function passed into the struct usb_serial_driver.resume [1]. The struct usb_driver.reset_resume is removed as that’s added automatically by the kernel’s USB init code [2].

The problem with GobiUSBNet.c is due to an api change that went live in 4.7.0, documented here: https://groups.google.com/forum/#!topic/linux.kernel/xmWuS0ALBtM

1: https://github.com/torvalds/linux/blob/master/drivers/usb/serial/usb-serial.c#L1164-L1179
2: https://github.com/torvalds/linux/blob/master/drivers/usb/serial/usb-serial.c#L1427-L1433

Also note: the “Latest Version” of these drivers (source.sierrawireless.com/resour … n2,-d-,36/) is the previous version. The Latest version links need to be updated to S2.25N2.38