lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [day] [month] [year] [list]
Date:   Wed, 16 Aug 2017 13:02:14 +0200
From:   Joakim Tjernlund <joakim.tjernlund@...inera.com>
To:     linux-kernel@...r.kernel.org, Scott Wood <oss@...error.net>
Cc:     Joakim Tjernlund <joakim.tjernlund@...inera.com>
Subject: [PATCH] spi-fsl-spi: Align CS behaviour for last SPI msg

According to spi.h cs_change can be used to leave the CS
active until next SPI transfer(paragraph ii).
Adjust driver to comply with (ii).

Signed-off-by: Joakim Tjernlund <joakim.tjernlund@...inera.com>
---
 drivers/spi/spi-fsl-spi.c | 14 ++++++++++----
 1 file changed, 10 insertions(+), 4 deletions(-)

diff --git a/drivers/spi/spi-fsl-spi.c b/drivers/spi/spi-fsl-spi.c
index 061c1f38bf46..9a6cb26680a9 100644
--- a/drivers/spi/spi-fsl-spi.c
+++ b/drivers/spi/spi-fsl-spi.c
@@ -358,6 +358,7 @@ static int fsl_spi_do_one_msg(struct spi_master *master,
 {
 	struct spi_device *spi = m->spi;
 	struct spi_transfer *t, *first;
+	bool keep_cs = false;
 	unsigned int cs_change;
 	const int nsecs = 50;
 	int status;
@@ -401,16 +402,21 @@ static int fsl_spi_do_one_msg(struct spi_master *master,
 			udelay(t->delay_usecs);
 
 		if (cs_change) {
-			ndelay(nsecs);
-			fsl_spi_chipselect(spi, BITBANG_CS_INACTIVE);
-			ndelay(nsecs);
+			if (list_is_last(&t->transfer_list,
+					 &m->transfers)) {
+				keep_cs = true;
+			} else {
+				ndelay(nsecs);
+				fsl_spi_chipselect(spi, BITBANG_CS_INACTIVE);
+				ndelay(nsecs);
+			}
 		}
 	}
 
 	m->status = status;
 	spi_finalize_current_message(master);
 
-	if (status || !cs_change) {
+	if (status || !keep_cs) {
 		ndelay(nsecs);
 		fsl_spi_chipselect(spi, BITBANG_CS_INACTIVE);
 	}
-- 
2.13.0

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ