From dc3d9315fe5ed725d87a909c2eb2da13760c7840 Mon Sep 17 00:00:00 2001 From: Peter Hutterer Date: Fri, 12 Dec 2014 12:14:13 +1000 Subject: [PATCH] touchpad: use ffs instead of a manual count BTN_TOOL_FINGER, DOUBLETAP, etc. are mutually exclusive in the kernel, so we can use ffs here instead of manually counting. Signed-off-by: Peter Hutterer Reviewed-by: Hans de Goede --- src/evdev-mt-touchpad.c | 11 +---------- 1 file changed, 1 insertion(+), 10 deletions(-) diff --git a/src/evdev-mt-touchpad.c b/src/evdev-mt-touchpad.c index 406ac39a..03d8d62e 100644 --- a/src/evdev-mt-touchpad.c +++ b/src/evdev-mt-touchpad.c @@ -138,17 +138,8 @@ tp_get_touch(struct tp_dispatch *tp, unsigned int slot) static inline unsigned int tp_fake_finger_count(struct tp_dispatch *tp) { - unsigned int fake_touches, nfake_touches; - /* don't count BTN_TOUCH */ - fake_touches = tp->fake_touches >> 1; - nfake_touches = 0; - while (fake_touches) { - nfake_touches++; - fake_touches >>= 1; - } - - return nfake_touches; + return ffs(tp->fake_touches >> 1); } static inline bool