aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/input/input.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/input/input.c')
-rw-r--r--drivers/input/input.c43
1 files changed, 26 insertions, 17 deletions
diff --git a/drivers/input/input.c b/drivers/input/input.c
index 8921c6180c51..768e46b05ef0 100644
--- a/drivers/input/input.c
+++ b/drivers/input/input.c
@@ -844,18 +844,10 @@ int input_set_keycode(struct input_dev *dev,
844} 844}
845EXPORT_SYMBOL(input_set_keycode); 845EXPORT_SYMBOL(input_set_keycode);
846 846
847#define MATCH_BIT(bit, max) \
848 for (i = 0; i < BITS_TO_LONGS(max); i++) \
849 if ((id->bit[i] & dev->bit[i]) != id->bit[i]) \
850 break; \
851 if (i != BITS_TO_LONGS(max)) \
852 continue;
853
854static const struct input_device_id *input_match_device(struct input_handler *handler, 847static const struct input_device_id *input_match_device(struct input_handler *handler,
855 struct input_dev *dev) 848 struct input_dev *dev)
856{ 849{
857 const struct input_device_id *id; 850 const struct input_device_id *id;
858 int i;
859 851
860 for (id = handler->id_table; id->flags || id->driver_info; id++) { 852 for (id = handler->id_table; id->flags || id->driver_info; id++) {
861 853
@@ -875,15 +867,32 @@ static const struct input_device_id *input_match_device(struct input_handler *ha
875 if (id->version != dev->id.version) 867 if (id->version != dev->id.version)
876 continue; 868 continue;
877 869
878 MATCH_BIT(evbit, EV_MAX); 870 if (!bitmap_subset(id->evbit, dev->evbit, EV_MAX))
879 MATCH_BIT(keybit, KEY_MAX); 871 continue;
880 MATCH_BIT(relbit, REL_MAX); 872
881 MATCH_BIT(absbit, ABS_MAX); 873 if (!bitmap_subset(id->keybit, dev->keybit, KEY_MAX))
882 MATCH_BIT(mscbit, MSC_MAX); 874 continue;
883 MATCH_BIT(ledbit, LED_MAX); 875
884 MATCH_BIT(sndbit, SND_MAX); 876 if (!bitmap_subset(id->relbit, dev->relbit, REL_MAX))
885 MATCH_BIT(ffbit, FF_MAX); 877 continue;
886 MATCH_BIT(swbit, SW_MAX); 878
879 if (!bitmap_subset(id->absbit, dev->absbit, ABS_MAX))
880 continue;
881
882 if (!bitmap_subset(id->mscbit, dev->mscbit, MSC_MAX))
883 continue;
884
885 if (!bitmap_subset(id->ledbit, dev->ledbit, LED_MAX))
886 continue;
887
888 if (!bitmap_subset(id->sndbit, dev->sndbit, SND_MAX))
889 continue;
890
891 if (!bitmap_subset(id->ffbit, dev->ffbit, FF_MAX))
892 continue;
893
894 if (!bitmap_subset(id->swbit, dev->swbit, SW_MAX))
895 continue;
887 896
888 if (!handler->match || handler->match(handler, dev)) 897 if (!handler->match || handler->match(handler, dev))
889 return id; 898 return id;