Browse Source

add compatibility for registering the nvmem config for kernels up to 4.19.x

Helmut Pozimski 5 years ago
parent
commit
4de3e6886e
1 changed files with 6 additions and 1 deletions
  1. 6 1
      rtc-ds13307.c

+ 6 - 1
rtc-ds13307.c

@@ -14,6 +14,7 @@
 #include <linux/bcd.h>
 #include <linux/slab.h>
 #include <linux/regmap.h>
+#include <linux/version.h>
 
 #define M_NAME "rtc-ds13307" /* Module name */
 
@@ -346,7 +347,11 @@ static int ds13307_probe(struct i2c_client *client,
 		ds1307_nvmem.reg_read = ds13307_nvram_read;
 		ds1307_nvmem.reg_write = ds13307_nvram_write;
 		ds1307_nvmem.priv = regmap;
-		rtc->nvmem_config = &ds1307_nvmem;
+		#if LINUX_VERSION_CODE <= KERNEL_VERSION(4,17,0)
+			rtc->nvmem_config = &ds1307_nvmem;
+		#else
+			rtc_nvmem_register(rtc, &ds1307_nvmem);
+		#endif
 	} else {
 		ds13307_rtc_ops.read_alarm = ds13307_read_alarm;
 		ds13307_rtc_ops.set_alarm = ds13307_write_alarm;