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>

+41 -45
+38 -45
drivers/input/input.c
··· 933 } 934 EXPORT_SYMBOL(input_set_keycode); 935 936 static const struct input_device_id *input_match_device(struct input_handler *handler, 937 struct input_dev *dev) 938 { 939 const struct input_device_id *id; 940 941 for (id = handler->id_table; id->flags || id->driver_info; id++) { 942 - 943 - if (id->flags & INPUT_DEVICE_ID_MATCH_BUS) 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; 988 } 989 990 return NULL;
··· 933 } 934 EXPORT_SYMBOL(input_set_keycode); 935 936 + bool 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 + } 969 + EXPORT_SYMBOL(input_match_device_id); 970 + 971 static const struct input_device_id *input_match_device(struct input_handler *handler, 972 struct input_dev *dev) 973 { 974 const struct input_device_id *id; 975 976 for (id = handler->id_table; id->flags || id->driver_info; id++) { 977 + if (input_match_device_id(dev, id) && 978 + (!handler->match || handler->match(handler, dev))) { 979 return id; 980 + } 981 } 982 983 return NULL;
+3
include/linux/input.h
··· 469 int input_set_keycode(struct input_dev *dev, 470 const struct input_keymap_entry *ke); 471 472 void input_enable_softrepeat(struct input_dev *dev, int delay, int period); 473 474 extern struct class input_class;
··· 469 int input_set_keycode(struct input_dev *dev, 470 const struct input_keymap_entry *ke); 471 472 + bool input_match_device_id(const struct input_dev *dev, 473 + const struct input_device_id *id); 474 + 475 void input_enable_softrepeat(struct input_dev *dev, int delay, int period); 476 477 extern struct class input_class;