spi: core: Set max_speed_hz of spi_device default to max_speed_hz of controller
authorAxel Lin <axel.lin@ingics.com>
Sun, 9 Feb 2014 16:08:05 +0000 (00:08 +0800)
committerMark Brown <broonie@linaro.org>
Mon, 10 Feb 2014 12:51:54 +0000 (12:51 +0000)
commit052eb2d49006fe53bc5f62a196dce23345d4a907
tree462e6776c9b49a341f81a0804cd385f48e600dee
parent38dbfb59d1175ef458d006556061adeaa8751b72
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 <axel.lin@ingics.com>
Signed-off-by: Mark Brown <broonie@linaro.org>
drivers/spi/spi.c