summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRalf Baechle <ralf@linux-mips.org>2017-10-03 10:43:19 +0200
committerRalf Baechle <ralf@linux-mips.org>2017-10-03 10:43:19 +0200
commitc314030d742803b5cd483eaacfb783502a2590fc (patch)
treec1da5911595742ecd00d04f9791beb23feacfc1e
parent5af2b138f92317cc2cb9fefd7a7d35e87d8a7d08 (diff)
Noch nicht committetes Zeugs.ax25-sysctl-overhaul
Signed-off-by: Ralf Baechle <ralf@linux-mips.org>
-rw-r--r--net/ax25/sysctl_net_ax25.c50
1 files changed, 44 insertions, 6 deletions
diff --git a/net/ax25/sysctl_net_ax25.c b/net/ax25/sysctl_net_ax25.c
index 60e292ebb593..670d4e57e7cb 100644
--- a/net/ax25/sysctl_net_ax25.c
+++ b/net/ax25/sysctl_net_ax25.c
@@ -12,16 +12,54 @@
#include <linux/spinlock.h>
#include <net/ax25.h>
+struct do_proc_dointvec_minmax_conv_param {
+ int *min;
+ int *max;
+};
+
+struct min_max {
+ int min[1];
+ int max[1];
+};
+
+static int ax25_conf_proc(struct ctl_table *ctl, int write,
+ void __user *buffer,
+ size_t *lenp, loff_t *ppos)
+{
+ struct min_max *mm = (void *) ctl->extra1;
+ int new_value, ret;
+ long i;
+ ax25_dev *ax25_dev;
+
+ struct ctl_table table = {
+ .data = ctl->data,
+ .maxlen = ctl->maxlen,
+ .extra1 = mm->min,
+ .extra2 = mm->max,
+ };
+ ret = proc_dointvec_minmax(&table, write, buffer, lenp, ppos);
+ if (ret < 0)
+ return ret;
+
+ if (!write)
+ return ret;
+
+ new_value = *(int *)ctl->data;
+ i = (long) ctl->extra2;
+
+ spin_lock_bh(&ax25_dev_lock);
+ for (ax25_dev = ax25_dev_list; ax25_dev; ax25_dev = ax25_dev->next)
+ ax25_dev->sv.values[i] = new_value;
+ spin_unlock_bh(&ax25_dev_lock);
+}
+
#define INIT_CTL_MIN_MAX_TABLE_ENTRY(index, name, _min, _max) \
[AX25_VALUES_ ## index] = { \
.min = {_min}, \
.max = {_max}, \
}
-static struct min_max {
- int min[1];
- int max[1];
-} min_max[] = {
+static struct min_max min_max[] = {
INIT_CTL_MIN_MAX_TABLE_ENTRY(IPDEFMODE, ipdefmode, 0, 1),
INIT_CTL_MIN_MAX_TABLE_ENTRY(AXDEFMODE, axdefmode, 0, 1),
INIT_CTL_MIN_MAX_TABLE_ENTRY(BACKOFF, backoff, 0, 2),
@@ -46,8 +84,8 @@ INIT_CTL_MIN_MAX_TABLE_ENTRY(DS_TIMEOUT, ds_timeout, 0, 65535000),
.maxlen = sizeof(int), \
.mode = 0644, \
.proc_handler = proc_dointvec_minmax, \
- .extra1 = &min_max[AX25_VALUES_ ## index].min, \
- .extra2 = &min_max[AX25_VALUES_ ## index].max, \
+ .extra1 = min_max + AX25_VALUES_ ## index, \
+ .extra2 = NULL, \
}
static const struct ctl_table ax25_param_table[] = {