vt: keyboard, use find_next_bit in kbd_match
Instead of a 'for' loop with 'test_bit's to find a bit in a range, use find_next_bit to achieve the same in a simpler and faster manner. Signed-off-by: Jiri Slaby <jslaby@suse.cz> Link: https://lore.kernel.org/r/20201029113222.32640-16-jslaby@suse.cz Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:
parent
6dee84d6be
commit
2389cdc360
@ -1535,18 +1535,16 @@ static void kbd_event(struct input_handle *handle, unsigned int event_type,
|
|||||||
|
|
||||||
static bool kbd_match(struct input_handler *handler, struct input_dev *dev)
|
static bool kbd_match(struct input_handler *handler, struct input_dev *dev)
|
||||||
{
|
{
|
||||||
int i;
|
|
||||||
|
|
||||||
if (test_bit(EV_SND, dev->evbit))
|
if (test_bit(EV_SND, dev->evbit))
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
if (test_bit(EV_KEY, dev->evbit)) {
|
if (test_bit(EV_KEY, dev->evbit)) {
|
||||||
for (i = KEY_RESERVED; i < BTN_MISC; i++)
|
if (find_next_bit(dev->keybit, BTN_MISC, KEY_RESERVED) <
|
||||||
if (test_bit(i, dev->keybit))
|
BTN_MISC)
|
||||||
return true;
|
return true;
|
||||||
for (i = KEY_BRL_DOT1; i <= KEY_BRL_DOT10; i++)
|
if (find_next_bit(dev->keybit, KEY_BRL_DOT10 + 1,
|
||||||
if (test_bit(i, dev->keybit))
|
KEY_BRL_DOT1) <= KEY_BRL_DOT10)
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user