aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/input/input.c
diff options
context:
space:
mode:
authorDmitry Torokhov <dmitry.torokhov@gmail.com>2017-10-09 14:09:33 -0400
committerDmitry Torokhov <dmitry.torokhov@gmail.com>2017-10-19 19:53:34 -0400
commit55dfce873dca46df00304c44a568d7933bffff89 (patch)
tree1faf3be2f3a5b6390b1e9daa2143753d7e6d8fae /drivers/input/input.c
parent9b5db7aab4d6b66f84f5e147c87eff4fe8b48651 (diff)
Input: factor out and export input_device_id matching code
Factor out and export input_match_device_id() so that modules may use it. It will be needed by joydev to blacklist accelerometers in composite devices. Tested-by: Roderick Colenbrander <roderick.colenbrander@sony.com> Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
Diffstat (limited to 'drivers/input/input.c')
-rw-r--r--drivers/input/input.c83
1 files changed, 38 insertions, 45 deletions
diff --git a/drivers/input/input.c b/drivers/input/input.c
index d268fdc23c64..02e6ea7955fe 100644
--- a/drivers/input/input.c
+++ b/drivers/input/input.c
@@ -933,58 +933,51 @@ int input_set_keycode(struct input_dev *dev,
933} 933}
934EXPORT_SYMBOL(input_set_keycode); 934EXPORT_SYMBOL(input_set_keycode);
935 935
936bool input_match_device_id(const struct input_dev *dev,
937 const struct input_device_id *id)
938{
939 if (id->flags & INPUT_DEVICE_ID_MATCH_BUS)
940 if (id->bustype != dev->id.bustype)
941 return false;
942
943 if (id->flags & INPUT_DEVICE_ID_MATCH_VENDOR)
944 if (id->vendor != dev->id.vendor)
945 return false;
946
947 if (id->flags & INPUT_DEVICE_ID_MATCH_PRODUCT)
948 if (id->product != dev->id.product)
949 return false;
950
951 if (id->flags & INPUT_DEVICE_ID_MATCH_VERSION)
952 if (id->version != dev->id.version)
953 return false;
954
955 if (!bitmap_subset(id->evbit, dev->evbit, EV_MAX) ||
956 !bitmap_subset(id->keybit, dev->keybit, KEY_MAX) ||
957 !bitmap_subset(id->relbit, dev->relbit, REL_MAX) ||
958 !bitmap_subset(id->absbit, dev->absbit, ABS_MAX) ||
959 !bitmap_subset(id->mscbit, dev->mscbit, MSC_MAX) ||
960 !bitmap_subset(id->ledbit, dev->ledbit, LED_MAX) ||
961 !bitmap_subset(id->sndbit, dev->sndbit, SND_MAX) ||
962 !bitmap_subset(id->ffbit, dev->ffbit, FF_MAX) ||
963 !bitmap_subset(id->swbit, dev->swbit, SW_MAX)) {
964 return false;
965 }
966
967 return true;
968}
969EXPORT_SYMBOL(input_match_device_id);
970
936static const struct input_device_id *input_match_device(struct input_handler *handler, 971static const struct input_device_id *input_match_device(struct input_handler *handler,
937 struct input_dev *dev) 972 struct input_dev *dev)
938{ 973{
939 const struct input_device_id *id; 974 const struct input_device_id *id;
940 975
941 for (id = handler->id_table; id->flags || id->driver_info; id++) { 976 for (id = handler->id_table; id->flags || id->driver_info; id++) {
942 977 if (input_match_device_id(dev, id) &&
943 if (id->flags & INPUT_DEVICE_ID_MATCH_BUS) 978 (!handler->match || handler->match(handler, dev))) {
944 if (id->bustype != dev->id.bustype)
945 continue;
946
947 if (id->flags & INPUT_DEVICE_ID_MATCH_VENDOR)
948 if (id->vendor != dev->id.vendor)
949 continue;
950
951 if (id->flags & INPUT_DEVICE_ID_MATCH_PRODUCT)
952 if (id->product != dev->id.product)
953 continue;
954
955 if (id->flags & INPUT_DEVICE_ID_MATCH_VERSION)
956 if (id->version != dev->id.version)
957 continue;
958
959 if (!bitmap_subset(id->evbit, dev->evbit, EV_MAX))
960 continue;
961
962 if (!bitmap_subset(id->keybit, dev->keybit, KEY_MAX))
963 continue;
964
965 if (!bitmap_subset(id->relbit, dev->relbit, REL_MAX))
966 continue;
967
968 if (!bitmap_subset(id->absbit, dev->absbit, ABS_MAX))
969 continue;
970
971 if (!bitmap_subset(id->mscbit, dev->mscbit, MSC_MAX))
972 continue;
973
974 if (!bitmap_subset(id->ledbit, dev->ledbit, LED_MAX))
975 continue;
976
977 if (!bitmap_subset(id->sndbit, dev->sndbit, SND_MAX))
978 continue;
979
980 if (!bitmap_subset(id->ffbit, dev->ffbit, FF_MAX))
981 continue;
982
983 if (!bitmap_subset(id->swbit, dev->swbit, SW_MAX))
984 continue;
985
986 if (!handler->match || handler->match(handler, dev))
987 return id; 979 return id;
980 }
988 } 981 }
989 982
990 return NULL; 983 return NULL;