Skip to content

Instantly share code, notes, and snippets.

@mleinart
Last active March 13, 2020 21:49
  • Star 4 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save mleinart/23b2bcedace7df3c367b137b70398bc2 to your computer and use it in GitHub Desktop.
Patch to GobiNet driver to support linux kernel >= 3.19
This is a patch to the GobiNet driver provided by Netgear
(http://www.downloads.netgear.com/files/aircard/Linux-Support-S2.13N2.25.zip) to support Kernel versions 3.19 and up
which deprecated the struct file->f_dentry api (https://lwn.net/Articles/206758/) as well as to support kernel versions 4.7
and above which removed struct net_device->trans_start
You need this patch if you see either of these errors while compiling:
/usr/src/GobiNet/GobiUSBNet.c: In function ‘GobiUSBNetStartXmit’:
/usr/src/GobiNet/GobiUSBNet.c:1201: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/GobiNet.orig/GobiUSBNet.o] Error 1
make[1]: *** [Makefile:1471: _module_/usr/src/GobiNet.orig] Error 2
make[1]: Leaving directory '/usr/lib/modules/4.8.6-1-ARCH/build'
make: *** [Makefile:8: all] Error 2
/usr/src/GobiNet.orig/QMIDevice.c: In function ‘UserspaceunlockedIOCTL’:
/usr/src/GobiNet.orig/QMIDevice.c:2311:26: error: ‘struct file’ has no member named ‘f_dentry’; did you mean ‘f_owner’?
pFilp->f_op = pFilp->f_dentry->d_inode->i_fop;
^~
/usr/src/GobiNet.orig/QMIDevice.c: In function ‘UserspaceClose’:
/usr/src/GobiNet.orig/QMIDevice.c:2758:26: error: ‘struct file’ has no member named ‘f_dentry’; did you mean ‘f_owner’?
pFilp->f_op = pFilp->f_dentry->d_inode->i_fop;
^~
/usr/src/GobiNet.orig/QMIDevice.c: In function ‘UserspaceRead’:
/usr/src/GobiNet.orig/QMIDevice.c:2816:26: error: ‘struct file’ has no member named ‘f_dentry’; did you mean ‘f_owner’?
pFilp->f_op = pFilp->f_dentry->d_inode->i_fop;
^~
/usr/src/GobiNet.orig/QMIDevice.c: In function ‘UserspaceWrite’:
/usr/src/GobiNet.orig/QMIDevice.c:2899:26: error: ‘struct file’ has no member named ‘f_dentry’; did you mean ‘f_owner’?
pFilp->f_op = pFilp->f_dentry->d_inode->i_fop;
^~
/usr/src/GobiNet.orig/QMIDevice.c: In function ‘UserspacePoll’:
/usr/src/GobiNet.orig/QMIDevice.c:2977:26: error: ‘struct file’ has no member named ‘f_dentry’; did you mean ‘f_owner’?
pFilp->f_op = pFilp->f_dentry->d_inode->i_fop;
^~
/usr/src/GobiNet.orig/QMIDevice.c: In function ‘DeregisterQMIDevice’:
/usr/src/GobiNet.orig/QMIDevice.c:3364:43: error: ‘struct file’ has no member named ‘f_dentry’; did you mean ‘f_owner’?
if (pFilp != NULL && pFilp->f_dentry != NULL)
^~
/usr/src/GobiNet.orig/QMIDevice.c:3366:28: error: ‘struct file’ has no member named ‘f_dentry’; did you mean ‘f_owner’?
if (pFilp->f_dentry->d_inode == pOpenInode)
^~
make[2]: *** [scripts/Makefile.build:290: /usr/src/GobiNet.orig/QMIDevice.o] Error 1
make[1]: *** [Makefile:1471: _module_/usr/src/GobiNet.orig] Error 2
make[1]: Leaving directory '/usr/lib/modules/4.8.6-1-ARCH/build'
make: *** [Makefile:8: all] Error 2
--- GobiNet/QMIDevice.c.orig 2016-11-03 17:56:17.386652874 +0000
+++ GobiNet/QMIDevice.c 2016-10-07 20:09:33.367473457 +0000
@@ -2308,7 +2308,7 @@
if (IsDeviceValid( pFilpData->mpDev ) == false)
{
DBG( "Invalid device! Updating f_ops\n" );
- pFilp->f_op = pFilp->f_dentry->d_inode->i_fop;
+ pFilp->f_op = pFilp->f_inode->i_fop;
return -ENXIO;
}
@@ -2755,7 +2755,7 @@
if (IsDeviceValid( pFilpData->mpDev ) == false)
{
DBG( "Invalid device! Updating f_ops\n" );
- pFilp->f_op = pFilp->f_dentry->d_inode->i_fop;
+ pFilp->f_op = pFilp->f_inode->i_fop;
return -ENXIO;
}
@@ -2813,7 +2813,7 @@
if (IsDeviceValid( pFilpData->mpDev ) == false)
{
DBG( "Invalid device! Updating f_ops\n" );
- pFilp->f_op = pFilp->f_dentry->d_inode->i_fop;
+ pFilp->f_op = pFilp->f_inode->i_fop;
return -ENXIO;
}
@@ -2896,7 +2896,7 @@
if (IsDeviceValid( pFilpData->mpDev ) == false)
{
DBG( "Invalid device! Updating f_ops\n" );
- pFilp->f_op = pFilp->f_dentry->d_inode->i_fop;
+ pFilp->f_op = pFilp->f_inode->i_fop;
return -ENXIO;
}
@@ -2974,7 +2974,7 @@
if (IsDeviceValid( pFilpData->mpDev ) == false)
{
DBG( "Invalid device! Updating f_ops\n" );
- pFilp->f_op = pFilp->f_dentry->d_inode->i_fop;
+ pFilp->f_op = pFilp->f_inode->i_fop;
return POLLERR;
}
@@ -3361,9 +3361,9 @@
for (count = 0; count < pFDT->max_fds; count++)
{
pFilp = pFDT->fd[count];
- if (pFilp != NULL && pFilp->f_dentry != NULL)
+ if (pFilp != NULL && pFilp->f_inode != NULL)
{
- if (pFilp->f_dentry->d_inode == pOpenInode)
+ if (pFilp->f_inode == pOpenInode)
{
// Close this file handle
rcu_assign_pointer( pFDT->fd[count], NULL );
--- GobiNet/GobiUSBNet.c.orig 2016-11-03 18:18:00.853396174 +0000
+++ GobiNet/GobiUSBNet.c 2016-11-03 18:36:56.686796288 +0000
@@ -1198,7 +1198,11 @@
complete( &pAutoPM->mThreadDoWork );
// Start transfer timer
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 7, 0)
+ dev_trans_start(pNet);
+#else
pNet->trans_start = jiffies;
+#endif
// Free SKB
if (pSKB)
dev_kfree_skb_any ( pSKB );
@dmitvitalii
Copy link

dmitvitalii commented Dec 21, 2017

Thank you.

Helped me to install a driver for Dlink DUB E100.

Faced an error:

axusbnet.c:1082:8: error: 'struct net_device' has no member named 'trans_start'; did you mean 'mem_start'?

Fix:

--- a/axusbnet.c
+++ b/axusbnet.c
@@ -1079,7 +1079,11 @@ axusbnet_start_xmit(struct sk_buff *skb, struct net_device *net)
            devdbg(dev, "tx: submit urb err %d", retval);
        break;
    case 0:
-       net->trans_start = jiffies;
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 7, 0)
+       dev_trans_start(net);
+#else
+       net->trans_start = jiffies;
+#endif
        __skb_queue_tail(&dev->txq, skb);
        if (dev->txq.qlen >= TX_QLEN(dev))
            netif_stop_queue(net);

@valiant1x
Copy link

The original patch covered most of the changes needed to use a Sierra Wireless 340U in Ubuntu 18.04, but the following error persisted:

/usr/src/GobiNet/QMIDevice.c:3413:30: error: passing argument 1 of ‘atomic_read’ from incompatible pointer type [-Werror=incompatible-pointer-types]
int ref = atomic_read( &pDev->mQMIDev.mCdev.kobj.kref.refcount );

Fix:

--- a/QMIDevice.c
+++ b/QMIDevice.c
@@ -3410,7 +3410,7 @@ void DeregisterQMIDevice( sGobiUSBNet * pDev )
    // but exists to prevent an infinate loop just in case.
    for (tries = 0; tries < 30 * 100; tries++)
    {
-      int ref = atomic_read( &pDev->mQMIDev.mCdev.kobj.kref.refcount );
+      int ref = refcount_read( &pDev->mQMIDev.mCdev.kobj.kref.refcount );
       if (ref > 1)
       {
          DBG( "cdev in use by %d tasks\n", ref - 1 );

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment