Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

spi: stm32-qspi: Refactor dual flash mode enable check in ->setup()

gpiod_count() either returns positive number of the CS or negative
error code. In the stm32_qspi_setup() we check that configuration
has enough CS for the dual flash mode and SPI mode is not changing
over the lines of the code. Taking all above into considertion,
refactor dual flash mode enable check by dropping unneeded CS check
and reusing local mode variable.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Reviewed-by: Patrice Chotard <patrice.chotard@foss.st.com>
Link: https://lore.kernel.org/r/20220830182821.47919-2-andriy.shevchenko@linux.intel.com
Signed-off-by: Mark Brown <broonie@kernel.org>

authored by

Andy Shevchenko and committed by
Mark Brown
c9448aa4 eea0e7d2

+1 -2
+1 -2
drivers/spi/spi-stm32-qspi.c
··· 680 680 * Dual flash mode is only enable in case SPI_TX_OCTAL and SPI_TX_OCTAL 681 681 * are both set in spi->mode and "cs-gpios" properties is found in DT 682 682 */ 683 - if (((spi->mode & (SPI_TX_OCTAL | SPI_RX_OCTAL)) == (SPI_TX_OCTAL | SPI_RX_OCTAL)) && 684 - gpiod_count(qspi->dev, "cs")) { 683 + if (mode == (SPI_TX_OCTAL | SPI_RX_OCTAL)) { 685 684 qspi->cr_reg |= CR_DFM; 686 685 dev_dbg(qspi->dev, "Dual flash mode enable"); 687 686 }