summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPeter Hutterer <peter.hutterer@who-t.net>2014-12-12 12:14:13 +1000
committerPeter Hutterer <peter.hutterer@who-t.net>2015-01-16 07:39:59 +1000
commitdc3d9315fe5ed725d87a909c2eb2da13760c7840 (patch)
treebeb6d4945d894083cd40678c54a7547abec8690d
parent99cb9087224a8e7b0b988b13d391a54524eec61c (diff)
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 <peter.hutterer@who-t.net> Reviewed-by: Hans de Goede <hdegoede@redhat.com>
-rw-r--r--src/evdev-mt-touchpad.c11
1 files changed, 1 insertions, 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