From: Dmitry Torokhov <dmitry.torokhov@gmail.com>
To: linux-input@vger.kernel.org
Cc: Linus Walleij <linus.walleij@linaro.org>, linux-kernel@vger.kernel.org
Subject: [PATCH 5/7] Input: cy8ctmg110_ts - use endian helpers when converting data on wire
Date: Wed, 2 Jun 2021 21:37:24 -0700 [thread overview]
Message-ID: <20210603043726.3793876-5-dmitry.torokhov@gmail.com> (raw)
In-Reply-To: <20210603043726.3793876-1-dmitry.torokhov@gmail.com>
Switch to using be16_to_cpup() instead of shifting and combining data by
hand.
Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
---
drivers/input/touchscreen/cy8ctmg110_ts.c | 11 +++++------
1 file changed, 5 insertions(+), 6 deletions(-)
diff --git a/drivers/input/touchscreen/cy8ctmg110_ts.c b/drivers/input/touchscreen/cy8ctmg110_ts.c
index f8d7ab3b6c25..33c1360a251c 100644
--- a/drivers/input/touchscreen/cy8ctmg110_ts.c
+++ b/drivers/input/touchscreen/cy8ctmg110_ts.c
@@ -16,6 +16,7 @@
#include <linux/i2c.h>
#include <linux/gpio.h>
#include <linux/input/cy8ctmg110_pdata.h>
+#include <asm/byteorder.h>
#define CY8CTMG110_DRIVER_NAME "cy8ctmg110"
@@ -111,7 +112,6 @@ static int cy8ctmg110_touch_pos(struct cy8ctmg110 *tsc)
{
struct input_dev *input = tsc->input;
unsigned char reg_p[CY8CTMG110_REG_MAX];
- int x, y;
memset(reg_p, 0, CY8CTMG110_REG_MAX);
@@ -119,16 +119,15 @@ static int cy8ctmg110_touch_pos(struct cy8ctmg110 *tsc)
if (cy8ctmg110_read_regs(tsc, reg_p, 9, CY8CTMG110_TOUCH_X1) != 0)
return -EIO;
- y = reg_p[2] << 8 | reg_p[3];
- x = reg_p[0] << 8 | reg_p[1];
-
/* Number of touch */
if (reg_p[8] == 0) {
input_report_key(input, BTN_TOUCH, 0);
} else {
input_report_key(input, BTN_TOUCH, 1);
- input_report_abs(input, ABS_X, x);
- input_report_abs(input, ABS_Y, y);
+ input_report_abs(input, ABS_X,
+ be16_to_cpup((__be16 *)(reg_p + 0)));
+ input_report_abs(input, ABS_Y,
+ be16_to_cpup((__be16 *)(reg_p + 2)));
}
input_sync(input);
--
2.32.0.rc0.204.g9fa02ecfa5-goog
next prev parent reply other threads:[~2021-06-03 4:37 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-06-03 4:37 [PATCH 1/7] Input: cy8ctmg110_ts - rely on platform code to supply interrupt Dmitry Torokhov
2021-06-03 4:37 ` [PATCH 2/7] Input: cy8ctmg110_ts - do not hard code interrupt trigger Dmitry Torokhov
2021-06-04 7:31 ` Linus Walleij
2021-06-03 4:37 ` [PATCH 3/7] Input: cy8ctmg110_ts - do not hardcode as wakeup source Dmitry Torokhov
2021-06-04 7:31 ` Linus Walleij
2021-06-03 4:37 ` [PATCH 4/7] Input: cy8ctmg110_ts - let I2C core configure wake interrupt Dmitry Torokhov
2021-06-04 7:32 ` Linus Walleij
2021-06-06 4:10 ` Dmitry Torokhov
2021-06-03 4:37 ` Dmitry Torokhov [this message]
2021-06-04 7:34 ` [PATCH 5/7] Input: cy8ctmg110_ts - use endian helpers when converting data on wire Linus Walleij
2021-06-03 4:37 ` [PATCH 6/7] Input: cy8ctmg110_ts - switch to using managed resources Dmitry Torokhov
2021-06-04 7:35 ` Linus Walleij
2021-06-03 4:37 ` [PATCH 7/7] Input: cy8ctmg110_ts - switch to using gpiod API Dmitry Torokhov
2021-06-04 7:38 ` Linus Walleij
2021-06-06 4:08 ` Dmitry Torokhov
2021-06-04 7:30 ` [PATCH 1/7] Input: cy8ctmg110_ts - rely on platform code to supply interrupt Linus Walleij
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=20210603043726.3793876-5-dmitry.torokhov@gmail.com \
--to=dmitry.torokhov@gmail.com \
--cc=linus.walleij@linaro.org \
--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).