[PATCH libinput 2/6] touchpad: use __builtin_ffs instead of a manual count

Hans de Goede hdegoede at redhat.com
Mon Jan 5 03:00:24 PST 2015


Hi,

On 16-12-14 04:14, Peter Hutterer wrote:
> 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 at who-t.net>

Looks good:

Reviewed-by: Hans de Goede <hdegoede at redhat.com>

Regards,

Hans

> ---
>   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 42c163b..c80d314 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 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 __builtin_ffs(tp->fake_touches >> 1);
>   }
>
>   static inline bool
>


More information about the wayland-devel mailing list