touchpad: use ffs instead of a manual count
authorPeter Hutterer <peter.hutterer@who-t.net>
Fri, 12 Dec 2014 02:14:13 +0000 (12:14 +1000)
committerPeter Hutterer <peter.hutterer@who-t.net>
Thu, 15 Jan 2015 21:39:59 +0000 (07:39 +1000)
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 <peter.hutterer@who-t.net>
Reviewed-by: Hans de Goede <hdegoede@redhat.com>
src/evdev-mt-touchpad.c

index 406ac39ac73bd813975960204d1bd7842935d3dd..03d8d62ebbc264f16f7fb534e64a7488400fefa3 100644 (file)
@@ -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