SPI controller drivers: check for unsupported modes
[deliverable/linux.git] / drivers / spi / spi_mpc83xx.c
index e9798bf7b8c6a0dff43795edc1ec1ee36ade6c42..9cdbc12278e51ca55b4121920a675554da692dcb 100644 (file)
@@ -232,12 +232,21 @@ int mpc83xx_spi_setup_transfer(struct spi_device *spi, struct spi_transfer *t)
        return 0;
 }
 
+/* the spi->mode bits understood by this driver: */
+#define MODEBITS (SPI_CPOL | SPI_CPHA | SPI_CS_HIGH)
+
 static int mpc83xx_spi_setup(struct spi_device *spi)
 {
        struct spi_bitbang *bitbang;
        struct mpc83xx_spi *mpc83xx_spi;
        int retval;
 
+       if (spi->mode & ~MODEBITS) {
+               dev_dbg(&spi->dev, "setup: unsupported mode bits %x\n",
+                       spi->mode & ~MODEBITS);
+               return -EINVAL;
+       }
+
        if (!spi->max_speed_hz)
                return -EINVAL;
 
This page took 0.034991 seconds and 5 git commands to generate.