From patchwork Fri May 29 07:41:00 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Luis Chamberlain X-Patchwork-Id: 11578039 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id E7E43912 for ; Fri, 29 May 2020 07:56:15 +0000 (UTC) Received: from aserp2120.oracle.com (aserp2120.oracle.com [141.146.126.78]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id B9496207F5 for ; Fri, 29 May 2020 07:56:15 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org B9496207F5 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=kernel.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=ocfs2-devel-bounces@oss.oracle.com Received: from pps.filterd (aserp2120.oracle.com [127.0.0.1]) by aserp2120.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 04T7qE6F144095; Fri, 29 May 2020 07:55:31 GMT Received: from userp3020.oracle.com (userp3020.oracle.com [156.151.31.79]) by aserp2120.oracle.com with ESMTP id 318xe1ry0c-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL); Fri, 29 May 2020 07:55:31 +0000 Received: from pps.filterd (userp3020.oracle.com [127.0.0.1]) by userp3020.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 04T7ri28184026; Fri, 29 May 2020 07:55:30 GMT Received: from oss.oracle.com (oss-old-reserved.oracle.com [137.254.22.2]) by userp3020.oracle.com with ESMTP id 31a9ktuw9t-1 (version=TLSv1 cipher=AES256-SHA bits=256 verify=NO); Fri, 29 May 2020 07:55:30 +0000 Received: from localhost ([127.0.0.1] helo=lb-oss.oracle.com) by oss.oracle.com with esmtp (Exim 4.63) (envelope-from ) id 1jeZrV-0000KH-4f; Fri, 29 May 2020 00:55:29 -0700 Received: from aserp3020.oracle.com ([141.146.126.70]) by oss.oracle.com with esmtp (Exim 4.63) (envelope-from ) id 1jeZdo-0006cm-4j for ocfs2-devel@oss.oracle.com; Fri, 29 May 2020 00:41:20 -0700 Received: from pps.filterd (aserp3020.oracle.com [127.0.0.1]) by aserp3020.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 04T7bhNJ111482 for ; Fri, 29 May 2020 07:41:20 GMT Received: from userp2040.oracle.com (userp2040.oracle.com [156.151.31.90]) by aserp3020.oracle.com with ESMTP id 317j5xqxt4-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Fri, 29 May 2020 07:41:19 +0000 Received: from pps.filterd (userp2040.oracle.com [127.0.0.1]) by userp2040.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 04T7Xgvv018469 for ; Fri, 29 May 2020 07:41:19 GMT Received: from mail-pl1-f194.google.com (mail-pl1-f194.google.com [209.85.214.194]) by userp2040.oracle.com with ESMTP id 31avwbshjw-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128 verify=OK) for ; Fri, 29 May 2020 07:41:18 +0000 Received: by mail-pl1-f194.google.com with SMTP id t7so776815plr.0 for ; Fri, 29 May 2020 00:41:18 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=iFuOAMMzx366XD73njtfa9qdyal/YI+SEog1dnntDeg=; b=bMAa1+lNMWfMXqWzvG2pVYUFnJIGcXAkmx3cIfv2Kap0PbLFLXRlmW/qfdx7rUX9e3 ItxsvIt7rVmRYRQY57AolAKQ/zYr4DC4KLjwyn54x/SfOwiVRaubFuIUsD0q8W+htTLA UaBfpnsvLlWwJtMRyXPRscFnN2r5pDuHkc/Umv0tAXS3x2mMcYael2o5i2ai0weN6Gbq Qwve1r9C3LmJ8oJXWNgR2LTqCmYMtpxS2tnuWiH2DxkbX5KZ155f3fHACdfhMrlt13Xz 0jTbyD2rovjHjys/t7CNkQfhxjiE7mlU0x24sTXAjYR3Jzua8MKlRL9I8xrCDCwIN45z 1yTw== X-Gm-Message-State: AOAM531UJ+ImjOXBt3viXFbaewjr4slS0luOrEz4e6GwRI6jXwmLnuAf EEZp04gztG3Wy/85rPrcazs= X-Google-Smtp-Source: ABdhPJyWq+uNBt+z7g4lF4BNt9x39LLqlR7x3RVbHVyGUC5VKz7sfj4vqnpPnSKalsV1vnr314j4sQ== X-Received: by 2002:a17:902:82c9:: with SMTP id u9mr7568085plz.179.1590738077450; Fri, 29 May 2020 00:41:17 -0700 (PDT) Received: from 42.do-not-panic.com (42.do-not-panic.com. [157.230.128.187]) by smtp.gmail.com with ESMTPSA id 70sm6443717pfx.78.2020.05.29.00.41.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 29 May 2020 00:41:16 -0700 (PDT) Received: by 42.do-not-panic.com (Postfix, from userid 1000) id B233242337; Fri, 29 May 2020 07:41:10 +0000 (UTC) From: Luis Chamberlain To: keescook@chromium.org, yzaikin@google.com, nixiaoming@huawei.com, ebiederm@xmission.com, axboe@kernel.dk, clemens@ladisch.de, arnd@arndb.de, gregkh@linuxfoundation.org, jani.nikula@linux.intel.com, joonas.lahtinen@linux.intel.com, rodrigo.vivi@intel.com, airlied@linux.ie, daniel@ffwll.ch, benh@kernel.crashing.org, rdna@fb.com, viro@zeniv.linux.org.uk, mark@fasheh.com, jlbec@evilplan.org, joseph.qi@linux.alibaba.com, vbabka@suse.cz, sfr@canb.auug.org.au, jack@suse.cz, amir73il@gmail.com, rafael@kernel.org, tytso@mit.edu Date: Fri, 29 May 2020 07:41:00 +0000 Message-Id: <20200529074108.16928-6-mcgrof@kernel.org> X-Mailer: git-send-email 2.23.0.rc1 In-Reply-To: <20200529074108.16928-1-mcgrof@kernel.org> References: <20200529074108.16928-1-mcgrof@kernel.org> MIME-Version: 1.0 X-PDR: PASS X-Source-IP: 209.85.214.194 X-ServerName: mail-pl1-f194.google.com X-Proofpoint-SPF-Result: pass X-Proofpoint-SPF-Record: v=spf1 redirect=_spf.google.com X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9635 signatures=668686 X-Proofpoint-Spam-Details: rule=tap_notspam policy=tap score=0 cotscore=-2147483648 bulkscore=0 adultscore=0 mlxlogscore=691 clxscore=186 suspectscore=0 mlxscore=0 phishscore=0 priorityscore=60 impostorscore=0 lowpriorityscore=0 spamscore=0 malwarescore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2004280000 definitions=main-2005290058 X-Spam: Clean X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 bulkscore=0 spamscore=0 suspectscore=0 mlxlogscore=943 mlxscore=0 adultscore=0 phishscore=0 malwarescore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2004280000 definitions=main-2005290060 X-Mailman-Approved-At: Fri, 29 May 2020 00:55:28 -0700 Cc: intel-gfx@lists.freedesktop.org, linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org, julia.lawall@lip6.fr, Luis Chamberlain , linuxppc-dev@lists.ozlabs.org, ocfs2-devel@oss.oracle.com Subject: [Ocfs2-devel] [PATCH 05/13] macintosh/mac_hid.c: use new sysctl subdir helper register_sysctl_subdir() X-BeenThere: ocfs2-devel@oss.oracle.com X-Mailman-Version: 2.1.9 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: ocfs2-devel-bounces@oss.oracle.com Errors-To: ocfs2-devel-bounces@oss.oracle.com X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9635 signatures=668686 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=0 mlxscore=0 adultscore=0 mlxlogscore=999 malwarescore=0 spamscore=0 bulkscore=0 phishscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2004280000 definitions=main-2005290062 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9635 signatures=668686 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 spamscore=0 mlxlogscore=999 adultscore=0 cotscore=-2147483648 mlxscore=0 bulkscore=0 priorityscore=1501 phishscore=0 lowpriorityscore=0 malwarescore=0 clxscore=1015 impostorscore=0 suspectscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2004280000 definitions=main-2005290062 This simplifies the code considerably. The following coccinelle SmPL grammar rule was used to transform this code. // pycocci sysctl-subdir.cocci drivers/macintosh/mac_hid.c @c1@ expression E1; identifier subdir, sysctls; @@ static struct ctl_table subdir[] = { { .procname = E1, .maxlen = 0, .mode = 0555, .child = sysctls, }, { } }; @c2@ identifier c1.subdir; expression E2; identifier base; @@ static struct ctl_table base[] = { { .procname = E2, .maxlen = 0, .mode = 0555, .child = subdir, }, { } }; @c3@ identifier c2.base; identifier header; @@ header = register_sysctl_table(base); @r1 depends on c1 && c2 && c3@ expression c1.E1; identifier c1.subdir, c1.sysctls; @@ -static struct ctl_table subdir[] = { - { - .procname = E1, - .maxlen = 0, - .mode = 0555, - .child = sysctls, - }, - { } -}; @r2 depends on c1 && c2 && c3@ identifier c1.subdir; expression c2.E2; identifier c2.base; @@ -static struct ctl_table base[] = { - { - .procname = E2, - .maxlen = 0, - .mode = 0555, - .child = subdir, - }, - { } -}; @r3 depends on c1 && c2 && c3@ expression c1.E1; identifier c1.sysctls; expression c2.E2; identifier c2.base; identifier c3.header; @@ header = -register_sysctl_table(base); +register_sysctl_subdir(E2, E1, sysctls); Generated-by: Coccinelle SmPL Signed-off-by: Luis Chamberlain --- drivers/macintosh/mac_hid.c | 25 ++----------------------- 1 file changed, 2 insertions(+), 23 deletions(-) diff --git a/drivers/macintosh/mac_hid.c b/drivers/macintosh/mac_hid.c index 28b8581b44dd..736d0e151716 100644 --- a/drivers/macintosh/mac_hid.c +++ b/drivers/macintosh/mac_hid.c @@ -239,33 +239,12 @@ static struct ctl_table mac_hid_files[] = { { } }; -/* dir in /proc/sys/dev */ -static struct ctl_table mac_hid_dir[] = { - { - .procname = "mac_hid", - .maxlen = 0, - .mode = 0555, - .child = mac_hid_files, - }, - { } -}; - -/* /proc/sys/dev itself, in case that is not there yet */ -static struct ctl_table mac_hid_root_dir[] = { - { - .procname = "dev", - .maxlen = 0, - .mode = 0555, - .child = mac_hid_dir, - }, - { } -}; - static struct ctl_table_header *mac_hid_sysctl_header; static int __init mac_hid_init(void) { - mac_hid_sysctl_header = register_sysctl_table(mac_hid_root_dir); + mac_hid_sysctl_header = register_sysctl_subdir("dev", "mac_hid", + mac_hid_files); if (!mac_hid_sysctl_header) return -ENOMEM;