diff mbox series

[1/3] Input: st1232 - fix off-by-one error in resolution handling

Message ID 20201229162601.2154566-2-geert+renesas@glider.be (mailing list archive)
State Accepted
Delegated to: Geert Uytterhoeven
Headers show
Series Input: st1232 - fixes for resolution reading | expand

Commit Message

Geert Uytterhoeven Dec. 29, 2020, 4:25 p.m. UTC
Before, the maximum coordinates were fixed to (799, 479) or (319, 479),
depending on touchscreen controller type.  The driver was changed to
read the actual values from the touchscreen controller, but did not take
into account the returned values are not the maximum coordinates, but
the touchscreen resolution (e.g. 800 and 480).

Fix this by subtracting 1.

Fixes: 3a54a215410b1650 ("Input: st1232 - add support resolution reading")
Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>
---
 drivers/input/touchscreen/st1232.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

Comments

Dmitry Torokhov Jan. 4, 2021, 1:44 a.m. UTC | #1
On Tue, Dec 29, 2020 at 05:25:59PM +0100, Geert Uytterhoeven wrote:
> Before, the maximum coordinates were fixed to (799, 479) or (319, 479),
> depending on touchscreen controller type.  The driver was changed to
> read the actual values from the touchscreen controller, but did not take
> into account the returned values are not the maximum coordinates, but
> the touchscreen resolution (e.g. 800 and 480).
> 
> Fix this by subtracting 1.
> 
> Fixes: 3a54a215410b1650 ("Input: st1232 - add support resolution reading")
> Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>

Applied, thank you.
diff mbox series

Patch

diff --git a/drivers/input/touchscreen/st1232.c b/drivers/input/touchscreen/st1232.c
index bda96762744e6da3..f18d4c7e03da17c6 100644
--- a/drivers/input/touchscreen/st1232.c
+++ b/drivers/input/touchscreen/st1232.c
@@ -85,8 +85,8 @@  static int st1232_ts_read_resolution(struct st1232_ts_data *ts, u16 *max_x,
 
 	buf = ts->read_buf;
 
-	*max_x = ((buf[0] & 0x0070) << 4) | buf[1];
-	*max_y = ((buf[0] & 0x0007) << 8) | buf[2];
+	*max_x = (((buf[0] & 0x0070) << 4) | buf[1]) - 1;
+	*max_y = (((buf[0] & 0x0007) << 8) | buf[2]) - 1;
 
 	return 0;
 }