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

Input: move input_bits_to_string() to input-compat.c

The input_bits_to_string() function has special handling for compat
tasks, formatting the output as a sequence of 32-bit hex values. To
better isolate compatibility-related code, move it from
drivers/input/input.c to drivers/input/input-compat.c.

No functional change intended.

Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>

+33 -35
+30
drivers/input/input-compat.c
··· 6 6 */ 7 7 8 8 #include <linux/export.h> 9 + #include <linux/sprintf.h> 9 10 #include <linux/uaccess.h> 10 11 #include "input-compat.h" 11 12 ··· 95 94 return 0; 96 95 } 97 96 97 + int input_bits_to_string(char *buf, int buf_size, unsigned long bits, 98 + bool skip_empty) 99 + { 100 + int len = 0; 101 + 102 + if (in_compat_syscall()) { 103 + u32 dword = bits >> 32; 104 + if (dword || !skip_empty) 105 + len += snprintf(buf, buf_size, "%x ", dword); 106 + 107 + dword = bits & 0xffffffffUL; 108 + if (dword || !skip_empty || len) 109 + len += snprintf(buf + len, max(buf_size - len, 0), 110 + "%x", dword); 111 + } else { 112 + if (bits || !skip_empty) 113 + len += snprintf(buf, buf_size, "%lx", bits); 114 + } 115 + 116 + return len; 117 + } 118 + 98 119 #else 99 120 100 121 int input_event_from_user(const char __user *buffer, ··· 147 124 return -EFAULT; 148 125 149 126 return 0; 127 + } 128 + 129 + int input_bits_to_string(char *buf, int buf_size, unsigned long bits, 130 + bool skip_empty) 131 + { 132 + return bits || !skip_empty ? 133 + snprintf(buf, buf_size, "%lx", bits) : 0; 150 134 } 151 135 152 136 #endif /* CONFIG_COMPAT */
+3
drivers/input/input-compat.h
··· 75 75 int input_ff_effect_from_user(const char __user *buffer, size_t size, 76 76 struct ff_effect *effect); 77 77 78 + int input_bits_to_string(char *buf, int buf_size, unsigned long bits, 79 + bool skip_empty); 80 + 78 81 #endif /* _INPUT_COMPAT_H */
-35
drivers/input/input.c
··· 998 998 return error; 999 999 } 1000 1000 1001 - #ifdef CONFIG_COMPAT 1002 - 1003 - static int input_bits_to_string(char *buf, int buf_size, 1004 - unsigned long bits, bool skip_empty) 1005 - { 1006 - int len = 0; 1007 - 1008 - if (in_compat_syscall()) { 1009 - u32 dword = bits >> 32; 1010 - if (dword || !skip_empty) 1011 - len += snprintf(buf, buf_size, "%x ", dword); 1012 - 1013 - dword = bits & 0xffffffffUL; 1014 - if (dword || !skip_empty || len) 1015 - len += snprintf(buf + len, max(buf_size - len, 0), 1016 - "%x", dword); 1017 - } else { 1018 - if (bits || !skip_empty) 1019 - len += snprintf(buf, buf_size, "%lx", bits); 1020 - } 1021 - 1022 - return len; 1023 - } 1024 - 1025 - #else /* !CONFIG_COMPAT */ 1026 - 1027 - static int input_bits_to_string(char *buf, int buf_size, 1028 - unsigned long bits, bool skip_empty) 1029 - { 1030 - return bits || !skip_empty ? 1031 - snprintf(buf, buf_size, "%lx", bits) : 0; 1032 - } 1033 - 1034 - #endif 1035 - 1036 1001 #ifdef CONFIG_PROC_FS 1037 1002 1038 1003 static struct proc_dir_entry *proc_bus_input_dir;