diff mbox series

[v2,01/11] kernel/parisc: move soft-power sysctl to its own file

Message ID 20220221060847.9917-1-tangmeng@uniontech.com (mailing list archive)
State New, archived
Headers show
Series [v2,01/11] kernel/parisc: move soft-power sysctl to its own file | expand

Commit Message

Meng Tang Feb. 21, 2022, 6:08 a.m. UTC
kernel/sysctl.c is a kitchen sink where everyone leaves their dirty
dishes, this makes it very difficult to maintain.

To help with this maintenance let's start by moving sysctls to places
where they actually belong.  The proc sysctl maintainers do not want to
know what sysctl knobs you wish to add for your own piece of code, we
just care about the core logic.

All filesystem syctls now get reviewed by fs folks. This commit
follows the commit of fs, move the soft-power sysctl to its own file,
kernel/parisc/power.c.

Signed-off-by: tangmeng <tangmeng@uniontech.com>
---
 drivers/parisc/power.c | 24 ++++++++++++++++++++++--
 include/linux/sysctl.h |  1 -
 kernel/sysctl.c        |  9 ---------
 3 files changed, 22 insertions(+), 12 deletions(-)
diff mbox series

Patch

diff --git a/drivers/parisc/power.c b/drivers/parisc/power.c
index 456776bd8ee6..2426b6868a5a 100644
--- a/drivers/parisc/power.c
+++ b/drivers/parisc/power.c
@@ -109,7 +109,26 @@  static struct task_struct *power_task;
 #define SYSCTL_FILENAME	"sys/kernel/power"
 
 /* soft power switch enabled/disabled */
-int pwrsw_enabled __read_mostly = 1;
+static int pwrsw_enabled __read_mostly = 1;
+#ifdef CONFIG_SYSCTL
+static struct ctl_table kern_parisc_power_table[] = {
+	{
+		.procname       = "soft-power",
+		.data           = &pwrsw_enabled,
+		.maxlen         = sizeof(int),
+		.mode           = 0644,
+		.proc_handler   = proc_dointvec,
+	},
+	{ }
+};
+
+static void __init kernel_parisc_power_sysctls_init(void)
+{
+	register_sysctl_init("kernel", kern_parisc_power_table);
+}
+#else
+#define kernel_parisc_power_sysctls_init() do { } while (0)
+#endif /* CONFIG_SYSCTL */
 
 /* main kernel thread worker. It polls the button state */
 static int kpowerswd(void *param)
@@ -193,7 +212,6 @@  static struct notifier_block parisc_panic_block = {
 	.priority	= INT_MAX,
 };
 
-
 static int __init power_init(void)
 {
 	unsigned long ret;
@@ -233,6 +251,8 @@  static int __init power_init(void)
 	atomic_notifier_chain_register(&panic_notifier_list,
 			&parisc_panic_block);
 
+	kernel_parisc_power_sysctls_init();
+
 	return 0;
 }
 
diff --git a/include/linux/sysctl.h b/include/linux/sysctl.h
index 6353d6db69b2..e00bf436d63b 100644
--- a/include/linux/sysctl.h
+++ b/include/linux/sysctl.h
@@ -242,7 +242,6 @@  int do_proc_douintvec(struct ctl_table *table, int write,
 				  int write, void *data),
 		      void *data);
 
-extern int pwrsw_enabled;
 extern int unaligned_enabled;
 extern int unaligned_dump_stack;
 extern int no_unaligned_warning;
diff --git a/kernel/sysctl.c b/kernel/sysctl.c
index 22037f03cd2b..d11390634321 100644
--- a/kernel/sysctl.c
+++ b/kernel/sysctl.c
@@ -1737,15 +1737,6 @@  static struct ctl_table kern_table[] = {
 		.proc_handler	= proc_dointvec,
 	},
 #endif
-#ifdef CONFIG_PARISC
-	{
-		.procname	= "soft-power",
-		.data		= &pwrsw_enabled,
-		.maxlen		= sizeof (int),
-		.mode		= 0644,
-		.proc_handler	= proc_dointvec,
-	},
-#endif
 #ifdef CONFIG_SYSCTL_ARCH_UNALIGN_ALLOW
 	{
 		.procname	= "unaligned-trap",