diff options
author | Axel Lin <axel.lin@ingics.com> | 2014-03-17 10:08:12 +0800 |
---|---|---|
committer | Mark Brown <broonie@linaro.org> | 2014-03-17 15:46:25 +0000 |
commit | a6f87fad7b5132f026592729ccf65b995cdec35d (patch) | |
tree | 24bb5827e380833ab8066b0ac9ed8fa57a8cda19 | |
parent | 6ea312936d68b557766dafa9a3c4617e14ffa076 (diff) | |
download | op-kernel-dev-a6f87fad7b5132f026592729ccf65b995cdec35d.zip op-kernel-dev-a6f87fad7b5132f026592729ccf65b995cdec35d.tar.gz |
spi: core: Use master->max_speed_hz as transfer speed when xfer->speed_hz > master->max_speed_hz
When xfer->speed_hz is greater than master->max_speed_hz, it's generally safe
to use master->max_speed_hz as transfer speed.
Thus use master->max_speed_hz as transfer speed rather than return error when
xfer->speed_hz > master->max_speed_hz.
Signed-off-by: Axel Lin <axel.lin@ingics.com>
Tested-by: Guenter Roeck <linux@roeck-us.net>
Reviewed-by: Guenter Roeck <linux@roeck-us.net>
Signed-off-by: Mark Brown <broonie@linaro.org>
-rw-r--r-- | drivers/spi/spi.c | 14 |
1 files changed, 6 insertions, 8 deletions
diff --git a/drivers/spi/spi.c b/drivers/spi/spi.c index 9d14054..38e1c31 100644 --- a/drivers/spi/spi.c +++ b/drivers/spi/spi.c @@ -1653,12 +1653,13 @@ static int __spi_validate(struct spi_device *spi, struct spi_message *message) message->frame_length += xfer->len; if (!xfer->bits_per_word) xfer->bits_per_word = spi->bits_per_word; - if (!xfer->speed_hz) { + + if (!xfer->speed_hz) xfer->speed_hz = spi->max_speed_hz; - if (master->max_speed_hz && - xfer->speed_hz > master->max_speed_hz) - xfer->speed_hz = master->max_speed_hz; - } + + if (master->max_speed_hz && + xfer->speed_hz > master->max_speed_hz) + xfer->speed_hz = master->max_speed_hz; if (master->bits_per_word_mask) { /* Only 32 bits fit in the mask */ @@ -1687,9 +1688,6 @@ static int __spi_validate(struct spi_device *spi, struct spi_message *message) if (xfer->speed_hz && master->min_speed_hz && xfer->speed_hz < master->min_speed_hz) return -EINVAL; - if (xfer->speed_hz && master->max_speed_hz && - xfer->speed_hz > master->max_speed_hz) - return -EINVAL; if (xfer->tx_buf && !xfer->tx_nbits) xfer->tx_nbits = SPI_NBITS_SINGLE; |