patches: refresh on kernel v4.16-rc3
[openwrt/staging/blogic.git] / patches / devcoredump.patch
1 --- a/compat/drivers-base-devcoredump.c
2 +++ b/compat/drivers-base-devcoredump.c
3 @@ -16,6 +16,7 @@
4 #include <linux/slab.h>
5 #include <linux/fs.h>
6 #include <linux/workqueue.h>
7 +#include "backports.h"
8
9 static struct class devcd_class;
10
11 @@ -25,6 +26,10 @@ static bool devcd_disabled;
12 /* if data isn't read by userspace after 5 minutes then delete it */
13 #define DEVCD_TIMEOUT (HZ * 60 * 5)
14
15 +#if LINUX_VERSION_IS_LESS(3,11,0)
16 +static struct bin_attribute devcd_attr_data;
17 +#endif
18 +
19 struct devcd_entry {
20 struct device devcd_dev;
21 void *data;
22 @@ -54,8 +59,7 @@ static void devcd_dev_release(struct dev
23 * a struct device to know when it goes away?
24 */
25 if (devcd->failing_dev->kobj.sd)
26 - sysfs_delete_link(&devcd->failing_dev->kobj, &dev->kobj,
27 - "devcoredump");
28 + sysfs_remove_link(&devcd->failing_dev->kobj, "devcoredump");
29
30 put_device(devcd->failing_dev);
31 kfree(devcd);
32 @@ -67,6 +71,9 @@ static void devcd_del(struct work_struct
33
34 devcd = container_of(wk, struct devcd_entry, del_wk.work);
35
36 +#if LINUX_VERSION_IS_LESS(3,11,0)
37 + device_remove_bin_file(&devcd->devcd_dev, &devcd_attr_data);
38 +#endif
39 device_del(&devcd->devcd_dev);
40 put_device(&devcd->devcd_dev);
41 }
42 @@ -100,6 +107,7 @@ static struct bin_attribute devcd_attr_d
43 .write = devcd_data_write,
44 };
45
46 +#if LINUX_VERSION_IS_GEQ(3,11,0)
47 static struct bin_attribute *devcd_dev_bin_attrs[] = {
48 &devcd_attr_data, NULL,
49 };
50 @@ -111,6 +119,7 @@ static const struct attribute_group devc
51 static const struct attribute_group *devcd_dev_groups[] = {
52 &devcd_dev_group, NULL,
53 };
54 +#endif /* LINUX_VERSION_IS_GEQ(3,11,0) */
55
56 static int devcd_free(struct device *dev, void *data)
57 {
58 @@ -157,7 +166,9 @@ static struct class devcd_class = {
59 .name = "devcoredump",
60 .owner = THIS_MODULE,
61 .dev_release = devcd_dev_release,
62 +#if LINUX_VERSION_IS_GEQ(3,11,0)
63 .dev_groups = devcd_dev_groups,
64 +#endif
65 .class_groups = devcd_class_groups,
66 };
67
68 @@ -301,6 +312,11 @@ void dev_coredumpm(struct device *dev, s
69 if (device_add(&devcd->devcd_dev))
70 goto put_device;
71
72 +#if LINUX_VERSION_IS_LESS(3,11,0)
73 + if (device_create_bin_file(&devcd->devcd_dev, &devcd_attr_data))
74 + goto put_device;
75 +#endif
76 +
77 if (sysfs_create_link(&devcd->devcd_dev.kobj, &dev->kobj,
78 "failing_device"))
79 /* nothing - symlink will be missing */;
80 @@ -343,15 +359,13 @@ void dev_coredumpsg(struct device *dev,
81 }
82 EXPORT_SYMBOL_GPL(dev_coredumpsg);
83
84 -static int __init devcoredump_init(void)
85 +int __init devcoredump_init(void)
86 {
87 return class_register(&devcd_class);
88 }
89 -__initcall(devcoredump_init);
90
91 -static void __exit devcoredump_exit(void)
92 +void __exit devcoredump_exit(void)
93 {
94 class_for_each_device(&devcd_class, NULL, NULL, devcd_free);
95 class_unregister(&devcd_class);
96 }
97 -__exitcall(devcoredump_exit);
98 --- a/include/linux/backport-devcoredump.h
99 +++ b/include/linux/backport-devcoredump.h
100 @@ -66,7 +66,7 @@ static inline void _devcd_free_sgtable(s
101 }
102
103
104 -#ifdef CONFIG_DEV_COREDUMP
105 +#ifdef CPTCFG_BPAUTO_WANT_DEV_COREDUMP
106 void dev_coredumpv(struct device *dev, void *data, size_t datalen,
107 gfp_t gfp);
108
109 @@ -100,6 +100,6 @@ static inline void dev_coredumpsg(struct
110 {
111 _devcd_free_sgtable(table);
112 }
113 -#endif /* CONFIG_DEV_COREDUMP */
114 +#endif /* CPTCFG_BPAUTO_WANT_DEV_COREDUMP */
115
116 #endif /* __DEVCOREDUMP_H */
117 --- a/include/linux/devcoredump.h
118 +++ b/include/linux/devcoredump.h
119 @@ -1,6 +1,7 @@
120 /* Automatically created during backport process */
121 #ifndef CPTCFG_BPAUTO_BUILD_WANT_DEV_COREDUMP
122 #include_next <linux/devcoredump.h>
123 +#include <linux/bp-devcoredump.h>
124 #else
125 #undef dev_coredumpv
126 #define dev_coredumpv LINUX_BACKPORT(dev_coredumpv)