From: Dmitry Torokhov <dmitry.torokhov@gmail.com>
To: Joe Perches <joe@perches.com>
Cc: linux-kernel@vger.kernel.org, linux-input@vger.kernel.org
Subject: Re: [PATCH 03/11] aiptek: Fix probable mask then right shift defects
Date: Mon, 27 Oct 2014 07:44:11 -0700 [thread overview]
Message-ID: <20141027144411.GA7594@dtor-ws> (raw)
In-Reply-To: <8c6687a4d568c853ab649ba03d2477ee24bc6ff6.1414387334.git.joe@perches.com>
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
next prev parent reply other threads:[~2014-10-27 14:44 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-10-27 5:24 [PATCH 00/11] treewide: mask then shift defects and style updates Joe Perches
2014-10-27 5:24 ` [PATCH 03/11] aiptek: Fix probable mask then right shift defects Joe Perches
2014-10-27 14:44 ` Dmitry Torokhov [this message]
2014-10-27 17:56 ` Joe Perches
2014-10-27 18:01 ` Dmitry Torokhov
2014-10-27 18:03 ` Joe Perches
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20141027144411.GA7594@dtor-ws \
--to=dmitry.torokhov@gmail.com \
--cc=joe@perches.com \
--cc=linux-input@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).