public inbox for linux-input@vger.kernel.org
 help / color / mirror / Atom feed
From: Thanh Nguyen <thanhnguyxn07@gmail.com>
To: dmitry.torokhov@gmail.com
Cc: linux-input@vger.kernel.org, linux-kernel@vger.kernel.org,
	linus.walleij@linaro.org, timon37@lavabit.com,
	Thanh Nguyen <thanhnguyxn07@gmail.com>
Subject: [PATCH] Input: zinitix: iterate contact slots by finger count
Date: Wed,  8 Apr 2026 00:19:07 -0500	[thread overview]
Message-ID: <20260408051907.792-1-thanhnguyxn07@gmail.com> (raw)

On affected devices (for example Samsung A3 2015), the value in
touch_event.finger_mask appears to behave as a count of reported slots
rather than a bitmask. Using for_each_set_bit() can then skip valid
contacts and break multitouch gestures.

Keep filtering by SUB_BIT_EXIST to avoid reporting shadow contacts, but
iterate from slot 0 up to min(finger_mask, MAX_SUPPORTED_FINGER_NUM).
This follows the maintainer feedback to treat the field as a possible
count while preserving the anti-shadow check.

Fixes: e941dc13fd37 ("Input: zinitix - do not report shadow fingers")
Link: https://bugzilla.kernel.org/show_bug.cgi?id=221278
Signed-off-by: Thanh Nguyen <thanhnguyxn07@gmail.com>
---
v2:
 - Address maintainer feedback: do not revert e941dc13fd37.
 - Keep SUB_BIT_EXIST filtering to avoid shadow contacts.
 - Treat finger_mask as a slot-count bound and iterate 0..min(mask, max).

 drivers/input/touchscreen/zinitix.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/input/touchscreen/zinitix.c b/drivers/input/touchscreen/zinitix.c
index 716d6fa60..a2edae7df 100644
--- a/drivers/input/touchscreen/zinitix.c
+++ b/drivers/input/touchscreen/zinitix.c
@@ -471,7 +471,8 @@ static irqreturn_t zinitix_ts_irq_handler(int irq, void *bt541_handler)
 	}
 
 	finger_mask = touch_event.finger_mask;
-	for_each_set_bit(i, &finger_mask, MAX_SUPPORTED_FINGER_NUM) {
+	for (i = 0; i < min_t(unsigned long, finger_mask,
+			MAX_SUPPORTED_FINGER_NUM); i++) {
 		const struct point_coord *p = &touch_event.point_coord[i];
 
 		/* Only process contacts that are actually reported */
-- 
2.51.0.windows.2


                 reply	other threads:[~2026-04-08  5:19 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=20260408051907.792-1-thanhnguyxn07@gmail.com \
    --to=thanhnguyxn07@gmail.com \
    --cc=dmitry.torokhov@gmail.com \
    --cc=linus.walleij@linaro.org \
    --cc=linux-input@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=timon37@lavabit.com \
    /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