spi: core: Set max_speed_hz of spi_device default to max_speed_hz of controller
PATCH 1/1 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.
--- drivers/spi/spi.c | 3 +++ 1 file changed, 3 insertions(+)
drivers/spi/spi.c +3 -0
@@ -1787,6 +1787,9 @@ int spi_setup(struct spi_device *spi)if (!spi->bits_per_word) spi->bits_per_word =8 ; +if (!spi->max_speed_hz) + spi->max_speed_hz = spi->master->max_speed_hz; +if (spi->master->setup) status = spi->master->setup (spi);
Signature · 8 lines
1.8.1.2 -- To unsubscribe from this list: send the line "unsubscribe linux-spi" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
Mark Brown
AppliedQuoted 4 lines · Axel Lin
In
__spi_validate(),xfer->speed_hzis set to bespi->max_speed_hzif it is not set for this transfer. However, ifspi->max_speed_hzis also not set,xfer->speed_hzis 0. Some drivers (e.g. au1550, tegra114, tegra20-sflash, tegra20-slink, etc.) then use below code to avoid settingxfer->speed_hzto 0.
Applied, thanks.