Browse Source

Update Driver to compatible with ubuntu 24.04

- Add kenel version check in setting vma flags
master
mmtalaie 3 months ago
parent
commit
5712305985
  1. 9
      sonoPciDrv.c

9
sonoPciDrv.c

@ -1,4 +1,5 @@
#include <linux/module.h> #include <linux/module.h>
#include <linux/version.h>
#include <linux/proc_fs.h> #include <linux/proc_fs.h>
#include <linux/cdev.h> #include <linux/cdev.h>
#include <linux/pci.h> #include <linux/pci.h>
@ -179,7 +180,13 @@ static int sono_bar_mmap(struct file *filp, struct vm_area_struct *vma)
if(vsize > bar_size) if(vsize > bar_size)
return -EINVAL; return -EINVAL;
vma->vm_flags |= VM_IO;
#if LINUX_VERSION_CODE <= KERNEL_VERSION(5,4,0)
vma->vm_flags |= VM_IO;// ubuntu 14
#elif LINUX_VERSION_CODE <= KERNEL_VERSION(6,8,0)
vm_flags_set(vma, VM_IO);
#endif
vma->vm_page_prot = pgprot_noncached(vma->vm_page_prot); vma->vm_page_prot = pgprot_noncached(vma->vm_page_prot);
int res = remap_pfn_range(vma, vma->vm_start, physical >> PAGE_SHIFT, vsize, vma->vm_page_prot); int res = remap_pfn_range(vma, vma->vm_start, physical >> PAGE_SHIFT, vsize, vma->vm_page_prot);
if(res) if(res)

Loading…
Cancel
Save