drm: virtio_gpu: add support for ARGB8888 primary plane
[platform/kernel/linux-rpi.git] / kernel / sysctl.c
index 347a90a..928798f 100644 (file)
 static int sixty = 60;
 #endif
 
-static int __maybe_unused neg_one = -1;
-static int __maybe_unused two = 2;
-static int __maybe_unused four = 4;
 static unsigned long zero_ul;
 static unsigned long one_ul = 1;
 static unsigned long long_max = LONG_MAX;
-static int one_hundred = 100;
-static int two_hundred = 200;
-static int one_thousand = 1000;
-static int three_thousand = 3000;
 #ifdef CONFIG_PRINTK
 static int ten_thousand = 10000;
 #endif
@@ -386,13 +379,14 @@ int proc_dostring(struct ctl_table *table, int write,
                        ppos);
 }
 
-static size_t proc_skip_spaces(char **buf)
+static void proc_skip_spaces(char **buf, size_t *size)
 {
-       size_t ret;
-       char *tmp = skip_spaces(*buf);
-       ret = tmp - *buf;
-       *buf = tmp;
-       return ret;
+       while (*size) {
+               if (!isspace(**buf))
+                       break;
+               (*size)--;
+               (*buf)++;
+       }
 }
 
 static void proc_skip_char(char **buf, size_t *size, const char v)
@@ -461,13 +455,12 @@ static int proc_get_long(char **buf, size_t *size,
                          unsigned long *val, bool *neg,
                          const char *perm_tr, unsigned perm_tr_len, char *tr)
 {
-       int len;
        char *p, tmp[TMPBUFLEN];
+       ssize_t len = *size;
 
-       if (!*size)
+       if (len <= 0)
                return -EINVAL;
 
-       len = *size;
        if (len > TMPBUFLEN - 1)
                len = TMPBUFLEN - 1;
 
@@ -640,7 +633,7 @@ static int __do_proc_dointvec(void *tbl_data, struct ctl_table *table,
                bool neg;
 
                if (write) {
-                       left -= proc_skip_spaces(&p);
+                       proc_skip_spaces(&p, &left);
 
                        if (!left)
                                break;
@@ -667,7 +660,7 @@ static int __do_proc_dointvec(void *tbl_data, struct ctl_table *table,
        if (!write && !first && left && !err)
                proc_put_char(&buffer, &left, '\n');
        if (write && !err && left)
-               left -= proc_skip_spaces(&p);
+               proc_skip_spaces(&p, &left);
        if (write && first)
                return err ? : -EINVAL;
        *lenp -= left;
@@ -709,7 +702,7 @@ static int do_proc_douintvec_w(unsigned int *tbl_data,
        if (left > PAGE_SIZE - 1)
                left = PAGE_SIZE - 1;
 
-       left -= proc_skip_spaces(&p);
+       proc_skip_spaces(&p, &left);
        if (!left) {
                err = -EINVAL;
                goto out_free;
@@ -729,7 +722,7 @@ static int do_proc_douintvec_w(unsigned int *tbl_data,
        }
 
        if (!err && left)
-               left -= proc_skip_spaces(&p);
+               proc_skip_spaces(&p, &left);
 
 out_free:
        if (err)
@@ -1266,7 +1259,7 @@ static int __do_proc_doulongvec_minmax(void *data, struct ctl_table *table,
                if (write) {
                        bool neg;
 
-                       left -= proc_skip_spaces(&p);
+                       proc_skip_spaces(&p, &left);
                        if (!left)
                                break;
 
@@ -1294,7 +1287,7 @@ static int __do_proc_doulongvec_minmax(void *data, struct ctl_table *table,
        if (!write && !first && left && !err)
                proc_put_char(&buffer, &left, '\n');
        if (write && !err)
-               left -= proc_skip_spaces(&p);
+               proc_skip_spaces(&p, &left);
        if (write && first)
                return err ? : -EINVAL;
        *lenp -= left;
@@ -1973,7 +1966,7 @@ static struct ctl_table kern_table[] = {
                .maxlen         = sizeof(int),
                .mode           = 0644,
                .proc_handler   = proc_dointvec_minmax,
-               .extra1         = &neg_one,
+               .extra1         = SYSCTL_NEG_ONE,
                .extra2         = SYSCTL_ONE,
        },
 #endif
@@ -2227,17 +2220,6 @@ static struct ctl_table kern_table[] = {
                .proc_handler   = proc_dointvec,
        },
 #endif
-#ifdef CONFIG_SMP
-       {
-               .procname       = "oops_all_cpu_backtrace",
-               .data           = &sysctl_oops_all_cpu_backtrace,
-               .maxlen         = sizeof(int),
-               .mode           = 0644,
-               .proc_handler   = proc_dointvec_minmax,
-               .extra1         = SYSCTL_ZERO,
-               .extra2         = SYSCTL_ONE,
-       },
-#endif /* CONFIG_SMP */
        {
                .procname       = "pid_max",
                .data           = &pid_max,
@@ -2315,7 +2297,7 @@ static struct ctl_table kern_table[] = {
                .mode           = 0644,
                .proc_handler   = proc_dointvec_minmax_sysadmin,
                .extra1         = SYSCTL_ZERO,
-               .extra2         = &two,
+               .extra2         = SYSCTL_TWO,
        },
 #endif
        {
@@ -2575,7 +2557,7 @@ static struct ctl_table kern_table[] = {
                .maxlen         = sizeof(int),
                .mode           = 0644,
                .proc_handler   = proc_dointvec_minmax,
-               .extra1         = &neg_one,
+               .extra1         = SYSCTL_NEG_ONE,
        },
 #endif
 #ifdef CONFIG_RT_MUTEXES
@@ -2637,7 +2619,7 @@ static struct ctl_table kern_table[] = {
                .mode           = 0644,
                .proc_handler   = perf_cpu_time_max_percent_handler,
                .extra1         = SYSCTL_ZERO,
-               .extra2         = &one_hundred,
+               .extra2         = SYSCTL_ONE_HUNDRED,
        },
        {
                .procname       = "perf_event_max_stack",
@@ -2655,7 +2637,7 @@ static struct ctl_table kern_table[] = {
                .mode           = 0644,
                .proc_handler   = perf_event_max_stack_handler,
                .extra1         = SYSCTL_ZERO,
-               .extra2         = &one_thousand,
+               .extra2         = SYSCTL_ONE_THOUSAND,
        },
 #endif
        {
@@ -2686,7 +2668,7 @@ static struct ctl_table kern_table[] = {
                .mode           = 0644,
                .proc_handler   = bpf_unpriv_handler,
                .extra1         = SYSCTL_ZERO,
-               .extra2         = &two,
+               .extra2         = SYSCTL_TWO,
        },
        {
                .procname       = "bpf_stats_enabled",
@@ -2740,7 +2722,7 @@ static struct ctl_table vm_table[] = {
                .mode           = 0644,
                .proc_handler   = overcommit_policy_handler,
                .extra1         = SYSCTL_ZERO,
-               .extra2         = &two,
+               .extra2         = SYSCTL_TWO,
        },
        {
                .procname       = "panic_on_oom",
@@ -2749,7 +2731,7 @@ static struct ctl_table vm_table[] = {
                .mode           = 0644,
                .proc_handler   = proc_dointvec_minmax,
                .extra1         = SYSCTL_ZERO,
-               .extra2         = &two,
+               .extra2         = SYSCTL_TWO,
        },
        {
                .procname       = "oom_kill_allocating_task",
@@ -2794,7 +2776,7 @@ static struct ctl_table vm_table[] = {
                .mode           = 0644,
                .proc_handler   = dirty_background_ratio_handler,
                .extra1         = SYSCTL_ZERO,
-               .extra2         = &one_hundred,
+               .extra2         = SYSCTL_ONE_HUNDRED,
        },
        {
                .procname       = "dirty_background_bytes",
@@ -2811,7 +2793,7 @@ static struct ctl_table vm_table[] = {
                .mode           = 0644,
                .proc_handler   = dirty_ratio_handler,
                .extra1         = SYSCTL_ZERO,
-               .extra2         = &one_hundred,
+               .extra2         = SYSCTL_ONE_HUNDRED,
        },
        {
                .procname       = "dirty_bytes",
@@ -2851,7 +2833,7 @@ static struct ctl_table vm_table[] = {
                .mode           = 0644,
                .proc_handler   = proc_dointvec_minmax,
                .extra1         = SYSCTL_ZERO,
-               .extra2         = &two_hundred,
+               .extra2         = SYSCTL_TWO_HUNDRED,
        },
 #ifdef CONFIG_NUMA
        {
@@ -2910,7 +2892,7 @@ static struct ctl_table vm_table[] = {
                .mode           = 0200,
                .proc_handler   = drop_caches_sysctl_handler,
                .extra1         = SYSCTL_ONE,
-               .extra2         = &four,
+               .extra2         = SYSCTL_FOUR,
        },
 #ifdef CONFIG_COMPACTION
        {
@@ -2927,7 +2909,7 @@ static struct ctl_table vm_table[] = {
                .mode           = 0644,
                .proc_handler   = compaction_proactiveness_sysctl_handler,
                .extra1         = SYSCTL_ZERO,
-               .extra2         = &one_hundred,
+               .extra2         = SYSCTL_ONE_HUNDRED,
        },
        {
                .procname       = "extfrag_threshold",
@@ -2972,7 +2954,7 @@ static struct ctl_table vm_table[] = {
                .mode           = 0644,
                .proc_handler   = watermark_scale_factor_sysctl_handler,
                .extra1         = SYSCTL_ONE,
-               .extra2         = &three_thousand,
+               .extra2         = SYSCTL_THREE_THOUSAND,
        },
        {
                .procname       = "percpu_pagelist_high_fraction",
@@ -3051,7 +3033,7 @@ static struct ctl_table vm_table[] = {
                .mode           = 0644,
                .proc_handler   = sysctl_min_unmapped_ratio_sysctl_handler,
                .extra1         = SYSCTL_ZERO,
-               .extra2         = &one_hundred,
+               .extra2         = SYSCTL_ONE_HUNDRED,
        },
        {
                .procname       = "min_slab_ratio",
@@ -3060,7 +3042,7 @@ static struct ctl_table vm_table[] = {
                .mode           = 0644,
                .proc_handler   = sysctl_min_slab_ratio_sysctl_handler,
                .extra1         = SYSCTL_ZERO,
-               .extra2         = &one_hundred,
+               .extra2         = SYSCTL_ONE_HUNDRED,
        },
 #endif
 #ifdef CONFIG_SMP
@@ -3350,7 +3332,7 @@ static struct ctl_table fs_table[] = {
                .mode           = 0600,
                .proc_handler   = proc_dointvec_minmax,
                .extra1         = SYSCTL_ZERO,
-               .extra2         = &two,
+               .extra2         = SYSCTL_TWO,
        },
        {
                .procname       = "protected_regular",
@@ -3359,7 +3341,7 @@ static struct ctl_table fs_table[] = {
                .mode           = 0600,
                .proc_handler   = proc_dointvec_minmax,
                .extra1         = SYSCTL_ZERO,
-               .extra2         = &two,
+               .extra2         = SYSCTL_TWO,
        },
        {
                .procname       = "suid_dumpable",
@@ -3368,7 +3350,7 @@ static struct ctl_table fs_table[] = {
                .mode           = 0644,
                .proc_handler   = proc_dointvec_minmax_coredump,
                .extra1         = SYSCTL_ZERO,
-               .extra2         = &two,
+               .extra2         = SYSCTL_TWO,
        },
 #if defined(CONFIG_BINFMT_MISC) || defined(CONFIG_BINFMT_MISC_MODULE)
        {