Add kernel version checking; 4.20+ regmap_config; 5.0+ .compat_ioctl;
authorMiroslav Ondra <ondra@faster.cz>
Sun, 26 Jul 2020 09:04:02 +0000 (11:04 +0200)
committerMiroslav Ondra <ondra@faster.cz>
Sun, 26 Jul 2020 09:04:02 +0000 (11:04 +0200)
modules/unipi/src/unipi_spi.h
modules/unipi/src/unipi_tty.c

index 1de5252916d6aa5ac6eddca08d90ead100af12de..e855abc3ab0410a10e42e59623452154956c5861 100644 (file)
@@ -18,6 +18,7 @@
 /************
  * Includes *
  ************/
+#include <linux/version.h>
 
 #include "unipi_common.h"
 #include "unipi_platform.h"
@@ -162,7 +163,12 @@ static const struct regmap_config neuronspi_regmap_config_default =
                .val_bits                               = 16,
                .max_register                   = 65535,
                .cache_type                             = REGCACHE_RBTREE,
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(4,20,6)
+               .use_single_read                        = 0,
+               .use_single_write                       = 0,
+#else
                .use_single_rw                  = 0,
+#endif
                .can_multi_write                = 1,
 };
 
index 2611d821d955cd72ab340ee6902a382523264ecb..557197084c3d733f5f8fd124005939c21a378e2f 100644 (file)
@@ -55,6 +55,7 @@
 #include <linux/module.h>
 #include <linux/ratelimit.h>
 #include <linux/vmalloc.h>
+#include <linux/version.h>
 
 #include "unipi_tty.h"
 
@@ -945,6 +946,8 @@ static int unipi_tty_ioctl(struct tty_struct *tty, struct file *file,
 }
 
 #ifdef CONFIG_COMPAT
+#if LINUX_VERSION_CODE < KERNEL_VERSION(5,0,0)
+
 static long unipi_tty_compat_ioctl(struct tty_struct *tty, struct file *file,
                       unsigned int cmd, unsigned long arg)
 {
@@ -965,6 +968,7 @@ static long unipi_tty_compat_ioctl(struct tty_struct *tty, struct file *file,
        }
 }
 #endif
+#endif
 
 static struct tty_ldisc_ops unipi_tty_ops = {
        .magic           = TTY_LDISC_MAGIC,
@@ -977,7 +981,9 @@ static struct tty_ldisc_ops unipi_tty_ops = {
        .write           = unipi_tty_write,
        .ioctl           = unipi_tty_ioctl,
 #ifdef CONFIG_COMPAT
+#if LINUX_VERSION_CODE < KERNEL_VERSION(5,0,0)
        .compat_ioctl    = unipi_tty_compat_ioctl,
+#endif
 #endif
        .set_termios     = unipi_tty_set_termios,
        .poll            = unipi_tty_poll,