All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Jason A. Donenfeld" <Jason@zx2c4.com>
To: dmitry.torokhov@gmail.com, linux-input@vger.kernel.org,
	linux-kernel@vger.kernel.org, regressions@lists.linux.dev
Cc: "Jason A. Donenfeld" <Jason@zx2c4.com>,
	stable@vger.kernel.org, regressions@leemhuis.info,
	barry@messagefor.me.uk
Subject: [PATCH] Input: focaltech - use explicitly signed char type
Date: Sat, 18 Mar 2023 14:30:10 +0100	[thread overview]
Message-ID: <20230318133010.1285202-1-Jason@zx2c4.com> (raw)
In-Reply-To: <e20db4c4-b2a8-bc88-232f-d1213733d20c@leemhuis.info>

The recent change of -funsigned-char causes additions of negative
numbers to become additions of large positive numbers, leading to wrong
calculations of mouse movement. Change these casts to be explictly
signed, to take into account negative offsets.

Fixes: 3bc753c06dd0 ("kbuild: treat char as always unsigned")
Cc: stable@vger.kernel.org
Cc: regressions@leemhuis.info
Cc: barry@messagefor.me.uk
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
---
Wrote this patch from my phone, untested, so it would be nice if
somebody with hardware could confirm it works.

 drivers/input/mouse/focaltech.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/input/mouse/focaltech.c b/drivers/input/mouse/focaltech.c
index 6fd5fff0cbff..3dbad0d8e8c9 100644
--- a/drivers/input/mouse/focaltech.c
+++ b/drivers/input/mouse/focaltech.c
@@ -202,8 +202,8 @@ static void focaltech_process_rel_packet(struct psmouse *psmouse,
 	state->pressed = packet[0] >> 7;
 	finger1 = ((packet[0] >> 4) & 0x7) - 1;
 	if (finger1 < FOC_MAX_FINGERS) {
-		state->fingers[finger1].x += (char)packet[1];
-		state->fingers[finger1].y += (char)packet[2];
+		state->fingers[finger1].x += (signed char)packet[1];
+		state->fingers[finger1].y += (signed char)packet[2];
 	} else {
 		psmouse_err(psmouse, "First finger in rel packet invalid: %d\n",
 			    finger1);
@@ -218,8 +218,8 @@ static void focaltech_process_rel_packet(struct psmouse *psmouse,
 	 */
 	finger2 = ((packet[3] >> 4) & 0x7) - 1;
 	if (finger2 < FOC_MAX_FINGERS) {
-		state->fingers[finger2].x += (char)packet[4];
-		state->fingers[finger2].y += (char)packet[5];
+		state->fingers[finger2].x += (signed char)packet[4];
+		state->fingers[finger2].y += (signed char)packet[5];
 	}
 }
 
-- 
2.40.0


  reply	other threads:[~2023-03-18 13:30 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-03-18 12:08 [regression] focaltech touchpad driver misbehaves due to "kbuild: treat char as always unsigned" Linux regression tracking (Thorsten Leemhuis)
2023-03-18 13:30 ` Jason A. Donenfeld [this message]
2023-03-18 16:43   ` [PATCH] Input: focaltech - use explicitly signed char type Hans de Goede
2023-03-18 15:54 ` [regression] focaltech touchpad driver misbehaves due to "kbuild: treat char as always unsigned" msizanoen

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=20230318133010.1285202-1-Jason@zx2c4.com \
    --to=jason@zx2c4.com \
    --cc=barry@messagefor.me.uk \
    --cc=dmitry.torokhov@gmail.com \
    --cc=linux-input@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=regressions@leemhuis.info \
    --cc=regressions@lists.linux.dev \
    --cc=stable@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 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.