From nobody Fri Dec 19 04:28:15 2025 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id E2C78C7618B for ; Sat, 18 Mar 2023 15:25:39 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229822AbjCRPZi (ORCPT ); Sat, 18 Mar 2023 11:25:38 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44732 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229767AbjCRPZf (ORCPT ); Sat, 18 Mar 2023 11:25:35 -0400 X-Greylist: delayed 1199 seconds by postgrey-1.37 at lindbergh.monkeyblade.net; Sat, 18 Mar 2023 08:25:25 PDT Received: from hyperium.qtmlabs.xyz (hyperium.qtmlabs.xyz [194.163.182.183]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 740751ABCC; Sat, 18 Mar 2023 08:25:25 -0700 (PDT) Received: from dong.kernal.eu (unknown [222.254.17.84]) by hyperium.qtmlabs.xyz (Postfix) with ESMTPSA id B9055820257; Sat, 18 Mar 2023 15:46:24 +0100 (CET) Received: from localhost (unknown [171.255.115.39]) by dong.kernal.eu (Postfix) with ESMTPSA id 2975F44496AC; Sat, 18 Mar 2023 21:46:19 +0700 (+07) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=qtmlabs.xyz; s=syka; t=1679150779; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding; bh=QS6eRcg3qz0+dvGL11XvXEsHicDLuvrO+aW9MNPSbOE=; b=BIj85WG2x2uqf88mxb7tsgmbgKVsvHC0nx2oc4yjIX0OSYloylRPs9rdl8mJQamv79M4iO xIC8L2pjq6gWknVs+tTzYU8aBq1V1Vd0gSWSlyp6YHgLJL0yqJL28Xwaa58nCEO9gHOLh5 +RJepBA8M/EX9Be8lo+XLWQ0Hq9sTB9iyoKHd7rL7ahGrP6FZzV10CJbgJV/7XzRnbrcSv 5AxGTC6cbe1G/b2zZUHdmyxDwfn7PziA1hu06v1obLgdvhpSOjA+lyO/oQT34sF4SsQQlI 49k7O9hhQvdfSbqVSDitP67I7OnFgqLRckjkXUpDtCZ44L6ntIAizSwU/Pbd0g== From: msizanoen To: =?UTF-8?q?Pali=20Roh=C3=A1r?= , Dmitry Torokhov , Hans de Goede Cc: msizanoen , stable@vger.kernel.org, linux-input@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH] input: alps: fix compatibility with -funsigned-char Date: Sat, 18 Mar 2023 21:42:07 +0700 Message-Id: <20230318144206.14309-1-msizanoen@qtmlabs.xyz> X-Mailer: git-send-email 2.39.2 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" The AlpsPS/2 code previously relied on the assumption that `char` is a signed type, which was true on x86 platforms (the only place where this driver is used) before kernel 6.2. However, on 6.2 and later, this assumption is broken due to the introduction of -funsigned-char as a new global compiler flag. Fix this by explicitly specifying the signedness of `char` when sign extending the values received from the device. Fixes: f3f33c677699 ("Input: alps - Rushmore and v7 resolution support") Cc: stable@vger.kernel.org Signed-off-by: msizanoen Reviewed-by: Hans de Goede Reviewed-by: Pali Roh=C3=A1r Tested-by: msizanoen --- drivers/input/mouse/alps.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/input/mouse/alps.c b/drivers/input/mouse/alps.c index 989228b5a0a4..1c570d373b30 100644 --- a/drivers/input/mouse/alps.c +++ b/drivers/input/mouse/alps.c @@ -2294,20 +2294,20 @@ static int alps_get_v3_v7_resolution(struct psmouse= *psmouse, int reg_pitch) if (reg < 0) return reg; =20 - x_pitch =3D (char)(reg << 4) >> 4; /* sign extend lower 4 bits */ + x_pitch =3D (signed char)(reg << 4) >> 4; /* sign extend lower 4 bits */ x_pitch =3D 50 + 2 * x_pitch; /* In 0.1 mm units */ =20 - y_pitch =3D (char)reg >> 4; /* sign extend upper 4 bits */ + y_pitch =3D (signed char)reg >> 4; /* sign extend upper 4 bits */ y_pitch =3D 36 + 2 * y_pitch; /* In 0.1 mm units */ =20 reg =3D alps_command_mode_read_reg(psmouse, reg_pitch + 1); if (reg < 0) return reg; =20 - x_electrode =3D (char)(reg << 4) >> 4; /* sign extend lower 4 bits */ + x_electrode =3D (signed char)(reg << 4) >> 4; /* sign extend lower 4 bits= */ x_electrode =3D 17 + x_electrode; =20 - y_electrode =3D (char)reg >> 4; /* sign extend upper 4 bits */ + y_electrode =3D (signed char)reg >> 4; /* sign extend upper 4 bits */ y_electrode =3D 13 + y_electrode; =20 x_phys =3D x_pitch * (x_electrode - 1); /* In 0.1 mm units */ --=20 2.39.2