Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

sysctl: Move proc_doulongvec_ms_jiffies_minmax to kernel/time/jiffies.c

Move proc_doulongvec_ms_jiffies_minmax to kernel/time/jiffies.c. Create
a non static wrapper function proc_doulongvec_minmax_conv that
forwards the custom convmul and convdiv argument values to the internal
do_proc_doulongvec_minmax. Remove unused linux/times.h include from
kernel/sysctl.c.

Signed-off-by: Joel Granados <joel.granados@kernel.org>

+43 -32
+2
include/linux/jiffies.h
··· 620 620 void *buffer, size_t *lenp, loff_t *ppos); 621 621 int proc_dointvec_ms_jiffies(const struct ctl_table *table, int dir, void *buffer, 622 622 size_t *lenp, loff_t *ppos); 623 + int proc_doulongvec_ms_jiffies_minmax(const struct ctl_table *table, int dir, 624 + void *buffer, size_t *lenp, loff_t *ppos); 623 625 624 626 #endif
+3 -2
include/linux/sysctl.h
··· 193 193 int proc_dou8vec_minmax(const struct ctl_table *table, int write, void *buffer, 194 194 size_t *lenp, loff_t *ppos); 195 195 int proc_doulongvec_minmax(const struct ctl_table *, int, void *, size_t *, loff_t *); 196 - int proc_doulongvec_ms_jiffies_minmax(const struct ctl_table *table, int, void *, 197 - size_t *, loff_t *); 196 + int proc_doulongvec_minmax_conv(const struct ctl_table *table, int dir, 197 + void *buffer, size_t *lenp, loff_t *ppos, 198 + unsigned long convmul, unsigned long convdiv); 198 199 int proc_do_large_bitmap(const struct ctl_table *, int, void *, size_t *, loff_t *); 199 200 int proc_do_static_key(const struct ctl_table *table, int write, void *buffer, 200 201 size_t *lenp, loff_t *ppos);
+12 -29
kernel/sysctl.c
··· 13 13 #include <linux/highuid.h> 14 14 #include <linux/writeback.h> 15 15 #include <linux/initrd.h> 16 - #include <linux/times.h> 17 16 #include <linux/limits.h> 18 17 #include <linux/syscalls.h> 19 18 #include <linux/capability.h> ··· 824 825 return err; 825 826 } 826 827 828 + int proc_doulongvec_minmax_conv(const struct ctl_table *table, int dir, 829 + void *buffer, size_t *lenp, loff_t *ppos, 830 + unsigned long convmul, unsigned long convdiv) 831 + { 832 + return do_proc_doulongvec_minmax(table, dir, buffer, lenp, ppos, 833 + convmul, convdiv); 834 + } 835 + 827 836 /** 828 837 * proc_doulongvec_minmax - read a vector of long integers with min/max values 829 838 * @table: the sysctl table ··· 851 844 int proc_doulongvec_minmax(const struct ctl_table *table, int dir, 852 845 void *buffer, size_t *lenp, loff_t *ppos) 853 846 { 854 - return do_proc_doulongvec_minmax(table, dir, buffer, lenp, ppos, 1l, 1l); 855 - } 856 - 857 - /** 858 - * proc_doulongvec_ms_jiffies_minmax - read a vector of millisecond values with min/max values 859 - * @table: the sysctl table 860 - * @dir: %TRUE if this is a write to the sysctl file 861 - * @buffer: the user buffer 862 - * @lenp: the size of the user buffer 863 - * @ppos: file position 864 - * 865 - * Reads/writes up to table->maxlen/sizeof(unsigned long) unsigned long 866 - * values from/to the user buffer, treated as an ASCII string. The values 867 - * are treated as milliseconds, and converted to jiffies when they are stored. 868 - * 869 - * This routine will ensure the values are within the range specified by 870 - * table->extra1 (min) and table->extra2 (max). 871 - * 872 - * Returns 0 on success. 873 - */ 874 - int proc_doulongvec_ms_jiffies_minmax(const struct ctl_table *table, int dir, 875 - void *buffer, size_t *lenp, loff_t *ppos) 876 - { 877 - return do_proc_doulongvec_minmax(table, dir, buffer, 878 - lenp, ppos, HZ, 1000l); 847 + return proc_doulongvec_minmax_conv(table, dir, buffer, lenp, ppos, 1l, 1l); 879 848 } 880 849 881 850 int proc_dointvec_conv(const struct ctl_table *table, int dir, void *buffer, ··· 1059 1076 return -ENOSYS; 1060 1077 } 1061 1078 1062 - int proc_doulongvec_ms_jiffies_minmax(const struct ctl_table *table, int dir, 1063 - void *buffer, size_t *lenp, loff_t *ppos) 1079 + int proc_doulongvec_minmax_conv(const struct ctl_table *table, int dir, 1080 + void *buffer, size_t *lenp, loff_t *ppos, 1081 + unsigned long convmul, unsigned long convdiv) 1064 1082 { 1065 1083 return -ENOSYS; 1066 1084 } ··· 1177 1193 EXPORT_SYMBOL_GPL(proc_douintvec_minmax); 1178 1194 EXPORT_SYMBOL(proc_dostring); 1179 1195 EXPORT_SYMBOL(proc_doulongvec_minmax); 1180 - EXPORT_SYMBOL(proc_doulongvec_ms_jiffies_minmax); 1181 1196 EXPORT_SYMBOL(proc_do_large_bitmap);
+26 -1
kernel/time/jiffies.c
··· 190 190 return proc_dointvec_conv(table, dir, buffer, lenp, ppos, 191 191 do_proc_int_conv_ms_jiffies); 192 192 } 193 + EXPORT_SYMBOL(proc_dointvec_ms_jiffies); 193 194 194 195 int proc_dointvec_ms_jiffies_minmax(const struct ctl_table *table, int dir, 195 196 void *buffer, size_t *lenp, loff_t *ppos) ··· 198 197 return proc_dointvec_conv(table, dir, buffer, lenp, ppos, 199 198 do_proc_int_conv_ms_jiffies_minmax); 200 199 } 201 - EXPORT_SYMBOL(proc_dointvec_ms_jiffies); 200 + 201 + /** 202 + * proc_doulongvec_ms_jiffies_minmax - read a vector of millisecond values with min/max values 203 + * @table: the sysctl table 204 + * @dir: %TRUE if this is a write to the sysctl file 205 + * @buffer: the user buffer 206 + * @lenp: the size of the user buffer 207 + * @ppos: file position 208 + * 209 + * Reads/writes up to table->maxlen/sizeof(unsigned long) unsigned long 210 + * values from/to the user buffer, treated as an ASCII string. The values 211 + * are treated as milliseconds, and converted to jiffies when they are stored. 212 + * 213 + * This routine will ensure the values are within the range specified by 214 + * table->extra1 (min) and table->extra2 (max). 215 + * 216 + * Returns 0 on success. 217 + */ 218 + int proc_doulongvec_ms_jiffies_minmax(const struct ctl_table *table, int dir, 219 + void *buffer, size_t *lenp, loff_t *ppos) 220 + { 221 + return proc_doulongvec_minmax_conv(table, dir, buffer, lenp, ppos, 222 + HZ, 1000l); 223 + } 224 + EXPORT_SYMBOL(proc_doulongvec_ms_jiffies_minmax); 202 225