From: Dan Carpenter <dan.carpenter@oracle.com>
To: mirq-linux@rere.qmqm.pl
Cc: linux-input@vger.kernel.org
Subject: [bug report] Input: elants_i2c - add support for eKTF3624
Date: Thu, 28 Jan 2021 12:57:12 +0300 [thread overview]
Message-ID: <YBKKePZ1VyZIbBCo@mwanda> (raw)
Hello Michał Mirosław,
The patch 9517b95bdc46: "Input: elants_i2c - add support for
eKTF3624" from Jan 24, 2021, leads to the following static checker
warning:
drivers/input/touchscreen/elants_i2c.c:966 elants_i2c_mt_event()
warn: should this be a bitwise negate mask?
drivers/input/touchscreen/elants_i2c.c
942 /* Note: all fingers have the same tool type */
943 tool_type = buf[FW_POS_TOOL_TYPE] & BIT(0) ?
944 MT_TOOL_FINGER : MT_TOOL_PALM;
945
946 for (i = 0; i < MAX_CONTACT_NUM && n_fingers; i++) {
947 if (finger_state & 1) {
948 unsigned int x, y, p, w;
949 u8 *pos;
950
951 pos = &buf[FW_POS_XY + i * 3];
952 x = (((u16)pos[0] & 0xf0) << 4) | pos[1];
953 y = (((u16)pos[0] & 0x0f) << 8) | pos[2];
954
955 /*
956 * eKTF3624 may have use "old" touch-report format,
957 * depending on a device and TS firmware version.
958 * For example, ASUS Transformer devices use the "old"
959 * format, while ASUS Nexus 7 uses the "new" formant.
960 */
961 if (packet_size == PACKET_SIZE_OLD &&
962 ts->chip_id == EKTF3624) {
963 w = buf[FW_POS_WIDTH + i / 2];
964 w >>= 4 * (~i & 1);
965 w |= w << 4;
966 w |= !w;
^^^^^^^^
This code is just very puzzling. I think it may actually be correct?
The boring and conventional way to write this would be to do it like so:
if (!w)
w = 1;
967 p = w;
968 } else {
969 p = buf[FW_POS_PRESSURE + i];
970 w = buf[FW_POS_WIDTH + i];
971 }
972
973 dev_dbg(&ts->client->dev, "i=%d x=%d y=%d p=%d w=%d\n",
974 i, x, y, p, w);
975
976 input_mt_slot(input, i);
977 input_mt_report_slot_state(input, tool_type, true);
978 touchscreen_report_pos(input, &ts->prop, x, y, true);
regards,
dan carpenter
next reply other threads:[~2021-01-28 9:58 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-01-28 9:57 Dan Carpenter [this message]
2021-01-28 13:07 ` [bug report] Input: elants_i2c - add support for eKTF3624 Michał Mirosław
2021-01-28 14:37 ` Dan Carpenter
2021-01-28 23:21 ` Michał Mirosław
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=YBKKePZ1VyZIbBCo@mwanda \
--to=dan.carpenter@oracle.com \
--cc=linux-input@vger.kernel.org \
--cc=mirq-linux@rere.qmqm.pl \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.