diff --git a/drv/gim_drv.c b/drv/gim_drv.c index 1b5035f..2178f1e 100644 --- a/drv/gim_drv.c +++ b/drv/gim_drv.c @@ -24,6 +24,7 @@ #include #include #include +#include #include "gim_adapter.h" #include "gim_unwrapper.h" #include "gim_pci.h" @@ -63,21 +64,23 @@ static const struct pci_device_id gim_pci_tbl[] = { struct aer_item device_list[MAX_BRIDGES]; -static ssize_t gim_sriov(struct device_driver *drv, const char *buf, +static ssize_t sriov_store(struct device_driver *drv, const char *buf, size_t count) { call_interface_functions(buf, count); return count; } -static ssize_t gim_sriov_show(struct device_driver *drv, char *buf) +static ssize_t sriov_show(struct device_driver *drv, char *buf) { return respond_interface_functions(buf); } - -static DRIVER_ATTR(sriov, (S_IWUSR|S_IRUSR), gim_sriov_show, gim_sriov); - +#if LINUX_VERSION_CODE < KERNEL_VERSION(4, 14, 0) +static DRIVER_ATTR(sriov, (S_IWUSR | S_IRUSR), sriov_show, sriov_store); +#else +static DRIVER_ATTR_RW(sriov); +#endif static int gim_probe(struct pci_dev *pdev, const struct pci_device_id *ent) diff --git a/drv/gim_file.c b/drv/gim_file.c index 95c8bb2..4507c67 100644 --- a/drv/gim_file.c +++ b/drv/gim_file.c @@ -22,7 +22,6 @@ #include #include -#include #include #include @@ -60,9 +59,13 @@ unsigned long long file_size(struct file *file) #if !defined(XEN_DUNDEE) && (KERNEL_VERSION(3, 9, 0) > LINUX_VERSION_CODE) /* 3.4.9 */ vfs_getattr(file->f_vfsmnt, file->f_dentry, &ks); -#else +#elif LINUX_VERSION_CODE < KERNEL_VERSION(4, 11, 0) /* 3.14.0 + */ vfs_getattr(&file->f_path, &ks); +#else + /* 4.11.0 + */ + vfs_getattr(&file->f_path, &ks, STATX_TYPE | STATX_MODE, + AT_STATX_SYNC_AS_STAT); #endif set_fs(oldfs); @@ -97,8 +100,9 @@ int file_truncate(struct file *file, unsigned long long size) } int file_read(struct file *file, unsigned long long offset, unsigned char *data, - unsigned int size) + unsigned int size) { +#if LINUX_VERSION_CODE < KERNEL_VERSION(4, 14, 0) mm_segment_t oldfs; int ret; @@ -110,11 +114,15 @@ int file_read(struct file *file, unsigned long long offset, unsigned char *data, set_fs(oldfs); return ret; +#else + return kernel_read(file, data, size, &offset); +#endif } int file_write(struct file *file, unsigned long long offset, - unsigned char *data, unsigned int size) + unsigned char *data, unsigned int size) { +#if LINUX_VERSION_CODE < KERNEL_VERSION(4, 14, 0) mm_segment_t oldfs; int ret; @@ -126,6 +134,9 @@ int file_write(struct file *file, unsigned long long offset, set_fs(oldfs); return ret; +#else + return kernel_write(file, data, size, &offset); +#endif } int file_sync(struct file *file)