From: Greg Kroah-Hartman Date: Sun, 13 Jul 2014 01:11:25 +0000 (-0700) Subject: staging: lustre: clean up some proc file declarations X-Git-Url: https://git.karo-electronics.de/?a=commitdiff_plain;h=9b335e2b2f2e92b1134035818c9ae9316bbddca3;p=linux-beck.git staging: lustre: clean up some proc file declarations This removes the DECLARE_PROC_HANDLER macro, and makes proc_call_handler a static function (horrible name to be in a module). This makes the linux-prim.h file empty now, so it can be removed soon. Cc: Andreas Dilger Cc: Oleg Drokin Signed-off-by: Greg Kroah-Hartman --- diff --git a/drivers/staging/lustre/include/linux/libcfs/linux/linux-prim.h b/drivers/staging/lustre/include/linux/libcfs/linux/linux-prim.h index 43ce3a05f59b..8ea857684d65 100644 --- a/drivers/staging/lustre/include/linux/libcfs/linux/linux-prim.h +++ b/drivers/staging/lustre/include/linux/libcfs/linux/linux-prim.h @@ -61,16 +61,4 @@ #include "linux-time.h" -/* - * Sysctl register - */ -#define DECLARE_PROC_HANDLER(name) \ -static int name(struct ctl_table *table, int write, \ - void __user *buffer, size_t *lenp, loff_t *ppos) \ -{ \ - return proc_call_handler(table->data, write, \ - ppos, buffer, lenp, \ - __##name); \ -} - #endif diff --git a/drivers/staging/lustre/include/linux/libcfs/linux/portals_compat25.h b/drivers/staging/lustre/include/linux/libcfs/linux/portals_compat25.h index 4fe072056da2..0728f20b499f 100644 --- a/drivers/staging/lustre/include/linux/libcfs/linux/portals_compat25.h +++ b/drivers/staging/lustre/include/linux/libcfs/linux/portals_compat25.h @@ -84,10 +84,4 @@ #define ll_proc_dolongvec(table, write, filp, buffer, lenp, ppos) \ proc_doulongvec_minmax(table, write, buffer, lenp, ppos); -/* helper for sysctl handlers */ -int proc_call_handler(void *data, int write, - loff_t *ppos, void *buffer, size_t *lenp, - int (*handler)(void *data, int write, - loff_t pos, void *buffer, int len)); - #endif /* _PORTALS_COMPAT_H */ diff --git a/drivers/staging/lustre/lnet/lnet/router_proc.c b/drivers/staging/lustre/lnet/lnet/router_proc.c index 60b2e844a33d..122ebf430d2a 100644 --- a/drivers/staging/lustre/lnet/lnet/router_proc.c +++ b/drivers/staging/lustre/lnet/lnet/router_proc.c @@ -90,6 +90,24 @@ enum { #define LNET_PROC_VERSION(v) ((unsigned int)((v) & LNET_PROC_VER_MASK)) +static int proc_call_handler(void *data, int write, loff_t *ppos, void *buffer, + size_t *lenp, int (*handler)(void *data, int write, + loff_t pos, void *buffer, int len)) +{ + int rc = handler(data, write, *ppos, buffer, *lenp); + + if (rc < 0) + return rc; + + if (write) { + *ppos += *lenp; + } else { + *lenp = rc; + *ppos += rc; + } + return 0; +} + static int __proc_lnet_stats(void *data, int write, loff_t pos, void *buffer, int nob) { @@ -139,7 +157,12 @@ static int __proc_lnet_stats(void *data, int write, return rc; } -DECLARE_PROC_HANDLER(proc_lnet_stats); +static int proc_lnet_stats(struct ctl_table *table, int write, + void __user *buffer, size_t *lenp, loff_t *ppos) +{ + return proc_call_handler(table->data, write, ppos, buffer, lenp, + __proc_lnet_stats); +} int proc_lnet_routes(struct ctl_table *table, int write, void __user *buffer, size_t *lenp, loff_t *ppos) @@ -627,7 +650,12 @@ static int __proc_lnet_buffers(void *data, int write, return rc; } -DECLARE_PROC_HANDLER(proc_lnet_buffers); +static int proc_lnet_buffers(struct ctl_table *table, int write, + void __user *buffer, size_t *lenp, loff_t *ppos) +{ + return proc_call_handler(table->data, write, ppos, buffer, lenp, + __proc_lnet_buffers); +} int proc_lnet_nis(struct ctl_table *table, int write, void __user *buffer, size_t *lenp, loff_t *ppos) @@ -847,7 +875,14 @@ out: LIBCFS_FREE(buf, buf_len); return rc; } -DECLARE_PROC_HANDLER(proc_lnet_portal_rotor); + +static int proc_lnet_portal_rotor(struct ctl_table *table, int write, + void __user *buffer, size_t *lenp, + loff_t *ppos) +{ + return proc_call_handler(table->data, write, ppos, buffer, lenp, + __proc_lnet_portal_rotor); +} static struct ctl_table lnet_table[] = { /* diff --git a/drivers/staging/lustre/lustre/libcfs/linux/linux-proc.c b/drivers/staging/lustre/lustre/libcfs/linux/linux-proc.c index 68e41f780e74..0732ff4ca72f 100644 --- a/drivers/staging/lustre/lustre/libcfs/linux/linux-proc.c +++ b/drivers/staging/lustre/lustre/libcfs/linux/linux-proc.c @@ -98,11 +98,9 @@ enum { PSDEV_LNET_FAIL_VAL, /* userdata for fail loc */ }; -int -proc_call_handler(void *data, int write, - loff_t *ppos, void *buffer, size_t *lenp, - int (*handler)(void *data, int write, - loff_t pos, void *buffer, int len)) +static int proc_call_handler(void *data, int write, loff_t *ppos, void *buffer, + size_t *lenp, int (*handler)(void *data, int write, + loff_t pos, void *buffer, int len)) { int rc = handler(data, write, *ppos, buffer, *lenp); @@ -117,7 +115,6 @@ proc_call_handler(void *data, int write, } return 0; } -EXPORT_SYMBOL(proc_call_handler); static int __proc_dobitmasks(void *data, int write, loff_t pos, void *buffer, int nob) @@ -160,7 +157,12 @@ static int __proc_dobitmasks(void *data, int write, return rc; } -DECLARE_PROC_HANDLER(proc_dobitmasks) +static int proc_dobitmasks(struct ctl_table *table, int write, + void __user *buffer, size_t *lenp, loff_t *ppos) +{ + return proc_call_handler(table->data, write, ppos, buffer, lenp, + __proc_dobitmasks); +} static int min_watchdog_ratelimit = 0; /* disable ratelimiting */ static int max_watchdog_ratelimit = (24*60*60); /* limit to once per day */ @@ -174,7 +176,12 @@ static int __proc_dump_kernel(void *data, int write, return cfs_trace_dump_debug_buffer_usrstr(buffer, nob); } -DECLARE_PROC_HANDLER(proc_dump_kernel) +static int proc_dump_kernel(struct ctl_table *table, int write, + void __user *buffer, size_t *lenp, loff_t *ppos) +{ + return proc_call_handler(table->data, write, ppos, buffer, lenp, + __proc_dump_kernel); +} static int __proc_daemon_file(void *data, int write, loff_t pos, void *buffer, int nob) @@ -192,7 +199,12 @@ static int __proc_daemon_file(void *data, int write, return cfs_trace_daemon_command_usrstr(buffer, nob); } -DECLARE_PROC_HANDLER(proc_daemon_file) +static int proc_daemon_file(struct ctl_table *table, int write, + void __user *buffer, size_t *lenp, loff_t *ppos) +{ + return proc_call_handler(table->data, write, ppos, buffer, lenp, + __proc_daemon_file); +} static int __proc_debug_mb(void *data, int write, loff_t pos, void *buffer, int nob) @@ -212,7 +224,12 @@ static int __proc_debug_mb(void *data, int write, return cfs_trace_set_debug_mb_usrstr(buffer, nob); } -DECLARE_PROC_HANDLER(proc_debug_mb) +static int proc_debug_mb(struct ctl_table *table, int write, + void __user *buffer, size_t *lenp, loff_t *ppos) +{ + return proc_call_handler(table->data, write, ppos, buffer, lenp, + __proc_debug_mb); +} int proc_console_max_delay_cs(struct ctl_table *table, int write, void __user *buffer, size_t *lenp, loff_t *ppos) @@ -366,7 +383,13 @@ static int __proc_cpt_table(void *data, int write, LIBCFS_FREE(buf, len); return rc; } -DECLARE_PROC_HANDLER(proc_cpt_table) + +static int proc_cpt_table(struct ctl_table *table, int write, + void __user *buffer, size_t *lenp, loff_t *ppos) +{ + return proc_call_handler(table->data, write, ppos, buffer, lenp, + __proc_cpt_table); +} static struct ctl_table lnet_table[] = { /*