Skip to content

Commit c2bd079

Browse files
Patrice Chotardbroonie
authored andcommitted
spi: stm32: qspi: Fix dual flash mode sanity test in stm32_qspi_setup()
Misplaced parenthesis make test of mode wrong in case mode is equal to SPI_TX_OCTAL or SPI_RX_OCTAL. Simplify this sanity test, if one of this bit is set, property cs-gpio must be present in DT. Fixes: a557fca ("spi: stm32_qspi: Add transfer_one_message() spi callback") Cc: stable@vger.kernel.org Signed-off-by: Patrice Chotard <patrice.chotard@foss.st.com> Link: https://msgid.link/r/20240618132951.2743935-2-patrice.chotard@foss.st.com Signed-off-by: Mark Brown <broonie@kernel.org>
1 parent 60980cf commit c2bd079

File tree

1 file changed

+4
-6
lines changed

1 file changed

+4
-6
lines changed

drivers/spi/spi-stm32-qspi.c

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -653,9 +653,7 @@ static int stm32_qspi_setup(struct spi_device *spi)
653653
return -EINVAL;
654654

655655
mode = spi->mode & (SPI_TX_OCTAL | SPI_RX_OCTAL);
656-
if ((mode == SPI_TX_OCTAL || mode == SPI_RX_OCTAL) ||
657-
((mode == (SPI_TX_OCTAL | SPI_RX_OCTAL)) &&
658-
gpiod_count(qspi->dev, "cs") == -ENOENT)) {
656+
if (mode && gpiod_count(qspi->dev, "cs") == -ENOENT) {
659657
dev_err(qspi->dev, "spi-rx-bus-width\\/spi-tx-bus-width\\/cs-gpios\n");
660658
dev_err(qspi->dev, "configuration not supported\n");
661659

@@ -676,10 +674,10 @@ static int stm32_qspi_setup(struct spi_device *spi)
676674
qspi->cr_reg = CR_APMS | 3 << CR_FTHRES_SHIFT | CR_SSHIFT | CR_EN;
677675

678676
/*
679-
* Dual flash mode is only enable in case SPI_TX_OCTAL and SPI_TX_OCTAL
680-
* are both set in spi->mode and "cs-gpios" properties is found in DT
677+
* Dual flash mode is only enable in case SPI_TX_OCTAL or SPI_RX_OCTAL
678+
* is set in spi->mode and "cs-gpios" properties is found in DT
681679
*/
682-
if (mode == (SPI_TX_OCTAL | SPI_RX_OCTAL)) {
680+
if (mode) {
683681
qspi->cr_reg |= CR_DFM;
684682
dev_dbg(qspi->dev, "Dual flash mode enable");
685683
}

0 commit comments

Comments
 (0)