Merge tag 'spi-fix-v5.5-rc5' of git://git.kernel.org/pub/scm/linux/kernel/git/broonie/spi
[linux-2.6-microblaze.git] / drivers / spi / spi.c
index 6b95cd9..8994545 100644 (file)
@@ -1874,15 +1874,7 @@ static int of_spi_parse_dt(struct spi_controller *ctlr, struct spi_device *spi,
                spi->mode |= SPI_3WIRE;
        if (of_property_read_bool(nc, "spi-lsb-first"))
                spi->mode |= SPI_LSB_FIRST;
-
-       /*
-        * For descriptors associated with the device, polarity inversion is
-        * handled in the gpiolib, so all chip selects are "active high" in
-        * the logical sense, the gpiolib will invert the line if need be.
-        */
-       if (ctlr->use_gpio_descriptors)
-               spi->mode |= SPI_CS_HIGH;
-       else if (of_property_read_bool(nc, "spi-cs-high"))
+       if (of_property_read_bool(nc, "spi-cs-high"))
                spi->mode |= SPI_CS_HIGH;
 
        /* Device DUAL/QUAD mode */
@@ -1946,6 +1938,15 @@ static int of_spi_parse_dt(struct spi_controller *ctlr, struct spi_device *spi,
        }
        spi->chip_select = value;
 
+       /*
+        * For descriptors associated with the device, polarity inversion is
+        * handled in the gpiolib, so all gpio chip selects are "active high"
+        * in the logical sense, the gpiolib will invert the line if need be.
+        */
+       if ((ctlr->use_gpio_descriptors) && ctlr->cs_gpiods &&
+           ctlr->cs_gpiods[spi->chip_select])
+               spi->mode |= SPI_CS_HIGH;
+
        /* Device speed */
        rc = of_property_read_u32(nc, "spi-max-frequency", &value);
        if (rc) {