linux-input.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] Input: st1232 - Fix NORMAL vs. IDLE state handling
@ 2021-02-23  9:02 Geert Uytterhoeven
  2021-02-23 10:29 ` Michael Tretter
  0 siblings, 1 reply; 3+ messages in thread
From: Geert Uytterhoeven @ 2021-02-23  9:02 UTC (permalink / raw)
  To: Dmitry Torokhov, Michael Tretter
  Cc: Andrej Valek, linux-input, linux-renesas-soc, linux-kernel,
	Geert Uytterhoeven

NORMAL (0x0) and IDLE (0x4) are really two different states.  Hence you
cannot check for both using a bitmask, as that checks for IDLE only,
breaking operation for devices that are in NORMAL state.

Fix the wait function to report either state as ready.

Fixes: 6524d8eac258452e ("Input: st1232 - add IDLE state as ready condition")
Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>
---
 drivers/input/touchscreen/st1232.c | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)

diff --git a/drivers/input/touchscreen/st1232.c b/drivers/input/touchscreen/st1232.c
index 885f0572488dd061..6abae665ca71d8ec 100644
--- a/drivers/input/touchscreen/st1232.c
+++ b/drivers/input/touchscreen/st1232.c
@@ -94,8 +94,13 @@ static int st1232_ts_wait_ready(struct st1232_ts_data *ts)
 
 	for (retries = 10; retries; retries--) {
 		error = st1232_ts_read_data(ts, REG_STATUS, 1);
-		if (!error && ts->read_buf[0] == (STATUS_NORMAL | STATUS_IDLE | ERROR_NONE))
-			return 0;
+		if (!error) {
+			switch (ts->read_buf[0]) {
+			case STATUS_NORMAL | ERROR_NONE:
+			case STATUS_IDLE | ERROR_NONE:
+				return 0;
+			}
+		}
 
 		usleep_range(1000, 2000);
 	}
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] Input: st1232 - Fix NORMAL vs. IDLE state handling
  2021-02-23  9:02 [PATCH] Input: st1232 - Fix NORMAL vs. IDLE state handling Geert Uytterhoeven
@ 2021-02-23 10:29 ` Michael Tretter
  2021-02-23 17:30   ` Dmitry Torokhov
  0 siblings, 1 reply; 3+ messages in thread
From: Michael Tretter @ 2021-02-23 10:29 UTC (permalink / raw)
  To: Geert Uytterhoeven
  Cc: Dmitry Torokhov, Andrej Valek, linux-input, linux-renesas-soc,
	linux-kernel

On Tue, 23 Feb 2021 10:02:01 +0100, Geert Uytterhoeven wrote:
> NORMAL (0x0) and IDLE (0x4) are really two different states.  Hence you
> cannot check for both using a bitmask, as that checks for IDLE only,
> breaking operation for devices that are in NORMAL state.

Thanks. I missed that the state is actually a value and not a bitfield.

> 
> Fix the wait function to report either state as ready.
> 
> Fixes: 6524d8eac258452e ("Input: st1232 - add IDLE state as ready condition")
> Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>

Reviewed-by: Michael Tretter <m.tretter@pengutronix.de>

> ---
>  drivers/input/touchscreen/st1232.c | 9 +++++++--
>  1 file changed, 7 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/input/touchscreen/st1232.c b/drivers/input/touchscreen/st1232.c
> index 885f0572488dd061..6abae665ca71d8ec 100644
> --- a/drivers/input/touchscreen/st1232.c
> +++ b/drivers/input/touchscreen/st1232.c
> @@ -94,8 +94,13 @@ static int st1232_ts_wait_ready(struct st1232_ts_data *ts)
>  
>  	for (retries = 10; retries; retries--) {
>  		error = st1232_ts_read_data(ts, REG_STATUS, 1);
> -		if (!error && ts->read_buf[0] == (STATUS_NORMAL | STATUS_IDLE | ERROR_NONE))
> -			return 0;
> +		if (!error) {
> +			switch (ts->read_buf[0]) {
> +			case STATUS_NORMAL | ERROR_NONE:
> +			case STATUS_IDLE | ERROR_NONE:
> +				return 0;
> +			}
> +		}
>  
>  		usleep_range(1000, 2000);
>  	}
> -- 
> 2.25.1
> 
> 

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] Input: st1232 - Fix NORMAL vs. IDLE state handling
  2021-02-23 10:29 ` Michael Tretter
@ 2021-02-23 17:30   ` Dmitry Torokhov
  0 siblings, 0 replies; 3+ messages in thread
From: Dmitry Torokhov @ 2021-02-23 17:30 UTC (permalink / raw)
  To: Michael Tretter
  Cc: Geert Uytterhoeven, Andrej Valek, linux-input, linux-renesas-soc,
	linux-kernel

On Tue, Feb 23, 2021 at 11:29:00AM +0100, Michael Tretter wrote:
> On Tue, 23 Feb 2021 10:02:01 +0100, Geert Uytterhoeven wrote:
> > NORMAL (0x0) and IDLE (0x4) are really two different states.  Hence you
> > cannot check for both using a bitmask, as that checks for IDLE only,
> > breaking operation for devices that are in NORMAL state.
> 
> Thanks. I missed that the state is actually a value and not a bitfield.
> 
> > 
> > Fix the wait function to report either state as ready.
> > 
> > Fixes: 6524d8eac258452e ("Input: st1232 - add IDLE state as ready condition")
> > Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>
> 
> Reviewed-by: Michael Tretter <m.tretter@pengutronix.de>

Applied, thank you.

-- 
Dmitry

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2021-02-23 17:31 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-02-23  9:02 [PATCH] Input: st1232 - Fix NORMAL vs. IDLE state handling Geert Uytterhoeven
2021-02-23 10:29 ` Michael Tretter
2021-02-23 17:30   ` Dmitry Torokhov

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).