linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Andy Shevchenko <andy.shevchenko@gmail.com>
To: David Laight <David.Laight@aculab.com>
Cc: Dmitry Torokhov <dmitry.torokhov@gmail.com>,
	"linux-input@vger.kernel.org" <linux-input@vger.kernel.org>,
	Marco Felsch <m.felsch@pengutronix.de>,
	Benoit Parrot <bparrot@ti.com>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH 1/2] Input: edt-ft5x06 - use get_unaligned_be16()
Date: Tue, 25 Jun 2019 13:50:23 +0300	[thread overview]
Message-ID: <CAHp75VfJQp4TqfyvjGtFcnvN-md++9fQUis6a-dFKn_2OUN=0A@mail.gmail.com> (raw)
In-Reply-To: <011d62995b20493f977ead43f4b494a2@AcuMS.aculab.com>

On Tue, Jun 25, 2019 at 11:44 AM David Laight <David.Laight@aculab.com> wrote:
>
> From: Dmitry Torokhov
> > Sent: 23 June 2019 07:32
> >
> > Instead of doing conversion by hand, let's use the proper accessors.
> >
> > Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
> > ---
> >  drivers/input/touchscreen/edt-ft5x06.c | 5 +++--
> >  1 file changed, 3 insertions(+), 2 deletions(-)
> >
> > diff --git a/drivers/input/touchscreen/edt-ft5x06.c b/drivers/input/touchscreen/edt-ft5x06.c
> > index c639ebce914c..ec770226e119 100644
> > --- a/drivers/input/touchscreen/edt-ft5x06.c
> > +++ b/drivers/input/touchscreen/edt-ft5x06.c
> > @@ -27,6 +27,7 @@
> >  #include <linux/gpio/consumer.h>
> >  #include <linux/input/mt.h>
> >  #include <linux/input/touchscreen.h>
> > +#include <asm/unaligned.h>
> >
> >  #define WORK_REGISTER_THRESHOLD              0x00
> >  #define WORK_REGISTER_REPORT_RATE    0x08
> > @@ -239,8 +240,8 @@ static irqreturn_t edt_ft5x06_ts_isr(int irq, void *dev_id)
> >               if (tsdata->version == EDT_M06 && type == TOUCH_EVENT_DOWN)
> >                       continue;
> >
> > -             x = ((buf[0] << 8) | buf[1]) & 0x0fff;
> > -             y = ((buf[2] << 8) | buf[3]) & 0x0fff;
> > +             x = get_unaligned_be16(buf) & 0x0fff;
> > +             y = get_unaligned_be16(buf + 2) & 0x0fff;
>
> You might as well delete the pointless masking with 0xff.

Hmm... Does it guarantee the most significant nibble to be always 0?
(Note 16-bit value and three f:s in the mask)


-- 
With Best Regards,
Andy Shevchenko

  reply	other threads:[~2019-06-25 10:50 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-06-23  6:31 [PATCH 1/2] Input: edt-ft5x06 - use get_unaligned_be16() Dmitry Torokhov
2019-06-23  6:31 ` [PATCH 2/2] Input: edt-ft5x06 - simplify event reporting code Dmitry Torokhov
2019-06-23  7:59   ` Andy Shevchenko
2019-06-30  7:05     ` Dmitry Torokhov
2019-07-01 10:41       ` Andy Shevchenko
2019-06-28 17:37   ` Benoit Parrot
2019-06-23  8:00 ` [PATCH 1/2] Input: edt-ft5x06 - use get_unaligned_be16() Andy Shevchenko
2019-06-25  8:44 ` David Laight
2019-06-25 10:50   ` Andy Shevchenko [this message]
2019-06-25 13:00     ` David Laight
2019-06-28 17:36 ` Benoit Parrot

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='CAHp75VfJQp4TqfyvjGtFcnvN-md++9fQUis6a-dFKn_2OUN=0A@mail.gmail.com' \
    --to=andy.shevchenko@gmail.com \
    --cc=David.Laight@aculab.com \
    --cc=bparrot@ti.com \
    --cc=dmitry.torokhov@gmail.com \
    --cc=linux-input@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=m.felsch@pengutronix.de \
    /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).