005-revert-devcoredump.patch 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152
  1. --- a/compat/Makefile
  2. +++ b/compat/Makefile
  3. @@ -35,8 +35,6 @@ compat-$(CPTCFG_KERNEL_4_6) += backport-
  4. compat-$(CPTCFG_BPAUTO_BUILD_CRYPTO_CCM) += crypto-ccm.o
  5. compat-$(CPTCFG_BPAUTO_CRYPTO_SKCIPHER) += crypto-skcipher.o
  6. -skcipher-objs += crypto-skcipher.o
  7. -obj-$(CPTCFG_BPAUTO_CRYPTO_SKCIPHER) += skcipher.o
  8. compat-$(CPTCFG_BPAUTO_BUILD_WANT_DEV_COREDUMP) += drivers-base-devcoredump.o
  9. compat-$(CPTCFG_BPAUTO_RHASHTABLE) += lib-rhashtable.o
  10. cordic-objs += lib-cordic.o
  11. --- a/compat/drivers-base-devcoredump.c
  12. +++ b/compat/drivers-base-devcoredump.c
  13. @@ -31,6 +31,7 @@
  14. #include <linux/slab.h>
  15. #include <linux/fs.h>
  16. #include <linux/workqueue.h>
  17. +#include "backports.h"
  18. static struct class devcd_class;
  19. @@ -40,6 +41,10 @@ static bool devcd_disabled;
  20. /* if data isn't read by userspace after 5 minutes then delete it */
  21. #define DEVCD_TIMEOUT (HZ * 60 * 5)
  22. +#if LINUX_VERSION_CODE < KERNEL_VERSION(3,11,0)
  23. +static struct bin_attribute devcd_attr_data;
  24. +#endif
  25. +
  26. struct devcd_entry {
  27. struct device devcd_dev;
  28. void *data;
  29. @@ -69,8 +74,7 @@ static void devcd_dev_release(struct dev
  30. * a struct device to know when it goes away?
  31. */
  32. if (devcd->failing_dev->kobj.sd)
  33. - sysfs_delete_link(&devcd->failing_dev->kobj, &dev->kobj,
  34. - "devcoredump");
  35. + sysfs_remove_link(&devcd->failing_dev->kobj, "devcoredump");
  36. put_device(devcd->failing_dev);
  37. kfree(devcd);
  38. @@ -82,6 +86,9 @@ static void devcd_del(struct work_struct
  39. devcd = container_of(wk, struct devcd_entry, del_wk.work);
  40. +#if LINUX_VERSION_CODE < KERNEL_VERSION(3,11,0)
  41. + device_remove_bin_file(&devcd->devcd_dev, &devcd_attr_data);
  42. +#endif
  43. device_del(&devcd->devcd_dev);
  44. put_device(&devcd->devcd_dev);
  45. }
  46. @@ -115,6 +122,7 @@ static struct bin_attribute devcd_attr_d
  47. .write = devcd_data_write,
  48. };
  49. +#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,11,0)
  50. static struct bin_attribute *devcd_dev_bin_attrs[] = {
  51. &devcd_attr_data, NULL,
  52. };
  53. @@ -126,6 +134,7 @@ static const struct attribute_group devc
  54. static const struct attribute_group *devcd_dev_groups[] = {
  55. &devcd_dev_group, NULL,
  56. };
  57. +#endif /* LINUX_VERSION_CODE >= KERNEL_VERSION(3,11,0) */
  58. static int devcd_free(struct device *dev, void *data)
  59. {
  60. @@ -160,18 +169,11 @@ static ssize_t disabled_store(struct cla
  61. return count;
  62. }
  63. -static CLASS_ATTR_RW(disabled);
  64. -static struct attribute *devcd_class_attrs[] = {
  65. - &class_attr_disabled.attr,
  66. - NULL,
  67. +static struct class_attribute devcd_class_attrs[] = {
  68. + __ATTR_RW(disabled),
  69. + __ATTR_NULL
  70. };
  71. -#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,11,0)
  72. -ATTRIBUTE_GROUPS(devcd_class);
  73. -#else
  74. -#define BP_ATTR_GRP_STRUCT device_attribute
  75. -ATTRIBUTE_GROUPS_BACKPORT(devcd_class);
  76. -#endif
  77. static struct class devcd_class = {
  78. .name = "devcoredump",
  79. @@ -179,10 +181,8 @@ static struct class devcd_class = {
  80. .dev_release = devcd_dev_release,
  81. #if LINUX_VERSION_CODE >= KERNEL_VERSION(3,11,0)
  82. .dev_groups = devcd_dev_groups,
  83. -#else
  84. - .dev_attrs = devcd_class_dev_attrs,
  85. #endif
  86. - .class_groups = devcd_class_groups,
  87. + .class_attrs = devcd_class_attrs,
  88. };
  89. static ssize_t devcd_readv(char *buffer, loff_t offset, size_t count,
  90. @@ -325,6 +325,11 @@ void dev_coredumpm(struct device *dev, s
  91. if (device_add(&devcd->devcd_dev))
  92. goto put_device;
  93. +#if LINUX_VERSION_CODE < KERNEL_VERSION(3,11,0)
  94. + if (device_create_bin_file(&devcd->devcd_dev, &devcd_attr_data))
  95. + goto put_device;
  96. +#endif
  97. +
  98. if (sysfs_create_link(&devcd->devcd_dev.kobj, &dev->kobj,
  99. "failing_device"))
  100. /* nothing - symlink will be missing */;
  101. @@ -367,16 +372,13 @@ void dev_coredumpsg(struct device *dev,
  102. }
  103. EXPORT_SYMBOL_GPL(dev_coredumpsg);
  104. -static int __init devcoredump_init(void)
  105. +int __init devcoredump_init(void)
  106. {
  107. - init_devcd_class_attrs();
  108. return class_register(&devcd_class);
  109. }
  110. -__initcall(devcoredump_init);
  111. -static void __exit devcoredump_exit(void)
  112. +void __exit devcoredump_exit(void)
  113. {
  114. class_for_each_device(&devcd_class, NULL, NULL, devcd_free);
  115. class_unregister(&devcd_class);
  116. }
  117. -__exitcall(devcoredump_exit);
  118. --- a/include/linux/backport-devcoredump.h
  119. +++ b/include/linux/backport-devcoredump.h
  120. @@ -66,7 +66,7 @@ static inline void _devcd_free_sgtable(s
  121. }
  122. -#ifdef CONFIG_DEV_COREDUMP
  123. +#ifdef CPTCFG_BPAUTO_WANT_DEV_COREDUMP
  124. void dev_coredumpv(struct device *dev, void *data, size_t datalen,
  125. gfp_t gfp);
  126. @@ -100,6 +100,6 @@ static inline void dev_coredumpsg(struct
  127. {
  128. _devcd_free_sgtable(table);
  129. }
  130. -#endif /* CONFIG_DEV_COREDUMP */
  131. +#endif /* CPTCFG_BPAUTO_WANT_DEV_COREDUMP */
  132. #endif /* __DEVCOREDUMP_H */