diff mbox

[3/3] backports: support class_groups

Message ID 20170206123956.20082-3-johannes@sipsolutions.net (mailing list archive)
State Accepted
Headers show

Commit Message

Johannes Berg Feb. 6, 2017, 12:39 p.m. UTC
From: Johannes Berg <johannes.berg@intel.com>

Add a new semantic patch just like for dev_groups to
support class_groups.

Change-Id: I114e1a6ed8db901b3aa738a5052721d1da45cae4
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
---
 .../0001-group-attr/0003-class_groups.cocci        | 54 ++++++++++++++++++++++
 1 file changed, 54 insertions(+)
 create mode 100644 patches/collateral-evolutions/generic/0001-group-attr/0003-class_groups.cocci

Comments

Arend van Spriel Feb. 6, 2017, 10:36 p.m. UTC | #1
On 6-2-2017 13:39, Johannes Berg wrote:
> From: Johannes Berg <johannes.berg@intel.com>
> 
> Add a new semantic patch just like for dev_groups to
> support class_groups.
> 
> Change-Id: I114e1a6ed8db901b3aa738a5052721d1da45cae4

Does it make sense to keep the Change-Id: things here?

> Signed-off-by: Johannes Berg <johannes.berg@intel.com>
> ---
>  .../0001-group-attr/0003-class_groups.cocci        | 54 ++++++++++++++++++++++
>  1 file changed, 54 insertions(+)
>  create mode 100644 patches/collateral-evolutions/generic/0001-group-attr/0003-class_groups.cocci
> 
> 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 000000000000..a4694dd75763
> --- /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";

So how will this work wrt naming scheme. Can we be sure all class_attrs
occurrences in the files we copy are named as such, ie. with _dev_attrs
post-fix?

Regards,
Arend
--
To unsubscribe from this list: send the line "unsubscribe backports" in
Johannes Berg Feb. 7, 2017, 6:29 a.m. UTC | #2
> > Change-Id: I114e1a6ed8db901b3aa738a5052721d1da45cae4
> 
> Does it make sense to keep the Change-Id: things here?

Not really. But eventually I got lazy. I've now removed the auto-
generation for my tree, which means I'll have to add it manually
internally, but whatever :)

> > +@ class_group @
> > +identifier group_class;
> > +identifier attribute_groups_name.groups;
> > +fresh identifier group_dev_attr = attribute_group.group ##
> > "_dev_attrs";
> 
> So how will this work wrt naming scheme. Can we be sure all
> class_attrs occurrences in the files we copy are named as such, ie.
> with _dev_attrs post-fix?

No no, that's not what happens here. The _dev_attrs postfix is
generated by the ATTRIBUTE_GROUPS_BACKPORT() macro.

johannes
--
To unsubscribe from this list: send the line "unsubscribe backports" in
diff mbox

Patch

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 000000000000..a4694dd75763
--- /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);
+)