Commit 0a34de6a authored by Federico Vaga's avatar Federico Vaga

Merge branch 'kernel-compatibility-update'

It makes the code compiling and running on modern kernels
parents 72e7fe42 f925faf8
...@@ -448,9 +448,8 @@ static void zbk_close(struct vm_area_struct *vma) ...@@ -448,9 +448,8 @@ static void zbk_close(struct vm_area_struct *vma)
atomic_dec(&zbki->map_count); atomic_dec(&zbki->map_count);
} }
static int zbk_fault(struct vm_area_struct *vma, struct vm_fault *vmf) static int __zbk_fault(struct vm_fault *vmf, struct file *f)
{ {
struct file *f = vma->vm_file;
struct zio_f_priv *priv = f->private_data; struct zio_f_priv *priv = f->private_data;
struct zio_bi *bi = priv->chan->bi; struct zio_bi *bi = priv->chan->bi;
struct zbk_instance *zbki = to_zbki(bi); struct zbk_instance *zbki = to_zbki(bi);
...@@ -474,6 +473,25 @@ static int zbk_fault(struct vm_area_struct *vma, struct vm_fault *vmf) ...@@ -474,6 +473,25 @@ static int zbk_fault(struct vm_area_struct *vma, struct vm_fault *vmf)
return 0; return 0;
} }
#if KERNEL_VERSION(4, 11, 0) > LINUX_VERSION_CODE
static int zbk_fault(struct vm_area_struct *vma, struct vm_fault *vmf)
{
return __zbk_fault(vmf, vma->vm_file);
}
#else
#if KERNEL_VERSION(4, 17, 0) > LINUX_VERSION_CODE
static int zbk_fault(struct vm_fault *vmf)
{
return __zbk_fault(vmf, vmf->vma->vm_file);
}
#else
static vm_fault_t zbk_fault(struct vm_fault *vmf)
{
return __zbk_fault(vmf, vmf->vma->vm_file);
}
#endif
#endif
static struct vm_operations_struct zbk_vma_ops = { static struct vm_operations_struct zbk_vma_ops = {
.open = zbk_open, .open = zbk_open,
.close = zbk_close, .close = zbk_close,
......
...@@ -13,7 +13,12 @@ ...@@ -13,7 +13,12 @@
#include <linux/mm.h> #include <linux/mm.h>
#include <linux/mutex.h> #include <linux/mutex.h>
#include <linux/poll.h> #include <linux/poll.h>
#include <linux/version.h>
#if KERNEL_VERSION(4, 11, 0) > LINUX_VERSION_CODE
#include <linux/sched.h> #include <linux/sched.h>
#else
#include <linux/sched/signal.h>
#endif
#include <linux/uaccess.h> #include <linux/uaccess.h>
#include <linux/zio.h> #include <linux/zio.h>
......
...@@ -15,12 +15,21 @@ ...@@ -15,12 +15,21 @@
#include <linux/module.h> #include <linux/module.h>
#include <linux/kernel.h> #include <linux/kernel.h>
#include <linux/init.h> #include <linux/init.h>
#include <linux/version.h>
#if KERNEL_VERSION(4, 11, 0) > LINUX_VERSION_CODE
#include <linux/sched.h> #include <linux/sched.h>
#else
#include <linux/sched/signal.h>
#endif
#include <linux/slab.h> #include <linux/slab.h>
#include <linux/fs.h> #include <linux/fs.h>
#include <linux/miscdevice.h> #include <linux/miscdevice.h>
#include <linux/stringify.h> #include <linux/stringify.h>
#if KERNEL_VERSION(4, 14, 0) > LINUX_VERSION_CODE
#include <asm/uaccess.h> #include <asm/uaccess.h>
#else
#include <linux/uaccess.h>
#endif
#include <linux/zio.h> #include <linux/zio.h>
#include <linux/zio-buffer.h> #include <linux/zio-buffer.h>
......
...@@ -10,6 +10,7 @@ ...@@ -10,6 +10,7 @@
#include <linux/usb.h> #include <linux/usb.h>
#include <linux/timer.h> #include <linux/timer.h>
#include <linux/jiffies.h> #include <linux/jiffies.h>
#include <linux/version.h>
#include <linux/zio.h> #include <linux/zio.h>
#include <linux/zio-buffer.h> #include <linux/zio-buffer.h>
...@@ -144,9 +145,8 @@ static void zvmk80xx_start_timer(struct zvmk80xx_cset *zvmk80xx_cset) ...@@ -144,9 +145,8 @@ static void zvmk80xx_start_timer(struct zvmk80xx_cset *zvmk80xx_cset)
* *
* This runs when the timer expires and on raw_io * This runs when the timer expires and on raw_io
*/ */
static void zvmk80xx_send_urb(unsigned long arg) static void __zvmk80xx_send_urb(struct zvmk80xx_cset *zvmk80xx_cset)
{ {
struct zvmk80xx_cset *zvmk80xx_cset = (void *)arg;
struct zio_channel *chan; struct zio_channel *chan;
uint8_t *data, *buf; uint8_t *data, *buf;
unsigned int sent, nsample; unsigned int sent, nsample;
...@@ -195,6 +195,22 @@ static void zvmk80xx_send_urb(unsigned long arg) ...@@ -195,6 +195,22 @@ static void zvmk80xx_send_urb(unsigned long arg)
zvmk80xx_start_timer(zvmk80xx_cset); zvmk80xx_start_timer(zvmk80xx_cset);
} }
#if KERNEL_VERSION(4, 15, 0) > LINUX_VERSION_CODE
static void zvmk80xx_send_urb(unsigned long arg)
{
struct zvmk80xx_cset *zvmk80xx_cset = (void *)arg;
__zvmk80xx_send_urb(zvmk80xx_cset);
}
#else
static void zvmk80xx_send_urb(struct timer_list *t)
{
struct zvmk80xx_cset *zvmk80xx_cset =
from_timer(zvmk80xx_cset, t, timer);
__zvmk80xx_send_urb(zvmk80xx_cset);
}
#endif
/* * * * * * * * * * * * * * * * * * * ZIO * * * * * * * * * * * * * * * * */ /* * * * * * * * * * * * * * * * * * * ZIO * * * * * * * * * * * * * * * * */
...@@ -215,7 +231,7 @@ static int zvmk80xx_generic_raw_io(struct zio_cset *cset) ...@@ -215,7 +231,7 @@ static int zvmk80xx_generic_raw_io(struct zio_cset *cset)
zvmk80xx_cset->period = zvmk80xx_cset->period =
msecs_to_jiffies(cset->zattr_set.ext_zattr[0].value); msecs_to_jiffies(cset->zattr_set.ext_zattr[0].value);
/* Program the next usb transfer */ /* Program the next usb transfer */
zvmk80xx_send_urb((unsigned long)zvmk80xx_cset); __zvmk80xx_send_urb(zvmk80xx_cset);
return -EAGAIN; return -EAGAIN;
} }
...@@ -241,8 +257,12 @@ static int zvmk80xx_init_cset(struct zio_cset *cset) ...@@ -241,8 +257,12 @@ static int zvmk80xx_init_cset(struct zio_cset *cset)
return -ENOMEM; return -ENOMEM;
} }
#if KERNEL_VERSION(4, 15, 0) > LINUX_VERSION_CODE
setup_timer(&zvmk80xx_cset->timer, zvmk80xx_send_urb, setup_timer(&zvmk80xx_cset->timer, zvmk80xx_send_urb,
(unsigned long)zvmk80xx_cset); (unsigned long)zvmk80xx_cset);
#else
timer_setup(&zvmk80xx_cset->timer, zvmk80xx_send_urb, 0);
#endif
switch (cset->index) { switch (cset->index) {
case 0: /* digital input */ case 0: /* digital input */
......
...@@ -8,7 +8,12 @@ ...@@ -8,7 +8,12 @@
#include <linux/module.h> #include <linux/module.h>
#include <linux/slab.h> #include <linux/slab.h>
#include <linux/string.h> #include <linux/string.h>
#include <linux/version.h>
#if KERNEL_VERSION(4, 11, 0) > LINUX_VERSION_CODE
#include <linux/sched.h> #include <linux/sched.h>
#else
#include <linux/sched/signal.h>
#endif
#include <linux/list.h> #include <linux/list.h>
#include <linux/fs.h> #include <linux/fs.h>
#include <linux/poll.h> #include <linux/poll.h>
......
...@@ -13,6 +13,7 @@ ...@@ -13,6 +13,7 @@
#include <linux/slab.h> #include <linux/slab.h>
#include <linux/timer.h> #include <linux/timer.h>
#include <linux/jiffies.h> #include <linux/jiffies.h>
#include <linux/version.h>
#include <linux/zio.h> #include <linux/zio.h>
#include <linux/zio-sysfs.h> #include <linux/zio-sysfs.h>
...@@ -111,9 +112,8 @@ static struct zio_sysfs_operations ztt_s_ops = { ...@@ -111,9 +112,8 @@ static struct zio_sysfs_operations ztt_s_ops = {
}; };
/* This runs when the timer expires */ /* This runs when the timer expires */
static void ztt_fn(unsigned long arg) static void __ztt_fn(struct zio_ti *ti)
{ {
struct zio_ti *ti = (void *)arg;
struct ztt_instance *ztt; struct ztt_instance *ztt;
zio_arm_trigger(ti); zio_arm_trigger(ti);
...@@ -126,6 +126,20 @@ static void ztt_fn(unsigned long arg) ...@@ -126,6 +126,20 @@ static void ztt_fn(unsigned long arg)
mod_timer(&ztt->timer, ztt->next_run); mod_timer(&ztt->timer, ztt->next_run);
} }
#if KERNEL_VERSION(4, 15, 0) > LINUX_VERSION_CODE
static void ztt_fn(unsigned long arg)
{
struct zio_ti *ti = (void *)arg;
__ztt_fn(ti);
}
#else
static void ztt_fn(struct timer_list *t)
{
struct ztt_instance *ztt = from_timer(ztt, t, timer);
__ztt_fn(&ztt->ti);
}
#endif
/* /*
* The trigger operations are the core of a trigger type * The trigger operations are the core of a trigger type
*/ */
...@@ -159,8 +173,12 @@ static struct zio_ti *ztt_create(struct zio_trigger_type *trig, ...@@ -159,8 +173,12 @@ static struct zio_ti *ztt_create(struct zio_trigger_type *trig,
ti->cset = cset; ti->cset = cset;
/* Fill own fields */ /* Fill own fields */
#if KERNEL_VERSION(4, 15, 0) > LINUX_VERSION_CODE
setup_timer(&ztt->timer, ztt_fn, setup_timer(&ztt->timer, ztt_fn,
(unsigned long)(&ztt->ti)); (unsigned long)(&ztt->ti));
#else
timer_setup(&ztt->timer, ztt_fn, 0);
#endif
ztt->period = msecs_to_jiffies(ztt_ext_attr[0].value); ztt->period = msecs_to_jiffies(ztt_ext_attr[0].value);
ztt->phase = msecs_to_jiffies(ztt_ext_attr[1].value); ztt->phase = msecs_to_jiffies(ztt_ext_attr[1].value);
ztt_start_timer(ztt); ztt_start_timer(ztt);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment