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/char/keyboard.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/char/keyboard.c')
-rw-r--r-- | drivers/char/keyboard.c | 24 |
1 files changed, 16 insertions, 8 deletions
diff --git a/drivers/char/keyboard.c b/drivers/char/keyboard.c index cbf64b985ef4..ada25bb8941e 100644 --- a/drivers/char/keyboard.c +++ b/drivers/char/keyboard.c | |||
@@ -1323,6 +1323,21 @@ static void kbd_event(struct input_handle *handle, unsigned int event_type, | |||
1323 | schedule_console_callback(); | 1323 | schedule_console_callback(); |
1324 | } | 1324 | } |
1325 | 1325 | ||
1326 | static bool kbd_match(struct input_handler *handler, struct input_dev *dev) | ||
1327 | { | ||
1328 | int i; | ||
1329 | |||
1330 | if (test_bit(EV_SND, dev->evbit)) | ||
1331 | return true; | ||
1332 | |||
1333 | if (test_bit(EV_KEY, dev->evbit)) | ||
1334 | for (i = KEY_RESERVED; i < BTN_MISC; i++) | ||
1335 | if (test_bit(i, dev->keybit)) | ||
1336 | return true; | ||
1337 | |||
1338 | return false; | ||
1339 | } | ||
1340 | |||
1326 | /* | 1341 | /* |
1327 | * When a keyboard (or other input device) is found, the kbd_connect | 1342 | * When a keyboard (or other input device) is found, the kbd_connect |
1328 | * function is called. The function then looks at the device, and if it | 1343 | * function is called. The function then looks at the device, and if it |
@@ -1334,14 +1349,6 @@ static int kbd_connect(struct input_handler *handler, struct input_dev *dev, | |||
1334 | { | 1349 | { |
1335 | struct input_handle *handle; | 1350 | struct input_handle *handle; |
1336 | int error; | 1351 | int error; |
1337 | int i; | ||
1338 | |||
1339 | for (i = KEY_RESERVED; i < BTN_MISC; i++) | ||
1340 | if (test_bit(i, dev->keybit)) | ||
1341 | break; | ||
1342 | |||
1343 | if (i == BTN_MISC && !test_bit(EV_SND, dev->evbit)) | ||
1344 | return -ENODEV; | ||
1345 | 1352 | ||
1346 | handle = kzalloc(sizeof(struct input_handle), GFP_KERNEL); | 1353 | handle = kzalloc(sizeof(struct input_handle), GFP_KERNEL); |
1347 | if (!handle) | 1354 | if (!handle) |
@@ -1407,6 +1414,7 @@ MODULE_DEVICE_TABLE(input, kbd_ids); | |||
1407 | 1414 | ||
1408 | static struct input_handler kbd_handler = { | 1415 | static struct input_handler kbd_handler = { |
1409 | .event = kbd_event, | 1416 | .event = kbd_event, |
1417 | .match = kbd_match, | ||
1410 | .connect = kbd_connect, | 1418 | .connect = kbd_connect, |
1411 | .disconnect = kbd_disconnect, | 1419 | .disconnect = kbd_disconnect, |
1412 | .start = kbd_start, | 1420 | .start = kbd_start, |