lkml.org 
[lkml]   [2014]   [Oct]   [27]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
Date
From
SubjectRe: [PATCH 03/11] aiptek: Fix probable mask then right shift defects
Hi Joe,

On Sun, Oct 26, 2014 at 10:24:59PM -0700, Joe Perches wrote:
> Precedence of & and >> is not the same and is not left to right.
> shift has higher precedence and should be done after the mask.

Looking at the protocol description the current code is exactly right.
We want to "move" button bits first as in packet type 1 they are in a
different place than in other packets.

I'll take a patch that adds parenthesis around shifts to make clear it
is intended.

Thanks.

>
> Here the shifts are unnecessary and a non-zero value can be used
> as the test to set 1 or zero.
>
> Signed-off-by: Joe Perches <joe@perches.com>
> ---
> drivers/input/tablet/aiptek.c | 6 +++---
> 1 file changed, 3 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/input/tablet/aiptek.c b/drivers/input/tablet/aiptek.c
> index e7f966d..dee2bb9 100644
> --- a/drivers/input/tablet/aiptek.c
> +++ b/drivers/input/tablet/aiptek.c
> @@ -489,9 +489,9 @@ static void aiptek_irq(struct urb *urb)
> */
> jitterable = data[1] & 0x07;
>
> - left = (data[1] & aiptek->curSetting.mouseButtonLeft >> 2) != 0 ? 1 : 0;
> - right = (data[1] & aiptek->curSetting.mouseButtonRight >> 2) != 0 ? 1 : 0;
> - middle = (data[1] & aiptek->curSetting.mouseButtonMiddle >> 2) != 0 ? 1 : 0;
> + left = data[1] & aiptek->curSetting.mouseButtonLeft ? 1 : 0;
> + right = data[1] & aiptek->curSetting.mouseButtonRight ? 1 : 0;
> + middle = data[1] & aiptek->curSetting.mouseButtonMiddle ? 1 : 0;
>
> input_report_key(inputdev, BTN_LEFT, left);
> input_report_key(inputdev, BTN_MIDDLE, middle);
> --
> 2.1.2
>

--
Dmitry


\
 
 \ /
  Last update: 2014-10-27 16:21    [W:1.939 / U:0.008 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site