]> git.proxmox.com Git - mirror_ubuntu-bionic-kernel.git/commitdiff
spi: fsl-spi: Convert to let spi core validate xfer->bits_per_word
authorAxel Lin <axel.lin@ingics.com>
Thu, 13 Feb 2014 11:05:38 +0000 (19:05 +0800)
committerMark Brown <broonie@linaro.org>
Sun, 23 Feb 2014 04:14:39 +0000 (13:14 +0900)
Set bits_per_word_mask so spi core will reject transfers that attempt to use
an unsupported bits_per_word value.

fsl_spi_grlib_probe() may update mpc8xxx_spi->max_bits_per_word setting.
So set master->bits_per_word_mask after fsl_spi_grlib_probe().

Signed-off-by: Axel Lin <axel.lin@ingics.com>
Signed-off-by: Mark Brown <broonie@linaro.org>
drivers/spi/spi-fsl-spi.c

index 4dcb2929c01fa641709f1ce532fc832365212b70..f35488ed62a9eaca3c353401d9bf7b935bf4a00c 100644 (file)
@@ -239,12 +239,6 @@ static int fsl_spi_setup_transfer(struct spi_device *spi,
        if (!bits_per_word)
                bits_per_word = spi->bits_per_word;
 
-       /* Make sure its a bit width we support [4..16, 32] */
-       if ((bits_per_word < 4)
-           || ((bits_per_word > 16) && (bits_per_word != 32))
-           || (bits_per_word > mpc8xxx_spi->max_bits_per_word))
-               return -EINVAL;
-
        if (!hz)
                hz = spi->max_speed_hz;
 
@@ -651,6 +645,10 @@ static struct spi_master * fsl_spi_probe(struct device *dev,
        if (mpc8xxx_spi->type == TYPE_GRLIB)
                fsl_spi_grlib_probe(dev);
 
+       master->bits_per_word_mask =
+               (SPI_BPW_RANGE_MASK(4, 16) | SPI_BPW_MASK(32)) &
+               SPI_BPW_RANGE_MASK(1, mpc8xxx_spi->max_bits_per_word);
+
        if (mpc8xxx_spi->flags & SPI_QE_CPU_MODE)
                mpc8xxx_spi->set_shifts = fsl_spi_qe_cpu_set_shifts;