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.
Unified · Split
| @@ -933,58 +933,51 @@ int input_set_keycode(struct input_dev *dev, · 932 unmodified lines | ||
| 933 | 933 | } |
| 934 | 934 | EXPORT_SYMBOL(input_set_keycode); |
| 935 | 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 | + | |
| 936 | 971 | static const struct input_device_id *input_match_device(struct input_handler *handler, |
| 937 | 972 | struct input_dev *dev) |
| 938 | 973 | { |
| 939 | 974 | const struct input_device_id *id; |
| 940 | 975 | |
| 941 | 976 | 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)) | |
| 977 | + if (input_match_device_id(dev, id) && | |
| 978 | + (!handler->match || handler->match(handler, dev))) { | |
| 987 | 979 | return id; |
| 980 | + } | |
| 988 | 981 | } |
| 989 | 982 | |
| 990 | 983 | return NULL; |
| @@ -469,6 +469,9 @@ int input_get_keycode(struct input_dev *dev, struct input_keymap_entry *ke); · 468 unmodified lines | ||
| 469 | 469 | int input_set_keycode(struct input_dev *dev, |
| 470 | 470 | const struct input_keymap_entry *ke); |
| 471 | 471 | |
| 472 | +bool input_match_device_id(const struct input_dev *dev, | |
| 473 | + const struct input_device_id *id); | |
| 474 | + | |
| 472 | 475 | void input_enable_softrepeat(struct input_dev *dev, int delay, int period); |
| 473 | 476 | |
| 474 | 477 | extern struct class input_class; |