Skip to content

Commit 56ede94

Browse files
juhosgbroonie
authored andcommitted
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>
1 parent 24a0013 commit 56ede94

1 file changed

Lines changed: 6 additions & 1 deletion

File tree

‎drivers/spi/spi.c‎

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1382,8 +1382,13 @@ static int __spi_async(struct spi_device *spi, struct spi_message *message)
13821382
list_for_each_entry(xfer, &message->transfers, transfer_list) {
13831383
if (!xfer->bits_per_word)
13841384
xfer->bits_per_word = spi->bits_per_word;
1385-
if (!xfer->speed_hz)
1385+
if (!xfer->speed_hz) {
13861386
xfer->speed_hz = spi->max_speed_hz;
1387+
if (master->max_speed_hz &&
1388+
xfer->speed_hz > master->max_speed_hz)
1389+
xfer->speed_hz = master->max_speed_hz;
1390+
}
1391+
13871392
if (master->bits_per_word_mask) {
13881393
/* Only 32 bits fit in the mask */
13891394
if (xfer->bits_per_word > 32)

0 commit comments

Comments
 (0)