From: Jani Nikula <jani.nikula@linux.intel.com>
To: Luis Chamberlain <mcgrof@kernel.org>,
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,
joonas.lahtinen@linux.intel.com, rodrigo.vivi@intel.com,
tvrtko.ursulin@linux.intel.com, airlied@linux.ie,
daniel@ffwll.chairlied, 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: ocfs2-devel@oss.oracle.com, linuxppc-dev@lists.ozlabs.org,
intel-gfx@lists.freedesktop.org, dri-devel@lists.freedesktop.org,
linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org,
Luis Chamberlain <mcgrof@kernel.org>
Subject: Re: [PATCH v2 2/8] i915: simplify subdirectory registration with register_sysctl()
Date: Thu, 25 Nov 2021 11:41:30 +0200 [thread overview]
Message-ID: <87fsrklghh.fsf@intel.com> (raw)
In-Reply-To: <20211123202422.819032-3-mcgrof@kernel.org>
On Tue, 23 Nov 2021, Luis Chamberlain <mcgrof@kernel.org> wrote:
> 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.
\o/
Acked-by: Jani Nikula <jani.nikula@intel.com>
>
> // 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/gpu/drm/i915/i915_perf.c | 22 +---------------------
> 1 file changed, 1 insertion(+), 21 deletions(-)
>
> diff --git a/drivers/gpu/drm/i915/i915_perf.c b/drivers/gpu/drm/i915/i915_perf.c
> index 2f01b8c0284c..5979e3258647 100644
> --- a/drivers/gpu/drm/i915/i915_perf.c
> +++ b/drivers/gpu/drm/i915/i915_perf.c
> @@ -4273,26 +4273,6 @@ static struct ctl_table oa_table[] = {
> {}
> };
>
> -static struct ctl_table i915_root[] = {
> - {
> - .procname = "i915",
> - .maxlen = 0,
> - .mode = 0555,
> - .child = oa_table,
> - },
> - {}
> -};
> -
> -static struct ctl_table dev_root[] = {
> - {
> - .procname = "dev",
> - .maxlen = 0,
> - .mode = 0555,
> - .child = i915_root,
> - },
> - {}
> -};
> -
> static void oa_init_supported_formats(struct i915_perf *perf)
> {
> struct drm_i915_private *i915 = perf->i915;
> @@ -4488,7 +4468,7 @@ static int destroy_config(int id, void *p, void *data)
>
> int i915_perf_sysctl_register(void)
> {
> - sysctl_header = register_sysctl_table(dev_root);
> + sysctl_header = register_sysctl("dev/i915", oa_table);
> return 0;
> }
--
Jani Nikula, Intel Open Source Graphics Center
prev parent reply other threads:[~2021-11-25 9:43 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <20211123202422.819032-1-mcgrof@kernel.org>
[not found] ` <20211123202422.819032-7-mcgrof@kernel.org>
2021-11-24 9:44 ` [PATCH v2 6/8] inotify: simplify subdirectory registration with register_sysctl() Jan Kara
2021-11-24 13:40 ` Luis Chamberlain
[not found] ` <20211123202422.819032-5-mcgrof@kernel.org>
2021-11-24 9:49 ` [PATCH v2 4/8] ocfs2: " Jan Kara
[not found] ` <20211123202422.819032-8-mcgrof@kernel.org>
2021-11-25 9:23 ` [PATCH v2 7/8] cdrom: " Phillip Potter
[not found] ` <20211123202422.819032-3-mcgrof@kernel.org>
2021-11-25 9:41 ` Jani Nikula [this message]
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=87fsrklghh.fsf@intel.com \
--to=jani.nikula@linux.intel.com \
--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=daniel@ffwll.chairlied \
--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=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=mcgrof@kernel.org \
--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: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).