Advertisement
mad_soft

lsadrv patch to work in kernel 5.11

Oct 20th, 2021
991
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 6.31 KB | None | 0 0
  1. diff -ur lsadrv/fakemouse.c lsadrv-nuevo/fakemouse.c
  2. --- lsadrv/fakemouse.c  2015-02-23 07:42:02.000000000 +0100
  3. +++ lsadrv-nuevo/fakemouse.c    2021-10-18 13:47:19.359346693 +0200
  4. @@ -25,38 +25,24 @@
  5.  #define REPORT(FMT,VAL) printk(KERN_ALERT stringify( MODNAME ) ":" FMT "!\n", VAL);
  6.  #define WARN(X) printk(KERN_WARNING stringify( MODNAME ) ":" X "!\n");
  7.  
  8. -static int fakemouse_ioctl(struct file *filp,unsigned int command, unsigned long arg);
  9. +static long fakemouse_ioctl(struct file *filp,unsigned int command, unsigned long arg);
  10.  static int fakemouse_device_open(struct inode *inode, struct file *filp);
  11.  static int fakemouse_device_release(struct inode *inode, struct file *filp);
  12.  
  13. -#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 36)
  14. -struct file_operations fakemouse_fops =
  15. +static const struct file_operations fakemouse_fops =
  16.    {
  17.      .owner   = THIS_MODULE,
  18.      .llseek  = 0,
  19.      .read    = 0,
  20.      .write   = 0,
  21. -    .compat_ioctl   = fakemouse_ioctl,
  22. +    .compat_ioctl  = fakemouse_ioctl,
  23.      .open    = fakemouse_device_open,
  24.      .release = fakemouse_device_release,
  25.    };
  26. -#else
  27. -struct file_operations fakemouse_fops =
  28. -  {
  29. -    .owner   = THIS_MODULE,
  30. -    .llseek  = 0,
  31. -    .read    = 0,
  32. -    .write   = 0,
  33. -    .unlocked_ioctl   = fakemouse_ioctl,
  34. -    .open    = fakemouse_device_open,
  35. -    .release = fakemouse_device_release,
  36. -  };
  37. -#endif
  38. -
  39.  
  40.  int lsadrv_ioctl_mouseevent_dispatch(void *arg);
  41.  
  42. -static int fakemouse_ioctl(struct file *filp,unsigned int command, unsigned long arg)
  43. +static long fakemouse_ioctl(struct file *filp,unsigned int command, unsigned long arg)
  44.  {
  45.    struct lsadrv_mouse_input *minp = (struct lsadrv_mouse_input*)arg;
  46.  
  47. diff -ur lsadrv/lsadrv.h lsadrv-nuevo/lsadrv.h
  48. --- lsadrv/lsadrv.h 2015-02-23 07:42:02.000000000 +0100
  49. +++ lsadrv-nuevo/lsadrv.h   2021-10-18 10:53:22.414217359 +0200
  50. @@ -152,8 +152,8 @@
  51.  void lsadrv_init_waitqueue_head(wait_queue_head_t **q);
  52.  void lsadrv_free_waitqueue_head(wait_queue_head_t *q);
  53.  void lsadrv_init_waitqueue_entry(void *buf, int size);
  54. -void lsadrv_add_wait_queue(wait_queue_head_t *q, wait_queue_t *wait);
  55. -void lsadrv_remove_wait_queue(wait_queue_head_t *q, wait_queue_t *wait);
  56. +void lsadrv_add_wait_queue(wait_queue_head_t *q, wait_queue_entry_t *wait);
  57. +void lsadrv_remove_wait_queue(wait_queue_head_t *q, wait_queue_entry_t *wait);
  58.  void lsadrv_wake_up_interruptible(wait_queue_head_t *q);
  59.  void lsadrv_modlock(struct lsadrv_device *xdev);
  60.  void lsadrv_modunlock(struct lsadrv_device *xdev);
  61. diff -ur lsadrv/lsadrv-isoc.c lsadrv-nuevo/lsadrv-isoc.c
  62. --- lsadrv/lsadrv-isoc.c    2015-02-23 07:42:02.000000000 +0100
  63. +++ lsadrv-nuevo/lsadrv-isoc.c  2021-10-18 10:53:37.790458387 +0200
  64. @@ -509,7 +509,7 @@
  65.     struct lsadrv_ring_buffer *ringBuffer;
  66.     //DECLARE_WAITQUEUE(wait, current);
  67.     unsigned char waitbuf[64];  /* sufficient size */
  68. -   wait_queue_t *wait = (wait_queue_t *) waitbuf;
  69. +   wait_queue_entry_t *wait = (wait_queue_entry_t *) waitbuf;
  70.     struct lsadrv_device *xdev;
  71.     unsigned int pendingTransfers;
  72.  
  73. @@ -780,7 +780,7 @@
  74.     struct lsadrv_ring_buffer *ringBuffer;
  75.     //DECLARE_WAITQUEUE(wait, current);
  76.     unsigned char waitbuf[64];  /* sufficient size */
  77. -   wait_queue_t *wait = (wait_queue_t *) waitbuf;
  78. +   wait_queue_entry_t *wait = (wait_queue_entry_t *) waitbuf;
  79.     unsigned int recSize = PacketSize + sizeof(struct lsadrv_iso_packet_desc);
  80.     unsigned int bytesToRead = PacketCount * recSize;
  81.     unsigned int bytesRead = 0;
  82. diff -ur lsadrv/lsadrv-main.c lsadrv-nuevo/lsadrv-main.c
  83. --- lsadrv/lsadrv-main.c    2015-02-23 07:42:02.000000000 +0100
  84. +++ lsadrv-nuevo/lsadrv-main.c  2021-10-18 11:08:53.593146006 +0200
  85. @@ -18,7 +18,7 @@
  86.   *
  87.  ============================================================================*/
  88.  
  89. -#include <linux/sched.h>
  90. +#include <linux/sched/signal.h>
  91.  #ifdef MODVERSIONS
  92.  #include <linux/modversions.h>
  93.  #endif
  94. @@ -451,14 +451,14 @@
  95.  static void lsadrv_create_procfs_dir(void)
  96.  {
  97.     struct lsadrv_proc_files *files = &lsadrv_files;
  98. -   static struct file_operations proc_fops = {
  99. +   static struct proc_ops proc_fops = {
  100.  #if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 31)
  101.             .owner    = THIS_MODULE,
  102.  #endif
  103. -           .open     = lsadrv_devices_open,
  104. -           .read     = seq_read,
  105. -           .llseek   = seq_lseek,
  106. -           .release  = seq_release
  107. +           .proc_open     = lsadrv_devices_open,
  108. +           .proc_read     = seq_read,
  109. +           .proc_lseek   = seq_lseek,
  110. +           .proc_release  = seq_release
  111.     };
  112.     /* Make procfs/driver/lsadrv directory */
  113.  /* files->lsadrvDirEntry = create_proc_entry("lsadrv", S_IFDIR, proc_root_driver);*/
  114. diff -ur lsadrv/lsadrv-sub.c lsadrv-nuevo/lsadrv-sub.c
  115. --- lsadrv/lsadrv-sub.c 2015-02-23 07:42:02.000000000 +0100
  116. +++ lsadrv-nuevo/lsadrv-sub.c   2021-10-18 11:17:23.589224894 +0200
  117. @@ -25,9 +25,9 @@
  118.  #include <linux/kernel.h>  /* for linux kernel */
  119.  #include <linux/slab.h>
  120.  #include <linux/version.h>
  121. -#include <asm/uaccess.h>
  122. +#include <linux/uaccess.h>
  123.  
  124. -#include <linux/sched.h>
  125. +#include <linux/sched/signal.h>
  126.  
  127.  #if (LINUX_VERSION_CODE > KERNEL_VERSION(2, 6, 22)) & (LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 31))
  128.  #define find_task_by_pid(pid) find_task_by_pid_type_ns(PIDTYPE_PID, pid, &init_pid_ns)
  129. @@ -119,20 +119,20 @@
  130.  
  131.  void lsadrv_init_waitqueue_entry(void *buf, int size)
  132.  {
  133. -   wait_queue_t *wait = (wait_queue_t *) buf;
  134. -   if (size < sizeof(wait_queue_t)) {
  135. +   wait_queue_entry_t *wait = (wait_queue_entry_t *) buf;
  136. +   if (size < sizeof(wait_queue_entry_t)) {
  137.         BUG();
  138.     }
  139. -   memset(wait, 0, sizeof(wait_queue_t));
  140. +   memset(wait, 0, sizeof(wait_queue_entry_t));
  141.     init_waitqueue_entry(wait, current);
  142.  }
  143.  
  144. -void lsadrv_add_wait_queue(wait_queue_head_t *q, wait_queue_t *wait)
  145. +void lsadrv_add_wait_queue(wait_queue_head_t *q, wait_queue_entry_t *wait)
  146.  {
  147.     add_wait_queue(q, wait);
  148.  }
  149.  
  150. -void lsadrv_remove_wait_queue(wait_queue_head_t *q, wait_queue_t *wait)
  151. +void lsadrv_remove_wait_queue(wait_queue_head_t *q, wait_queue_entry_t *wait)
  152.  {
  153.     remove_wait_queue(q, wait);
  154.  }
  155. @@ -179,7 +179,7 @@
  156.  
  157.  int lsadrv_write_ok(void *addr, unsigned long size)
  158.  {
  159. -   return access_ok(VERIFY_WRITE, addr, size);
  160. +   return access_ok(addr, size);
  161.  }
  162.  
  163.  unsigned long lsadrv_copy_to_user(void *to, const void *from, unsigned long n)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement