summaryrefslogtreecommitdiff
path: root/drivers/spi/spi.c
diff options
context:
space:
mode:
authorGabor Juhos <juhosg@openwrt.org>2013-08-14 10:25:28 +0200
committerMark Brown <broonie@linaro.org>2013-08-14 19:12:31 +0100
commit56ede94a000bb9635b326db38baf66da6dfc174e (patch)
treefdf5f0ba35a81bbfaf3ae5374609d9b2689b16b4 /drivers/spi/spi.c
parent24a0013a04e81e95198daab98edf4df02e191568 (diff)
downloadlwn-56ede94a000bb9635b326db38baf66da6dfc174e.tar.gz
lwn-56ede94a000bb9635b326db38baf66da6dfc174e.zip
spi: limit default transfer speed to controller's max speed
Since the 'spi: Support transfer speed checking in the core' change, the SPI core validates the desired speed of a given transfer against the minimum and maximum speeds supported by the controller. If the speed of a transfer is not specified, the core uses the maximum speed of the actual SPI device. However if the maximum speed of the actual device is greater than the maximum speed of the controller, the core will reject the transfer due to the aforementioned change. Change the code to use the maximum speed of the controller by default if that is below the device's maximum speed. Signed-off-by: Gabor Juhos <juhosg@openwrt.org> Signed-off-by: Mark Brown <broonie@linaro.org>
Diffstat (limited to 'drivers/spi/spi.c')
-rw-r--r--drivers/spi/spi.c7
1 files changed, 6 insertions, 1 deletions
diff --git a/drivers/spi/spi.c b/drivers/spi/spi.c
index c2899161ccac..2a20c32c8277 100644
--- a/drivers/spi/spi.c
+++ b/drivers/spi/spi.c
@@ -1382,8 +1382,13 @@ static int __spi_async(struct spi_device *spi, struct spi_message *message)
list_for_each_entry(xfer, &message->transfers, transfer_list) {
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->bits_per_word_mask) {
/* Only 32 bits fit in the mask */
if (xfer->bits_per_word > 32)