The spi_setup should fail if underlying controller or its driver does not support requested bits_per_word. So if the master driver set mask and let core do bits_per_word check then we should also test this mask in spi_setup.
Signed-off-by: Scott Jiang <[email protected]> --- drivers/spi/spi.c | 9 +++++++++ 1 files changed, 9 insertions(+), 0 deletions(-) diff --git a/drivers/spi/spi.c b/drivers/spi/spi.c index 45cb6a9..dc8fde0 100644 --- a/drivers/spi/spi.c +++ b/drivers/spi/spi.c @@ -1326,6 +1326,15 @@ int spi_setup(struct spi_device *spi) if (!spi->bits_per_word) spi->bits_per_word = 8; + if (spi->master->bits_per_word_mask) { + /* Only 32 bits fit in the mask */ + if (spi->bits_per_word > 32) + return -EINVAL; + if (!(spi->master->bits_per_word_mask & + BIT(spi->bits_per_word - 1))) + return -EINVAL; + } + if (spi->master->setup) status = spi->master->setup(spi); -- 1.7.0.4 ------------------------------------------------------------------------------ This SF.net email is sponsored by Windows: Build for Windows Store. http://p.sf.net/sfu/windows-dev2dev _______________________________________________ spi-devel-general mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/spi-devel-general
