]> git.karo-electronics.de Git - karo-tx-linux.git/blobdiff - kernel/sysctl.c
Use the new proc_do_intvec_bool() handler for various boolean inputs.
[karo-tx-linux.git] / kernel / sysctl.c
index 11d65b531e507a8b98d8411123bde6aff76bda97..b09b6be2ab1908d13a4dd30f60d95c8ffbdbb75d 100644 (file)
@@ -18,7 +18,7 @@
  *  Removed it and replaced it with older style, 03/23/00, Bill Wendling
  */
 
-#include <linux/module.h>
+#include <linux/export.h>
 #include <linux/mm.h>
 #include <linux/swap.h>
 #include <linux/slab.h>
@@ -349,9 +349,7 @@ static struct ctl_table kern_table[] = {
                .data           = &sysctl_timer_migration,
                .maxlen         = sizeof(unsigned int),
                .mode           = 0644,
-               .proc_handler   = proc_dointvec_minmax,
-               .extra1         = &zero,
-               .extra2         = &one,
+               .proc_handler   = proc_dointvec_bool,
        },
 #endif
        {
@@ -709,9 +707,7 @@ static struct ctl_table kern_table[] = {
                .data           = &dmesg_restrict,
                .maxlen         = sizeof(int),
                .mode           = 0644,
-               .proc_handler   = proc_dointvec_minmax,
-               .extra1         = &zero,
-               .extra2         = &one,
+               .proc_handler   = proc_dointvec_bool,
        },
        {
                .procname       = "kptr_restrict",
@@ -754,9 +750,7 @@ static struct ctl_table kern_table[] = {
                .data           = &softlockup_panic,
                .maxlen         = sizeof(int),
                .mode           = 0644,
-               .proc_handler   = proc_dointvec_minmax,
-               .extra1         = &zero,
-               .extra2         = &one,
+               .proc_handler   = proc_dointvec_bool,
        },
        {
                .procname       = "nmi_watchdog",
@@ -870,9 +864,7 @@ static struct ctl_table kern_table[] = {
                .data           = &sysctl_hung_task_panic,
                .maxlen         = sizeof(int),
                .mode           = 0644,
-               .proc_handler   = proc_dointvec_minmax,
-               .extra1         = &zero,
-               .extra2         = &one,
+               .proc_handler   = proc_dointvec_bool,
        },
        {
                .procname       = "hung_task_check_count",
@@ -1320,9 +1312,7 @@ static struct ctl_table vm_table[] = {
                .data           = &vm_highmem_is_dirtyable,
                .maxlen         = sizeof(vm_highmem_is_dirtyable),
                .mode           = 0644,
-               .proc_handler   = proc_dointvec_minmax,
-               .extra1         = &zero,
-               .extra2         = &one,
+               .proc_handler   = proc_dointvec_bool,
        },
 #endif
        {
@@ -1338,18 +1328,14 @@ static struct ctl_table vm_table[] = {
                .data           = &sysctl_memory_failure_early_kill,
                .maxlen         = sizeof(sysctl_memory_failure_early_kill),
                .mode           = 0644,
-               .proc_handler   = proc_dointvec_minmax,
-               .extra1         = &zero,
-               .extra2         = &one,
+               .proc_handler   = proc_dointvec_bool,
        },
        {
                .procname       = "memory_failure_recovery",
                .data           = &sysctl_memory_failure_recovery,
                .maxlen         = sizeof(sysctl_memory_failure_recovery),
                .mode           = 0644,
-               .proc_handler   = proc_dointvec_minmax,
-               .extra1         = &zero,
-               .extra2         = &one,
+               .proc_handler   = proc_dointvec_bool,
        },
 #endif
        { }
@@ -2477,6 +2463,33 @@ int proc_dointvec_minmax(struct ctl_table *table, int write,
                                do_proc_dointvec_minmax_conv, &param);
 }
 
+/**
+ * proc_dointvec_bool - read a vector of integers with 0/1 values
+ * @table: the sysctl table
+ * @write: %TRUE if this is a write to the sysctl file
+ * @buffer: the user buffer
+ * @lenp: the size of the user buffer
+ * @ppos: file position
+ *
+ * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
+ * values from/to the user buffer, treated as an ASCII string.
+ *
+ * This routine will ensure the values are either 0 or 1.
+ *
+ * Returns 0 on success.
+ */
+int proc_dointvec_bool(struct ctl_table *table, int write,
+                 void __user *buffer, size_t *lenp, loff_t *ppos)
+{
+       struct do_proc_dointvec_minmax_conv_param param = {
+               .min = &zero,
+               .max = &one,
+       };
+       return do_proc_dointvec(table, write, buffer, lenp, ppos,
+                               do_proc_dointvec_minmax_conv, &param);
+}
+EXPORT_SYMBOL(proc_dointvec_bool);
+
 static int __do_proc_doulongvec_minmax(void *data, struct ctl_table *table, int write,
                                     void __user *buffer,
                                     size_t *lenp, loff_t *ppos,