Commit 71e33a1d authored by Vasily Gorbik's avatar Vasily Gorbik Committed by Martin Schwidefsky

s390/cmm: split and simplify cmm pages proc handler

Split cmm_pages_handler into cmm_pages_handler and
cmm_timed_pages_handler, each handling separate proc entry.  And reuse
proc_doulongvec_minmax to simplify proc handlers. Min/max values are
optional and are omitted here.
Reviewed-by: default avatarHeiko Carstens <heiko.carstens@de.ibm.com>
Signed-off-by: default avatarVasily Gorbik <gor@linux.ibm.com>
Signed-off-by: default avatarMartin Schwidefsky <schwidefsky@de.ibm.com>
parent 196851be
...@@ -251,45 +251,42 @@ static int cmm_skip_blanks(char *cp, char **endp) ...@@ -251,45 +251,42 @@ static int cmm_skip_blanks(char *cp, char **endp)
return str != cp; return str != cp;
} }
static struct ctl_table cmm_table[];
static int cmm_pages_handler(struct ctl_table *ctl, int write, static int cmm_pages_handler(struct ctl_table *ctl, int write,
void __user *buffer, size_t *lenp, loff_t *ppos) void __user *buffer, size_t *lenp, loff_t *ppos)
{ {
char buf[16], *p; long nr = cmm_get_pages();
unsigned int len; struct ctl_table ctl_entry = {
long nr; .procname = ctl->procname,
.data = &nr,
.maxlen = sizeof(long),
};
int rc;
if (!*lenp || (*ppos && !write)) { rc = proc_doulongvec_minmax(&ctl_entry, write, buffer, lenp, ppos);
*lenp = 0; if (rc < 0 || !write)
return 0; return rc;
}
if (write) { cmm_set_pages(nr);
len = *lenp; return 0;
if (copy_from_user(buf, buffer, }
len > sizeof(buf) ? sizeof(buf) : len))
return -EFAULT; static int cmm_timed_pages_handler(struct ctl_table *ctl, int write,
buf[sizeof(buf) - 1] = '\0'; void __user *buffer, size_t *lenp,
cmm_skip_blanks(buf, &p); loff_t *ppos)
nr = simple_strtoul(p, &p, 0); {
if (ctl == &cmm_table[0]) long nr = cmm_get_timed_pages();
cmm_set_pages(nr); struct ctl_table ctl_entry = {
else .procname = ctl->procname,
cmm_add_timed_pages(nr); .data = &nr,
} else { .maxlen = sizeof(long),
if (ctl == &cmm_table[0]) };
nr = cmm_get_pages(); int rc;
else
nr = cmm_get_timed_pages(); rc = proc_doulongvec_minmax(&ctl_entry, write, buffer, lenp, ppos);
len = sprintf(buf, "%ld\n", nr); if (rc < 0 || !write)
if (len > *lenp) return rc;
len = *lenp;
if (copy_to_user(buffer, buf, len)) cmm_add_timed_pages(nr);
return -EFAULT;
}
*lenp = len;
*ppos += len;
return 0; return 0;
} }
...@@ -338,7 +335,7 @@ static struct ctl_table cmm_table[] = { ...@@ -338,7 +335,7 @@ static struct ctl_table cmm_table[] = {
{ {
.procname = "cmm_timed_pages", .procname = "cmm_timed_pages",
.mode = 0644, .mode = 0644,
.proc_handler = cmm_pages_handler, .proc_handler = cmm_timed_pages_handler,
}, },
{ {
.procname = "cmm_timeout", .procname = "cmm_timeout",
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment