diff options
author | Dmitry Torokhov <dmitry.torokhov@gmail.com> | 2012-08-01 01:08:55 -0400 |
---|---|---|
committer | Dmitry Torokhov <dmitry.torokhov@gmail.com> | 2012-08-22 01:29:52 -0400 |
commit | c0bb1f975ca06b17d595937c5e91578b36047039 (patch) | |
tree | f21fdf30c33fcd5a9d0f87cc5115af9f4f471382 /drivers/input | |
parent | 80c99bcd28617bd534b6f9489857235ee613c797 (diff) |
Input: get rid of MATCH_BIT() macro
MATCH_BIT() is ugly and stupid, we have much nicer bitmap_subset() which
does the same and does not hide control flow.
Reported-by: Baodong Chen <chenbdchenbd@gmail.com>
Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
Diffstat (limited to 'drivers/input')
-rw-r--r-- | drivers/input/input.c | 43 |
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 | } |
845 | EXPORT_SYMBOL(input_set_keycode); | 845 | EXPORT_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 | |||
854 | static const struct input_device_id *input_match_device(struct input_handler *handler, | 847 | static 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; |