From: Luis Chamberlain <mcgrof@kernel.org> To: akpm@linux-foundation.org, keescook@chromium.org, yzaikin@google.com, nixiaoming@huawei.com, ebiederm@xmission.com, clemens@ladisch.de, arnd@arndb.de, gregkh@linuxfoundation.org, jani.nikula@linux.intel.com, joonas.lahtinen@linux.intel.com, rodrigo.vivi@intel.com, tvrtko.ursulin@linux.intel.com, airlied@linux.ie, "daniel@ffwll.chairlied"@linux.ie, benh@kernel.crashing.org, mark@fasheh.com, jlbec@evilplan.org, joseph.qi@linux.alibaba.com, jack@suse.cz, amir73il@gmail.com, phil@philpotter.co.uk, viro@zeniv.linux.org.uk, julia.lawall@inria.fr Cc: intel-gfx@lists.freedesktop.org, linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org, Luis Chamberlain <mcgrof@kernel.org>, linux-fsdevel@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, ocfs2-devel@oss.oracle.com Subject: [PATCH v2 3/8] macintosh/mac_hid.c: simplify subdirectory registration with register_sysctl() Date: Tue, 23 Nov 2021 12:24:17 -0800 [thread overview] Message-ID: <20211123202422.819032-4-mcgrof@kernel.org> (raw) In-Reply-To: <20211123202422.819032-1-mcgrof@kernel.org> There is no need to user boiler plate code to specify a set of base directories we're going to stuff sysctls under. Simplify this by using register_sysctl() and specifying the directory path directly. // pycocci sysctl-subdir-register-sysctl-simplify.cocci PATH @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, - }, - { } -}; @initialize:python@ @@ def make_my_fresh_expression(s1, s2): return '"' + s1.strip('"') + "/" + s2.strip('"') + '"' @r3 depends on c1 && c2 && c3@ expression c1.E1; identifier c1.sysctls; expression c2.E2; identifier c2.base; identifier c3.header; fresh identifier E3 = script:python(E2, E1) { make_my_fresh_expression(E2, E1) }; @@ header = -register_sysctl_table(base); +register_sysctl(E3, sysctls); Generated-by: Coccinelle SmPL Signed-off-by: Luis Chamberlain <mcgrof@kernel.org> --- drivers/macintosh/mac_hid.c | 24 +----------------------- 1 file changed, 1 insertion(+), 23 deletions(-) diff --git a/drivers/macintosh/mac_hid.c b/drivers/macintosh/mac_hid.c index 28b8581b44dd..d8c4d5664145 100644 --- a/drivers/macintosh/mac_hid.c +++ b/drivers/macintosh/mac_hid.c @@ -239,33 +239,11 @@ 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("dev/mac_hid", mac_hid_files); if (!mac_hid_sysctl_header) return -ENOMEM; -- 2.33.0
WARNING: multiple messages have this Message-ID (diff)
From: Luis Chamberlain <mcgrof@kernel.org> To: akpm@linux-foundation.org, keescook@chromium.org, yzaikin@google.com, nixiaoming@huawei.com, ebiederm@xmission.com, clemens@ladisch.de, arnd@arndb.de, gregkh@linuxfoundation.org, jani.nikula@linux.intel.com, joonas.lahtinen@linux.intel.com, rodrigo.vivi@intel.com, tvrtko.ursulin@linux.intel.com, airlied@linux.ie, "daniel@ffwll.chairlied"@linux.ie, benh@kernel.crashing.org, mark@fasheh.com, jlbec@evilplan.org, joseph.qi@linux.alibaba.com, jack@suse.cz, amir73il@gmail.com, phil@philpotter.co.uk, viro@zeniv.linux.org.uk, julia.lawall@inria.fr Cc: intel-gfx@lists.freedesktop.org, linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org, Luis Chamberlain <mcgrof@kernel.org>, linux-fsdevel@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, ocfs2-devel@oss.oracle.com Subject: [Intel-gfx] [PATCH v2 3/8] macintosh/mac_hid.c: simplify subdirectory registration with register_sysctl() Date: Tue, 23 Nov 2021 12:24:17 -0800 [thread overview] Message-ID: <20211123202422.819032-4-mcgrof@kernel.org> (raw) In-Reply-To: <20211123202422.819032-1-mcgrof@kernel.org> There is no need to user boiler plate code to specify a set of base directories we're going to stuff sysctls under. Simplify this by using register_sysctl() and specifying the directory path directly. // pycocci sysctl-subdir-register-sysctl-simplify.cocci PATH @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, - }, - { } -}; @initialize:python@ @@ def make_my_fresh_expression(s1, s2): return '"' + s1.strip('"') + "/" + s2.strip('"') + '"' @r3 depends on c1 && c2 && c3@ expression c1.E1; identifier c1.sysctls; expression c2.E2; identifier c2.base; identifier c3.header; fresh identifier E3 = script:python(E2, E1) { make_my_fresh_expression(E2, E1) }; @@ header = -register_sysctl_table(base); +register_sysctl(E3, sysctls); Generated-by: Coccinelle SmPL Signed-off-by: Luis Chamberlain <mcgrof@kernel.org> --- drivers/macintosh/mac_hid.c | 24 +----------------------- 1 file changed, 1 insertion(+), 23 deletions(-) diff --git a/drivers/macintosh/mac_hid.c b/drivers/macintosh/mac_hid.c index 28b8581b44dd..d8c4d5664145 100644 --- a/drivers/macintosh/mac_hid.c +++ b/drivers/macintosh/mac_hid.c @@ -239,33 +239,11 @@ 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("dev/mac_hid", mac_hid_files); if (!mac_hid_sysctl_header) return -ENOMEM; -- 2.33.0
next prev parent reply other threads:[~2021-11-23 20:26 UTC|newest] Thread overview: 42+ messages / expand[flat|nested] mbox.gz Atom feed top 2021-11-23 20:24 [PATCH v2 0/8] sysctl: second set of kernel/sysctl cleanups Luis Chamberlain 2021-11-23 20:24 ` [Intel-gfx] " Luis Chamberlain 2021-11-23 20:24 ` [PATCH v2 1/8] hpet: simplify subdirectory registration with register_sysctl() Luis Chamberlain 2021-11-23 20:24 ` [Intel-gfx] " Luis Chamberlain 2021-11-23 20:24 ` [PATCH v2 2/8] i915: " Luis Chamberlain 2021-11-23 20:24 ` [Intel-gfx] " Luis Chamberlain 2021-11-25 9:41 ` Jani Nikula 2021-11-25 9:41 ` Jani Nikula 2021-11-25 9:41 ` [Intel-gfx] " Jani Nikula 2021-11-23 20:24 ` Luis Chamberlain [this message] 2021-11-23 20:24 ` [Intel-gfx] [PATCH v2 3/8] macintosh/mac_hid.c: " Luis Chamberlain 2021-11-23 20:24 ` [PATCH v2 4/8] ocfs2: " Luis Chamberlain 2021-11-23 20:24 ` [Intel-gfx] " Luis Chamberlain 2021-11-24 9:49 ` Jan Kara 2021-11-24 9:49 ` [Intel-gfx] " Jan Kara 2021-11-24 9:49 ` Jan Kara 2021-11-24 9:49 ` Jan Kara 2021-11-24 9:49 ` [Ocfs2-devel] " Jan Kara via Ocfs2-devel 2021-11-23 20:24 ` [PATCH v2 5/8] test_sysctl: " Luis Chamberlain 2021-11-23 20:24 ` [Intel-gfx] " Luis Chamberlain 2021-11-23 20:24 ` [PATCH v2 6/8] inotify: " Luis Chamberlain 2021-11-23 20:24 ` [Intel-gfx] " Luis Chamberlain 2021-11-24 9:44 ` Jan Kara 2021-11-24 9:44 ` Jan Kara 2021-11-24 9:44 ` [Intel-gfx] " Jan Kara 2021-11-24 9:44 ` Jan Kara 2021-11-24 9:44 ` [Ocfs2-devel] " Jan Kara via Ocfs2-devel 2021-11-24 13:40 ` Luis Chamberlain 2021-11-24 13:40 ` Luis Chamberlain 2021-11-24 13:40 ` [Ocfs2-devel] " Luis Chamberlain via Ocfs2-devel 2021-11-24 13:40 ` [Intel-gfx] " Luis Chamberlain 2021-11-24 13:40 ` Luis Chamberlain 2021-11-23 20:24 ` [PATCH v2 7/8] cdrom: " Luis Chamberlain 2021-11-23 20:24 ` [Intel-gfx] " Luis Chamberlain 2021-11-25 9:23 ` Phillip Potter 2021-11-25 9:23 ` [Intel-gfx] " Phillip Potter 2021-11-25 9:23 ` Phillip Potter 2021-11-25 9:23 ` Phillip Potter 2021-11-23 20:24 ` [PATCH v2 8/8] eventpoll: simplify sysctl declaration " Luis Chamberlain 2021-11-23 20:24 ` [Intel-gfx] " Luis Chamberlain 2021-11-23 22:56 ` [Intel-gfx] ✗ Fi.CI.BUILD: failure for sysctl: second set of kernel/sysctl cleanups Patchwork 2021-11-24 13:59 ` [Intel-gfx] ✗ Fi.CI.BUILD: failure for sysctl: second set of kernel/sysctl cleanups (rev2) Patchwork
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=20211123202422.819032-4-mcgrof@kernel.org \ --to=mcgrof@kernel.org \ --cc="daniel@ffwll.chairlied"@linux.ie \ --cc=airlied@linux.ie \ --cc=akpm@linux-foundation.org \ --cc=amir73il@gmail.com \ --cc=arnd@arndb.de \ --cc=benh@kernel.crashing.org \ --cc=clemens@ladisch.de \ --cc=dri-devel@lists.freedesktop.org \ --cc=ebiederm@xmission.com \ --cc=gregkh@linuxfoundation.org \ --cc=intel-gfx@lists.freedesktop.org \ --cc=jack@suse.cz \ --cc=jani.nikula@linux.intel.com \ --cc=jlbec@evilplan.org \ --cc=joonas.lahtinen@linux.intel.com \ --cc=joseph.qi@linux.alibaba.com \ --cc=julia.lawall@inria.fr \ --cc=keescook@chromium.org \ --cc=linux-fsdevel@vger.kernel.org \ --cc=linux-kernel@vger.kernel.org \ --cc=linuxppc-dev@lists.ozlabs.org \ --cc=mark@fasheh.com \ --cc=nixiaoming@huawei.com \ --cc=ocfs2-devel@oss.oracle.com \ --cc=phil@philpotter.co.uk \ --cc=rodrigo.vivi@intel.com \ --cc=tvrtko.ursulin@linux.intel.com \ --cc=viro@zeniv.linux.org.uk \ --cc=yzaikin@google.com \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes, see mirroring instructions on how to clone and mirror all data and code used by this external index.