Skip to content

Commit 754ff50

Browse files
msizanoen1dtor
authored andcommitted
Input: alps - fix compatibility with -funsigned-char
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: f3f33c6 ("Input: alps - Rushmore and v7 resolution support") Signed-off-by: msizanoen <msizanoen@qtmlabs.xyz> Cc: stable@vger.kernel.org Link: https://lore.kernel.org/r/20230320045228.182259-1-msizanoen@qtmlabs.xyz Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
1 parent 8980f19 commit 754ff50

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

drivers/input/mouse/alps.c

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -852,8 +852,8 @@ static void alps_process_packet_v6(struct psmouse *psmouse)
852852
x = y = z = 0;
853853

854854
/* Divide 4 since trackpoint's speed is too fast */
855-
input_report_rel(dev2, REL_X, (char)x / 4);
856-
input_report_rel(dev2, REL_Y, -((char)y / 4));
855+
input_report_rel(dev2, REL_X, (s8)x / 4);
856+
input_report_rel(dev2, REL_Y, -((s8)y / 4));
857857

858858
psmouse_report_standard_buttons(dev2, packet[3]);
859859

@@ -1104,8 +1104,8 @@ static void alps_process_trackstick_packet_v7(struct psmouse *psmouse)
11041104
((packet[3] & 0x20) << 1);
11051105
z = (packet[5] & 0x3f) | ((packet[3] & 0x80) >> 1);
11061106

1107-
input_report_rel(dev2, REL_X, (char)x);
1108-
input_report_rel(dev2, REL_Y, -((char)y));
1107+
input_report_rel(dev2, REL_X, (s8)x);
1108+
input_report_rel(dev2, REL_Y, -((s8)y));
11091109
input_report_abs(dev2, ABS_PRESSURE, z);
11101110

11111111
psmouse_report_standard_buttons(dev2, packet[1]);
@@ -2294,20 +2294,20 @@ static int alps_get_v3_v7_resolution(struct psmouse *psmouse, int reg_pitch)
22942294
if (reg < 0)
22952295
return reg;
22962296

2297-
x_pitch = (char)(reg << 4) >> 4; /* sign extend lower 4 bits */
2297+
x_pitch = (s8)(reg << 4) >> 4; /* sign extend lower 4 bits */
22982298
x_pitch = 50 + 2 * x_pitch; /* In 0.1 mm units */
22992299

2300-
y_pitch = (char)reg >> 4; /* sign extend upper 4 bits */
2300+
y_pitch = (s8)reg >> 4; /* sign extend upper 4 bits */
23012301
y_pitch = 36 + 2 * y_pitch; /* In 0.1 mm units */
23022302

23032303
reg = alps_command_mode_read_reg(psmouse, reg_pitch + 1);
23042304
if (reg < 0)
23052305
return reg;
23062306

2307-
x_electrode = (char)(reg << 4) >> 4; /* sign extend lower 4 bits */
2307+
x_electrode = (s8)(reg << 4) >> 4; /* sign extend lower 4 bits */
23082308
x_electrode = 17 + x_electrode;
23092309

2310-
y_electrode = (char)reg >> 4; /* sign extend upper 4 bits */
2310+
y_electrode = (s8)reg >> 4; /* sign extend upper 4 bits */
23112311
y_electrode = 13 + y_electrode;
23122312

23132313
x_phys = x_pitch * (x_electrode - 1); /* In 0.1 mm units */

0 commit comments

Comments
 (0)