Skip to content

Commit 052eb2d

Browse files
AxelLinbroonie
authored andcommitted
spi: core: Set max_speed_hz of spi_device default to max_speed_hz of controller
In __spi_validate(), xfer->speed_hz is set to be spi->max_speed_hz if it is not set for this transfer. However, if spi->max_speed_hz is also not set, xfer->speed_hz is 0. Some drivers (e.g. au1550, tegra114, tegra20-sflash, tegra20-slink, etc.) then use below code to avoid setting xfer->speed_hz to 0. /* Set speed to the spi max fequency if spi device has not set */ spi->max_speed_hz = spi->max_speed_hz ? : tspi->spi_max_frequency; Let's handle it in spi core. If spi->max_speed_hz is not set, make it default to spi->master->max_speed_hz. So In __spi_validate() if both xfer->speed_hz and spi->max_speed_hz are not set, xfer->speed_hz will be set to spi->master->max_speed_hz. Signed-off-by: Axel Lin <[email protected]> Signed-off-by: Mark Brown <[email protected]>
1 parent 38dbfb5 commit 052eb2d

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

drivers/spi/spi.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1599,6 +1599,9 @@ int spi_setup(struct spi_device *spi)
15991599
if (!spi->bits_per_word)
16001600
spi->bits_per_word = 8;
16011601

1602+
if (!spi->max_speed_hz)
1603+
spi->max_speed_hz = spi->master->max_speed_hz;
1604+
16021605
if (spi->master->setup)
16031606
status = spi->master->setup(spi);
16041607

0 commit comments

Comments
 (0)