Skip to content

Commit

Permalink
spi: limit default transfer speed to controller's max speed
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Gabor Juhos authored and Mark Brown committed Aug 14, 2013
1 parent 24a0013 commit 56ede94
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion drivers/spi/spi.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 56ede94

Please sign in to comment.