1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
|
diff -pNaru5 dgrp-1.9.orig/driver/2.6.27/dgrp_sysfs.c dgrp-1.9/driver/2.6.27/dgrp_sysfs.c
--- dgrp-1.9.orig/driver/2.6.27/dgrp_sysfs.c 2017-07-11 13:01:13.000000000 -0400
+++ dgrp-1.9/driver/2.6.27/dgrp_sysfs.c 2018-04-13 21:02:27.542053022 -0400
@@ -57,21 +57,24 @@
static struct class *dgrp_class;
struct device *dgrp_class_nodes_dev;
struct device *dgrp_class_global_settings_dev;
-
+#if LINUX_VERSION_CODE < KERNEL_VERSION(4,13,0)
#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,35)
static ssize_t dgrp_class_version_show(struct class *class, struct class_attribute *attr, char *buf)
#else
static ssize_t dgrp_class_version_show(struct class *class, char *buf)
#endif
{
return snprintf(buf, PAGE_SIZE, "%s\n", DIGI_VERSION);
}
static CLASS_ATTR(driver_version, 0400, dgrp_class_version_show, NULL);
-
+#else
+// CLASS_ATTR_STRING first appeared in 2.6.34
+static CLASS_ATTR_STRING(driver_version, 0400, __stringify(PAGE_SIZE) DIGI_VERSION);
+#endif
static ssize_t dgrp_class_register_with_sysfs_show(struct device *c, struct device_attribute *attr, char *buf)
{
return snprintf(buf, PAGE_SIZE, "1\n");
}
@@ -186,11 +189,15 @@ void dgrp_create_class_sysfs_files(void)
{
int ret = 0;
int max_majors = 1U << (32 - MINORBITS);
dgrp_class = class_create(THIS_MODULE, "digi_realport");
+#if LINUX_VERSION_CODE < KERNEL_VERSION(4,13,0)
ret = class_create_file(dgrp_class, &class_attr_driver_version);
+#else
+ ret = class_create_file(dgrp_class, &class_attr_driver_version.attr);
+#endif
dgrp_class_global_settings_dev = device_create(dgrp_class, NULL,
MKDEV(0, max_majors + 1), NULL, "driver_settings");
ret = sysfs_create_group(&dgrp_class_global_settings_dev->kobj,
@@ -218,11 +225,15 @@ void dgrp_remove_class_sysfs_files(void)
}
sysfs_remove_group(&dgrp_class_global_settings_dev->kobj,
&dgrp_global_settings_attribute_group);
+#if LINUX_VERSION_CODE < KERNEL_VERSION(4,13,0)
class_remove_file(dgrp_class, &class_attr_driver_version);
+#else
+ class_remove_file(dgrp_class, &class_attr_driver_version.attr);
+#endif
device_destroy(dgrp_class, MKDEV(0, max_majors + 1));
device_destroy(dgrp_class, MKDEV(0, max_majors + 2));
class_destroy(dgrp_class);
}
|