diff options
author | Dmitry Torokhov <dmitry.torokhov@gmail.com> | 2010-01-22 02:55:25 -0500 |
---|---|---|
committer | Dmitry Torokhov <dmitry.torokhov@gmail.com> | 2010-01-22 02:55:25 -0500 |
commit | 7755726fe90a8b253659756e6de68c1a55aa427f (patch) | |
tree | a3523fa77e07854db3b8089e3066a55ea997060c /drivers/input/input.c | |
parent | 3bf127637e22ddf95e67e10a23c339cee3d52429 (diff) | |
parent | 92dcffb916d309aa01778bf8963a6932e4014d07 (diff) |
Merge commit 'v2.6.33-rc5' into next
Diffstat (limited to 'drivers/input/input.c')
-rw-r--r-- | drivers/input/input.c | 86 |
1 files changed, 71 insertions, 15 deletions
diff --git a/drivers/input/input.c b/drivers/input/input.c index a31394c1eca8..6c161e220868 100644 --- a/drivers/input/input.c +++ b/drivers/input/input.c | |||
@@ -24,6 +24,7 @@ | |||
24 | #include <linux/mutex.h> | 24 | #include <linux/mutex.h> |
25 | #include <linux/rcupdate.h> | 25 | #include <linux/rcupdate.h> |
26 | #include <linux/smp_lock.h> | 26 | #include <linux/smp_lock.h> |
27 | #include "input-compat.h" | ||
27 | 28 | ||
28 | MODULE_AUTHOR("Vojtech Pavlik <vojtech@suse.cz>"); | 29 | MODULE_AUTHOR("Vojtech Pavlik <vojtech@suse.cz>"); |
29 | MODULE_DESCRIPTION("Input core"); | 30 | MODULE_DESCRIPTION("Input core"); |
@@ -767,6 +768,40 @@ static int input_attach_handler(struct input_dev *dev, struct input_handler *han | |||
767 | return error; | 768 | return error; |
768 | } | 769 | } |
769 | 770 | ||
771 | #ifdef CONFIG_COMPAT | ||
772 | |||
773 | static int input_bits_to_string(char *buf, int buf_size, | ||
774 | unsigned long bits, bool skip_empty) | ||
775 | { | ||
776 | int len = 0; | ||
777 | |||
778 | if (INPUT_COMPAT_TEST) { | ||
779 | u32 dword = bits >> 32; | ||
780 | if (dword || !skip_empty) | ||
781 | len += snprintf(buf, buf_size, "%x ", dword); | ||
782 | |||
783 | dword = bits & 0xffffffffUL; | ||
784 | if (dword || !skip_empty || len) | ||
785 | len += snprintf(buf + len, max(buf_size - len, 0), | ||
786 | "%x", dword); | ||
787 | } else { | ||
788 | if (bits || !skip_empty) | ||
789 | len += snprintf(buf, buf_size, "%lx", bits); | ||
790 | } | ||
791 | |||
792 | return len; | ||
793 | } | ||
794 | |||
795 | #else /* !CONFIG_COMPAT */ | ||
796 | |||
797 | static int input_bits_to_string(char *buf, int buf_size, | ||
798 | unsigned long bits, bool skip_empty) | ||
799 | { | ||
800 | return bits || !skip_empty ? | ||
801 | snprintf(buf, buf_size, "%lx", bits) : 0; | ||
802 | } | ||
803 | |||
804 | #endif | ||
770 | 805 | ||
771 | #ifdef CONFIG_PROC_FS | 806 | #ifdef CONFIG_PROC_FS |
772 | 807 | ||
@@ -835,14 +870,25 @@ static void input_seq_print_bitmap(struct seq_file *seq, const char *name, | |||
835 | unsigned long *bitmap, int max) | 870 | unsigned long *bitmap, int max) |
836 | { | 871 | { |
837 | int i; | 872 | int i; |
838 | 873 | bool skip_empty = true; | |
839 | for (i = BITS_TO_LONGS(max) - 1; i > 0; i--) | 874 | char buf[18]; |
840 | if (bitmap[i]) | ||
841 | break; | ||
842 | 875 | ||
843 | seq_printf(seq, "B: %s=", name); | 876 | seq_printf(seq, "B: %s=", name); |
844 | for (; i >= 0; i--) | 877 | |
845 | seq_printf(seq, "%lx%s", bitmap[i], i > 0 ? " " : ""); | 878 | for (i = BITS_TO_LONGS(max) - 1; i >= 0; i--) { |
879 | if (input_bits_to_string(buf, sizeof(buf), | ||
880 | bitmap[i], skip_empty)) { | ||
881 | skip_empty = false; | ||
882 | seq_printf(seq, "%s%s", buf, i > 0 ? " " : ""); | ||
883 | } | ||
884 | } | ||
885 | |||
886 | /* | ||
887 | * If no output was produced print a single 0. | ||
888 | */ | ||
889 | if (skip_empty) | ||
890 | seq_puts(seq, "0"); | ||
891 | |||
846 | seq_putc(seq, '\n'); | 892 | seq_putc(seq, '\n'); |
847 | } | 893 | } |
848 | 894 | ||
@@ -1131,14 +1177,23 @@ static int input_print_bitmap(char *buf, int buf_size, unsigned long *bitmap, | |||
1131 | { | 1177 | { |
1132 | int i; | 1178 | int i; |
1133 | int len = 0; | 1179 | int len = 0; |
1180 | bool skip_empty = true; | ||
1181 | |||
1182 | for (i = BITS_TO_LONGS(max) - 1; i >= 0; i--) { | ||
1183 | len += input_bits_to_string(buf + len, max(buf_size - len, 0), | ||
1184 | bitmap[i], skip_empty); | ||
1185 | if (len) { | ||
1186 | skip_empty = false; | ||
1187 | if (i > 0) | ||
1188 | len += snprintf(buf + len, max(buf_size - len, 0), " "); | ||
1189 | } | ||
1190 | } | ||
1134 | 1191 | ||
1135 | for (i = BITS_TO_LONGS(max) - 1; i > 0; i--) | 1192 | /* |
1136 | if (bitmap[i]) | 1193 | * If no output was produced print a single 0. |
1137 | break; | 1194 | */ |
1138 | 1195 | if (len == 0) | |
1139 | for (; i >= 0; i--) | 1196 | len = snprintf(buf, buf_size, "%d", 0); |
1140 | len += snprintf(buf + len, max(buf_size - len, 0), | ||
1141 | "%lx%s", bitmap[i], i > 0 ? " " : ""); | ||
1142 | 1197 | ||
1143 | if (add_cr) | 1198 | if (add_cr) |
1144 | len += snprintf(buf + len, max(buf_size - len, 0), "\n"); | 1199 | len += snprintf(buf + len, max(buf_size - len, 0), "\n"); |
@@ -1153,7 +1208,8 @@ static ssize_t input_dev_show_cap_##bm(struct device *dev, \ | |||
1153 | { \ | 1208 | { \ |
1154 | struct input_dev *input_dev = to_input_dev(dev); \ | 1209 | struct input_dev *input_dev = to_input_dev(dev); \ |
1155 | int len = input_print_bitmap(buf, PAGE_SIZE, \ | 1210 | int len = input_print_bitmap(buf, PAGE_SIZE, \ |
1156 | input_dev->bm##bit, ev##_MAX, 1); \ | 1211 | input_dev->bm##bit, ev##_MAX, \ |
1212 | true); \ | ||
1157 | return min_t(int, len, PAGE_SIZE); \ | 1213 | return min_t(int, len, PAGE_SIZE); \ |
1158 | } \ | 1214 | } \ |
1159 | static DEVICE_ATTR(bm, S_IRUGO, input_dev_show_cap_##bm, NULL) | 1215 | static DEVICE_ATTR(bm, S_IRUGO, input_dev_show_cap_##bm, NULL) |
@@ -1217,7 +1273,7 @@ static int input_add_uevent_bm_var(struct kobj_uevent_env *env, | |||
1217 | 1273 | ||
1218 | len = input_print_bitmap(&env->buf[env->buflen - 1], | 1274 | len = input_print_bitmap(&env->buf[env->buflen - 1], |
1219 | sizeof(env->buf) - env->buflen, | 1275 | sizeof(env->buf) - env->buflen, |
1220 | bitmap, max, 0); | 1276 | bitmap, max, false); |
1221 | if (len >= (sizeof(env->buf) - env->buflen)) | 1277 | if (len >= (sizeof(env->buf) - env->buflen)) |
1222 | return -ENOMEM; | 1278 | return -ENOMEM; |
1223 | 1279 | ||