Merge pull request #2 from nfbrown/fix-linux-4.11

Fix compilation issues for Linux versions greater than 4.11
pull/4/head
jeffq-intrepid 2017-12-04 15:45:26 -05:00 committed by GitHub
commit d8ea05895e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 22 additions and 3 deletions

View File

@ -47,6 +47,7 @@
#include <linux/can/error.h> #include <linux/can/error.h>
#include <linux/wait.h> #include <linux/wait.h>
#include <linux/poll.h> #include <linux/poll.h>
#include <linux/version.h>
#define KO_DESC "Netdevice driver for Intrepid CAN/Ethernet devices" #define KO_DESC "Netdevice driver for Intrepid CAN/Ethernet devices"
#define KO_VERSION "1.0" #define KO_VERSION "1.0"
@ -301,7 +302,12 @@ static int intrepid_add_if(struct intrepid_netdevice** result)
dev->base_addr = i; dev->base_addr = i;
dev->flags |= IFF_ECHO; dev->flags |= IFF_ECHO;
dev->netdev_ops = &intrepid_netdevice_ops; dev->netdev_ops = &intrepid_netdevice_ops;
dev->destructor = intrepid_netdevice_free; #if LINUX_VERSION_CODE < KERNEL_VERSION(4,11,9)
dev->destructor = intrepid_netdevice_free;
#else
dev->needs_free_netdev = true;
dev->priv_destructor = intrepid_netdevice_free;
#endif
ics = netdev_priv(dev); ics = netdev_priv(dev);
ics->dev = dev; ics->dev = dev;
ics->is_stopped = 0; ics->is_stopped = 0;
@ -488,8 +494,15 @@ static long intrepid_dev_ioctl(struct file *fp, unsigned int cmd, unsigned long
} }
/* when the mmap()ed pages are first accesed by usermode there will be a page fault. /* when the mmap()ed pages are first accesed by usermode there will be a page fault.
* here we simply linerally map in the big vmalloc() we got */ * here we simply linerally map in the big vmalloc() we got.
static int intrepid_vm_fault(struct vm_area_struct *vma, struct vm_fault *vmf) *
* Starting in kernel version 4.11, (struct vm_operations_struct *)->fault() no
* longer takes the vma parameter (since it resides in vmf) */
static int intrepid_vm_fault(
#if LINUX_VERSION_CODE < KERNEL_VERSION(4,11,0)
struct vm_area_struct *vma,
#endif
struct vm_fault *vmf)
{ {
vmf->page = vmalloc_to_page(shared_mem + (vmf->pgoff << PAGE_SHIFT)); vmf->page = vmalloc_to_page(shared_mem + (vmf->pgoff << PAGE_SHIFT));
get_page(vmf->page); /* increment reference count, very important */ get_page(vmf->page); /* increment reference count, very important */
@ -721,7 +734,13 @@ static __exit void intrepid_exit(void)
{ {
if (net_devices[i] != NULL) if (net_devices[i] != NULL)
{ {
// Kernel version 4.11.9 changed the destructor function to
// priv_destructor
#if LINUX_VERSION_CODE < KERNEL_VERSION(4,11,9)
net_devices[i]->destructor = NULL; /* no dangling callbacks */ net_devices[i]->destructor = NULL; /* no dangling callbacks */
#else
net_devices[i]->priv_destructor = NULL;
#endif
intrepid_remove_if(i); intrepid_remove_if(i);
} }
} }