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>] [thread-next>] [day] [month] [year] [list]
Message-Id: <20191204231931.21378-1-linus.walleij@linaro.org>
Date:   Thu,  5 Dec 2019 00:19:31 +0100
From:   Linus Walleij <linus.walleij@...aro.org>
To:     lee.jones@...aro.org, linux-kernel@...r.kernel.org
Cc:     Linus Walleij <linus.walleij@...aro.org>,
        Mark Brown <broonie@...nel.org>
Subject: [PATCH] mfd: motorola-cpcap: Do not hardcode SPI mode flags

The current use of mode flags to us SPI_MODE_0 and
SPI_CS_HIGH is fragile: it overwrites anything already
assigned by the SPI core. Change it thusly:

- Just |= the SPI_MODE_0 so we keep other flags
- Assign ^= SPI_CS_HIGH since we might be active high
  already, and that is usually the case with GPIOs used
  for chip select, even if they are in practice active low.

Add a comment clarifying why ^= SPI_CS_HIGH is the right
choice here.

Reported-by: Mark Brown <broonie@...nel.org>
Signed-off-by: Linus Walleij <linus.walleij@...aro.org>
---
 drivers/mfd/motorola-cpcap.c | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/drivers/mfd/motorola-cpcap.c b/drivers/mfd/motorola-cpcap.c
index 52f38e57cdc1..a3bc61b8008c 100644
--- a/drivers/mfd/motorola-cpcap.c
+++ b/drivers/mfd/motorola-cpcap.c
@@ -279,7 +279,13 @@ static int cpcap_probe(struct spi_device *spi)
 	spi_set_drvdata(spi, cpcap);
 
 	spi->bits_per_word = 16;
-	spi->mode = SPI_MODE_0 | SPI_CS_HIGH;
+	spi->mode |= SPI_MODE_0;
+	/*
+	 * Active high should be defined as "inverse polarity" as GPIO-based
+	 * chip selects can be logically active high but inverted by the GPIO
+	 * library.
+	 */
+	spi->mode ^= SPI_CS_HIGH;
 
 	ret = spi_setup(spi);
 	if (ret)
-- 
2.23.0

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ