diff options
author | Dmitry Torokhov <dmitry.torokhov@gmail.com> | 2010-02-03 00:08:26 -0500 |
---|---|---|
committer | Dmitry Torokhov <dmitry.torokhov@gmail.com> | 2010-02-04 03:25:19 -0500 |
commit | 0b7024ac4df5821347141c18e680b7166bc1cb20 (patch) | |
tree | 7a61e55e66bdd39351b3ec39ecef367588b47170 /drivers/input/input.c | |
parent | 1e87a43080a259a0e9739377708ece163b08de8d (diff) |
Input: add match() method to input hanlders
Get rid of blacklist in input handler structure and instead allow
handlers to define their own match() method to perform fine-grained
filtering of supported devices.
Signed-off-by: Dmitry Torokhov <dtor@mail.ru>
Diffstat (limited to 'drivers/input/input.c')
-rw-r--r-- | drivers/input/input.c | 13 |
1 files changed, 6 insertions, 7 deletions
diff --git a/drivers/input/input.c b/drivers/input/input.c index 7080a9d4b840..dae49eba6ccd 100644 --- a/drivers/input/input.c +++ b/drivers/input/input.c | |||
@@ -723,12 +723,13 @@ EXPORT_SYMBOL(input_set_keycode); | |||
723 | if (i != BITS_TO_LONGS(max)) \ | 723 | if (i != BITS_TO_LONGS(max)) \ |
724 | continue; | 724 | continue; |
725 | 725 | ||
726 | static const struct input_device_id *input_match_device(const struct input_device_id *id, | 726 | static const struct input_device_id *input_match_device(struct input_handler *handler, |
727 | struct input_dev *dev) | 727 | struct input_dev *dev) |
728 | { | 728 | { |
729 | const struct input_device_id *id; | ||
729 | int i; | 730 | int i; |
730 | 731 | ||
731 | for (; id->flags || id->driver_info; id++) { | 732 | for (id = handler->id_table; id->flags || id->driver_info; id++) { |
732 | 733 | ||
733 | if (id->flags & INPUT_DEVICE_ID_MATCH_BUS) | 734 | if (id->flags & INPUT_DEVICE_ID_MATCH_BUS) |
734 | if (id->bustype != dev->id.bustype) | 735 | if (id->bustype != dev->id.bustype) |
@@ -756,7 +757,8 @@ static const struct input_device_id *input_match_device(const struct input_devic | |||
756 | MATCH_BIT(ffbit, FF_MAX); | 757 | MATCH_BIT(ffbit, FF_MAX); |
757 | MATCH_BIT(swbit, SW_MAX); | 758 | MATCH_BIT(swbit, SW_MAX); |
758 | 759 | ||
759 | return id; | 760 | if (!handler->match || handler->match(handler, dev)) |
761 | return id; | ||
760 | } | 762 | } |
761 | 763 | ||
762 | return NULL; | 764 | return NULL; |
@@ -767,10 +769,7 @@ static int input_attach_handler(struct input_dev *dev, struct input_handler *han | |||
767 | const struct input_device_id *id; | 769 | const struct input_device_id *id; |
768 | int error; | 770 | int error; |
769 | 771 | ||
770 | if (handler->blacklist && input_match_device(handler->blacklist, dev)) | 772 | id = input_match_device(handler, dev); |
771 | return -ENODEV; | ||
772 | |||
773 | id = input_match_device(handler->id_table, dev); | ||
774 | if (!id) | 773 | if (!id) |
775 | return -ENODEV; | 774 | return -ENODEV; |
776 | 775 | ||