From patchwork Mon Feb 6 12:39:56 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Johannes Berg X-Patchwork-Id: 9557713 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 39176604E0 for ; Mon, 6 Feb 2017 12:40:02 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 29ED326C9B for ; Mon, 6 Feb 2017 12:40:02 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 1ED882654B; Mon, 6 Feb 2017 12:40:02 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C05A926C9B for ; Mon, 6 Feb 2017 12:40:01 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1750956AbdBFMkB (ORCPT ); Mon, 6 Feb 2017 07:40:01 -0500 Received: from s3.sipsolutions.net ([5.9.151.49]:39814 "EHLO sipsolutions.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751437AbdBFMkA (ORCPT ); Mon, 6 Feb 2017 07:40:00 -0500 Received: by sipsolutions.net with esmtpsa (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.88) (envelope-from ) id 1caiaN-0003IL-EN; Mon, 06 Feb 2017 13:39:59 +0100 From: Johannes Berg To: backports@vger.kernel.org Cc: Johannes Berg Subject: [PATCH 3/3] backports: support class_groups Date: Mon, 6 Feb 2017 13:39:56 +0100 Message-Id: <20170206123956.20082-3-johannes@sipsolutions.net> X-Mailer: git-send-email 2.9.3 In-Reply-To: <20170206123956.20082-1-johannes@sipsolutions.net> References: <20170206123956.20082-1-johannes@sipsolutions.net> Sender: backports-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: backports@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Johannes Berg Add a new semantic patch just like for dev_groups to support class_groups. Change-Id: I114e1a6ed8db901b3aa738a5052721d1da45cae4 Signed-off-by: Johannes Berg --- .../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"; +@@ + +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); +)