linux-fsdevel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Luis Chamberlain <mcgrof@kernel.org>
To: ebiederm@xmission.com, keescook@chromium.org, yzaikin@google.com,
	jejb@linux.ibm.com, martin.petersen@oracle.com, minyard@acm.org,
	kys@microsoft.com, haiyangz@microsoft.com, wei.liu@kernel.org,
	decui@microsoft.com, song@kernel.org, robinmholt@gmail.com,
	steve.wahl@hpe.com, mike.travis@hpe.com, arnd@arndb.de,
	gregkh@linuxfoundation.org, jirislaby@kernel.org,
	jgross@suse.com, sstabellini@kernel.org,
	oleksandr_tyshchenko@epam.com, xen-devel@lists.xenproject.org
Cc: j.granados@samsung.com, zhangpeng362@huawei.com,
	tangmeng@uniontech.com, willy@infradead.org,
	nixiaoming@huawei.com, sujiaxun@uniontech.com,
	patches@lists.linux.dev, linux-fsdevel@vger.kernel.org,
	apparmor@lists.ubuntu.com, linux-raid@vger.kernel.org,
	linux-scsi@vger.kernel.org, linux-hyperv@vger.kernel.org,
	openipmi-developer@lists.sourceforge.net,
	linux-kernel@vger.kernel.org,
	Luis Chamberlain <mcgrof@kernel.org>
Subject: [PATCH 5/7] sgi-xp: simplify sysctl registration
Date: Thu,  2 Mar 2023 12:46:10 -0800	[thread overview]
Message-ID: <20230302204612.782387-6-mcgrof@kernel.org> (raw)
In-Reply-To: <20230302204612.782387-1-mcgrof@kernel.org>

Although this driver is a good use case for having a directory
that is not other directories and then subdirectories with more
entries, the usage of register_sysctl_table() can recurse and
increases complexity so to avoid that just split out the
registration to each directory with its own entries.

register_sysctl_table() is a deprecated compatibility wrapper.
register_sysctl() can do the directory creation for you so just use
that.

Signed-off-by: Luis Chamberlain <mcgrof@kernel.org>
---
 drivers/misc/sgi-xp/xpc_main.c | 24 ++++++++++--------------
 1 file changed, 10 insertions(+), 14 deletions(-)

diff --git a/drivers/misc/sgi-xp/xpc_main.c b/drivers/misc/sgi-xp/xpc_main.c
index b2c3c22fc13c..6da509d692bb 100644
--- a/drivers/misc/sgi-xp/xpc_main.c
+++ b/drivers/misc/sgi-xp/xpc_main.c
@@ -93,7 +93,7 @@ int xpc_disengage_timelimit = XPC_DISENGAGE_DEFAULT_TIMELIMIT;
 static int xpc_disengage_min_timelimit;	/* = 0 */
 static int xpc_disengage_max_timelimit = 120;
 
-static struct ctl_table xpc_sys_xpc_hb_dir[] = {
+static struct ctl_table xpc_sys_xpc_hb[] = {
 	{
 	 .procname = "hb_interval",
 	 .data = &xpc_hb_interval,
@@ -112,11 +112,7 @@ static struct ctl_table xpc_sys_xpc_hb_dir[] = {
 	 .extra2 = &xpc_hb_check_max_interval},
 	{}
 };
-static struct ctl_table xpc_sys_xpc_dir[] = {
-	{
-	 .procname = "hb",
-	 .mode = 0555,
-	 .child = xpc_sys_xpc_hb_dir},
+static struct ctl_table xpc_sys_xpc[] = {
 	{
 	 .procname = "disengage_timelimit",
 	 .data = &xpc_disengage_timelimit,
@@ -127,14 +123,9 @@ static struct ctl_table xpc_sys_xpc_dir[] = {
 	 .extra2 = &xpc_disengage_max_timelimit},
 	{}
 };
-static struct ctl_table xpc_sys_dir[] = {
-	{
-	 .procname = "xpc",
-	 .mode = 0555,
-	 .child = xpc_sys_xpc_dir},
-	{}
-};
+
 static struct ctl_table_header *xpc_sysctl;
+static struct ctl_table_header *xpc_sysctl_hb;
 
 /* non-zero if any remote partition disengage was timed out */
 int xpc_disengage_timedout;
@@ -1041,6 +1032,8 @@ xpc_do_exit(enum xp_retval reason)
 
 	if (xpc_sysctl)
 		unregister_sysctl_table(xpc_sysctl);
+	if (xpc_sysctl_hb)
+		unregister_sysctl_table(xpc_sysctl_hb);
 
 	xpc_teardown_partitions();
 
@@ -1243,7 +1236,8 @@ xpc_init(void)
 		goto out_1;
 	}
 
-	xpc_sysctl = register_sysctl_table(xpc_sys_dir);
+	xpc_sysctl = register_sysctl("xpc", xpc_sys_xpc);
+	xpc_sysctl_hb = register_sysctl("xpc/hb", xpc_sys_xpc_hb);
 
 	/*
 	 * Fill the partition reserved page with the information needed by
@@ -1308,6 +1302,8 @@ xpc_init(void)
 	(void)unregister_die_notifier(&xpc_die_notifier);
 	(void)unregister_reboot_notifier(&xpc_reboot_notifier);
 out_2:
+	if (xpc_sysctl_hb)
+		unregister_sysctl_table(xpc_sysctl_hb);
 	if (xpc_sysctl)
 		unregister_sysctl_table(xpc_sysctl);
 
-- 
2.39.1


  parent reply	other threads:[~2023-03-02 20:47 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-03-02 20:46 [PATCH 0/7] sysctl: slowly deprecate register_sysctl_table() Luis Chamberlain
2023-03-02 20:46 ` [PATCH 1/7] scsi: simplify sysctl registration with register_sysctl() Luis Chamberlain
2023-03-02 20:46 ` [PATCH 2/7] ipmi: simplify sysctl registration Luis Chamberlain
2023-03-02 22:17   ` Corey Minyard
2023-03-02 20:46 ` [PATCH 3/7] hv: " Luis Chamberlain
2023-03-03  0:59   ` Michael Kelley (LINUX)
2023-03-06 15:27   ` Wei Liu
2023-03-02 20:46 ` [PATCH 4/7] md: " Luis Chamberlain
2023-03-03 18:16   ` Song Liu
2023-03-02 20:46 ` Luis Chamberlain [this message]
2023-03-07 22:24   ` [PATCH 5/7] sgi-xp: " Steve Wahl
2023-03-02 20:46 ` [PATCH 6/7] tty: " Luis Chamberlain
2023-03-02 20:46 ` [PATCH 7/7] xen: simplify sysctl registration for balloon Luis Chamberlain
2023-03-06  8:10   ` Juergen Gross
2023-03-09 22:18 ` [PATCH 0/7] sysctl: slowly deprecate register_sysctl_table() Luis Chamberlain

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=20230302204612.782387-6-mcgrof@kernel.org \
    --to=mcgrof@kernel.org \
    --cc=apparmor@lists.ubuntu.com \
    --cc=arnd@arndb.de \
    --cc=decui@microsoft.com \
    --cc=ebiederm@xmission.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=haiyangz@microsoft.com \
    --cc=j.granados@samsung.com \
    --cc=jejb@linux.ibm.com \
    --cc=jgross@suse.com \
    --cc=jirislaby@kernel.org \
    --cc=keescook@chromium.org \
    --cc=kys@microsoft.com \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-hyperv@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-raid@vger.kernel.org \
    --cc=linux-scsi@vger.kernel.org \
    --cc=martin.petersen@oracle.com \
    --cc=mike.travis@hpe.com \
    --cc=minyard@acm.org \
    --cc=nixiaoming@huawei.com \
    --cc=oleksandr_tyshchenko@epam.com \
    --cc=openipmi-developer@lists.sourceforge.net \
    --cc=patches@lists.linux.dev \
    --cc=robinmholt@gmail.com \
    --cc=song@kernel.org \
    --cc=sstabellini@kernel.org \
    --cc=steve.wahl@hpe.com \
    --cc=sujiaxun@uniontech.com \
    --cc=tangmeng@uniontech.com \
    --cc=wei.liu@kernel.org \
    --cc=willy@infradead.org \
    --cc=xen-devel@lists.xenproject.org \
    --cc=yzaikin@google.com \
    --cc=zhangpeng362@huawei.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).