]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
spi: Allow to have all native CSs in use along with GPIOs
authorAndy Shevchenko <andriy.shevchenko@linux.intel.com>
Tue, 20 Apr 2021 16:44:24 +0000 (19:44 +0300)
committerMark Brown <broonie@kernel.org>
Wed, 21 Apr 2021 14:49:53 +0000 (15:49 +0100)
The commit 7d93aecdb58d ("spi: Add generic support for unused native cs
with cs-gpios") excludes the valid case for the controllers that doesn't
need to switch native CS in order to perform the transfer, i.e. when

  0 native
  ... ...
  <n> - 1 native
  <n> GPIO
  <n> + 1 GPIO
  ... ...

where <n> defines maximum of native CSs supported by the controller.

To allow this, bail out from spi_get_gpio_descs() conditionally for
the controllers which explicitly marked with SPI_MASTER_GPIO_SS.

Fixes: 7d93aecdb58d ("spi: Add generic support for unused native cs with cs-gpios")
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Link: https://lore.kernel.org/r/20210420164425.40287-1-andriy.shevchenko@linux.intel.com
Signed-off-by: Mark Brown <broonie@kernel.org>
drivers/spi/spi.c

index 862a9bb6912984d076c25d7ed92f8acea8fbf1f2..2e5dca20c8d00b4e659637819b059f7aea9c1aa4 100644 (file)
@@ -2612,8 +2612,9 @@ static int spi_get_gpio_descs(struct spi_controller *ctlr)
        }
 
        ctlr->unused_native_cs = ffz(native_cs_mask);
-       if (num_cs_gpios && ctlr->max_native_cs &&
-           ctlr->unused_native_cs >= ctlr->max_native_cs) {
+
+       if ((ctlr->flags & SPI_MASTER_GPIO_SS) && num_cs_gpios &&
+           ctlr->max_native_cs && ctlr->unused_native_cs >= ctlr->max_native_cs) {
                dev_err(dev, "No unused native chip select available\n");
                return -EINVAL;
        }