summaryrefslogtreecommitdiff
path: root/patches
diff options
context:
space:
mode:
authorJohannes Berg <johannes.berg@intel.com>2017-02-06 13:04:39 +0100
committerJohannes Berg <johannes.berg@intel.com>2017-02-07 07:33:08 +0100
commit524627366f53b3a75220a13d89710a9c7feb6724 (patch)
tree8c025fd4aaed306725bca8585f8a81fd77d28a5d /patches
parent60d26f6a22d4aac8154b8fef48fbe8d6a1a1138a (diff)
backports: support class_groups
Add a new semantic patch just like for dev_groups to support class_groups. Signed-off-by: Johannes Berg <johannes.berg@intel.com>
Diffstat (limited to 'patches')
-rw-r--r--patches/collateral-evolutions/generic/0001-group-attr/0003-class_groups.cocci54
1 files changed, 54 insertions, 0 deletions
diff --git a/patches/collateral-evolutions/generic/0001-group-attr/0003-class_groups.cocci b/patches/collateral-evolutions/generic/0001-group-attr/0003-class_groups.cocci
new file mode 100644
index 00000000..a4694dd7
--- /dev/null
+++ b/patches/collateral-evolutions/generic/0001-group-attr/0003-class_groups.cocci
@@ -0,0 +1,54 @@
+/* see upstream commit ced6473e74867 */
+
+@ attribute_group @
+identifier group;
+declarer name ATTRIBUTE_GROUPS;
+@@
+
+ATTRIBUTE_GROUPS(group);
+
+@script:python attribute_groups_name@
+group << attribute_group.group;
+groups;
+@@
+coccinelle.groups = group + "_groups"
+
+@ class_group @
+identifier group_class;
+identifier attribute_groups_name.groups;
+fresh identifier group_dev_attr = attribute_group.group ## "_dev_attrs";
+@@
+
+struct class group_class = {
++#if LINUX_VERSION_CODE >= KERNEL_VERSION(4,10,0)
+ .class_groups = groups,
++#else
++ .class_attrs = group_dev_attr,
++#endif
+};
+
+@ attribute_group_mod depends on class_group @
+declarer name ATTRIBUTE_GROUPS_BACKPORT;
+identifier attribute_group.group;
+@@
+
++#if LINUX_VERSION_CODE >= KERNEL_VERSION(4,10,0)
+ATTRIBUTE_GROUPS(group);
++#else
++#define BP_ATTR_GRP_STRUCT class_attribute
++ATTRIBUTE_GROUPS_BACKPORT(group);
++#endif
+
+@ class_registering @
+identifier class_register, ret;
+identifier class_group.group_class;
+fresh identifier group_class_init = "init_" ## attribute_group.group ## "_attrs";
+@@
+
+(
++ group_class_init();
+ return class_register(&group_class);
+|
++ group_class_init();
+ ret = class_register(&group_class);
+)