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:   Fri,  2 Dec 2022 10:49:26 +0100
From:   Edmund Berenson <edmund.berenson@...ix.com>
To:     unlisted-recipients:; (no To-header on input)
Cc:     Edmund Berenson <edmund.berenson@...ix.com>,
        Lukasz Zemla <Lukasz.Zemla@...dward.com>,
        Mark Brown <broonie@...nel.org>, linux-spi@...r.kernel.org,
        linux-kernel@...r.kernel.org
Subject: [PATCH 2/3] spi: execute set_cs function before gpio cs is activated

In some cases it is necessary to adjust the spi controller configuration
before gpio cs is set.
For example if spi devices requiring different cpol are used from the same
controller the adjustment to cpol has to be made before gpio is activated.
To achieve this set_cs should be executed before gpio cs and necessary
adjustments can be made inside of controller driver.

Suggested-by: Lukasz Zemla <Lukasz.Zemla@...dward.com>
Signed-off-by: Edmund Berenson <edmund.berenson@...ix.com>
---
 drivers/spi/spi.c | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)

diff --git a/drivers/spi/spi.c b/drivers/spi/spi.c
index 5f9aedd1f0b6..bf2a67184969 100644
--- a/drivers/spi/spi.c
+++ b/drivers/spi/spi.c
@@ -976,6 +976,11 @@ static void spi_set_cs(struct spi_device *spi, bool enable, bool force)
 		enable = !enable;
 
 	if (spi->cs_gpiod) {
+		/* Some SPI masters need both GPIO CS & slave_select */
+		if ((spi->controller->flags & SPI_MASTER_GPIO_SS) &&
+		    spi->controller->set_cs)
+			spi->controller->set_cs(spi, !enable);
+
 		if (!(spi->mode & SPI_NO_CS)) {
 			/*
 			 * Historically ACPI has no means of the GPIO polarity and
@@ -993,10 +998,6 @@ static void spi_set_cs(struct spi_device *spi, bool enable, bool force)
 				/* Polarity handled by GPIO library */
 				gpiod_set_value_cansleep(spi->cs_gpiod, activate);
 		}
-		/* Some SPI masters need both GPIO CS & slave_select */
-		if ((spi->controller->flags & SPI_MASTER_GPIO_SS) &&
-		    spi->controller->set_cs)
-			spi->controller->set_cs(spi, !enable);
 	} else if (spi->controller->set_cs) {
 		spi->controller->set_cs(spi, !enable);
 	}
-- 
2.37.4

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ