linux-input.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Luca Ellero <luca.ellero@brickedbrain.com>
To: dmitry.torokhov@gmail.com, daniel@zonque.org,
	m.felsch@pengutronix.de, andriy.shevchenko@linux.intel.com,
	u.kleine-koenig@pengutronix.de, mkl@pengutronix.de,
	miquel.raynal@bootlin.com, imre.deak@nokia.com
Cc: linux-input@vger.kernel.org, linux-kernel@vger.kernel.org,
	Luca Ellero <l.ellero@asem.it>
Subject: [PATCH 2/3] ads7846: always set last command to PWRDOWN
Date: Thu, 14 Jul 2022 10:43:18 +0200	[thread overview]
Message-ID: <20220714084319.107334-3-luca.ellero@brickedbrain.com> (raw)
In-Reply-To: <20220714084319.107334-1-luca.ellero@brickedbrain.com>

From: Luca Ellero <l.ellero@asem.it>

This was broken on controllers with 3 commands as ads7845.
READ_Z1 was sent instead.

Signed-off-by: Luca Ellero <l.ellero@asem.it>
---
 drivers/input/touchscreen/ads7846.c | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)

diff --git a/drivers/input/touchscreen/ads7846.c b/drivers/input/touchscreen/ads7846.c
index 24605c40d039..9e15cdf6faa0 100644
--- a/drivers/input/touchscreen/ads7846.c
+++ b/drivers/input/touchscreen/ads7846.c
@@ -1066,6 +1066,9 @@ static int ads7846_setup_spi_msg(struct ads7846 *ts,
 		struct ads7846_buf_layout *l = &packet->l[cmd_idx];
 		unsigned int max_count;
 
+		if (cmd_idx == packet->cmds - 1)
+			cmd_idx = ADS7846_PWDOWN;
+
 		if (ads7846_cmd_need_settle(cmd_idx))
 			max_count = packet->count + packet->count_skip;
 		else
@@ -1102,7 +1105,12 @@ static int ads7846_setup_spi_msg(struct ads7846 *ts,
 
 	for (cmd_idx = 0; cmd_idx < packet->cmds; cmd_idx++) {
 		struct ads7846_buf_layout *l = &packet->l[cmd_idx];
-		u8 cmd = ads7846_get_cmd(cmd_idx, vref);
+		u8 cmd;
+
+		if (cmd_idx == packet->cmds - 1)
+			cmd_idx = ADS7846_PWDOWN;
+
+		cmd = ads7846_get_cmd(cmd_idx, vref);
 
 		for (b = 0; b < l->count; b++)
 			packet->tx[l->offset + b].cmd = cmd;
-- 
2.25.1


  parent reply	other threads:[~2022-07-14  8:45 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-07-14  8:43 [PATCH 0/3] ads7846: fix support for ADS7845 Luca Ellero
2022-07-14  8:43 ` [PATCH 1/3] ads7846: don't report pressure for ads7845 Luca Ellero
2022-07-14 11:32   ` Andy Shevchenko
2022-07-15 14:36     ` Luca Ellero
2022-07-14  8:43 ` Luca Ellero [this message]
2022-07-14 11:34   ` [PATCH 2/3] ads7846: always set last command to PWRDOWN Andy Shevchenko
2022-07-14  8:43 ` [PATCH 3/3] ads7846: don't check penirq immediately for 7845 Luca Ellero
2022-07-14 11:35   ` Andy Shevchenko
  -- strict thread matches above, loose matches on Subject: below --
2022-11-29 15:19 [PATCH 0/3 RESEND] ads7846: fix support for ADS7845 Luca Ellero
2022-11-29 15:19 ` [PATCH 2/3] ads7846: always set last command to PWRDOWN Luca Ellero
2022-11-29 16:24   ` Andy Shevchenko

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=20220714084319.107334-3-luca.ellero@brickedbrain.com \
    --to=luca.ellero@brickedbrain.com \
    --cc=andriy.shevchenko@linux.intel.com \
    --cc=daniel@zonque.org \
    --cc=dmitry.torokhov@gmail.com \
    --cc=imre.deak@nokia.com \
    --cc=l.ellero@asem.it \
    --cc=linux-input@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=m.felsch@pengutronix.de \
    --cc=miquel.raynal@bootlin.com \
    --cc=mkl@pengutronix.de \
    --cc=u.kleine-koenig@pengutronix.de \
    /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 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).