Skip to content

Commit

Permalink
spi: Limit the spi device max speed to controller's max speed
Browse files Browse the repository at this point in the history
Make sure the max_speed_hz of spi_device does not override
the max_speed_hz of controller.

Signed-off-by: Tudor Ambarus <tudor.ambarus@microchip.com>
Link: https://lore.kernel.org/r/20201209173514.93328-1-tudor.ambarus@microchip.com
Signed-off-by: Mark Brown <broonie@kernel.org>
  • Loading branch information
Tudor Ambarus authored and Mark Brown committed Dec 11, 2020
1 parent e748edd commit 9326e4f
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion drivers/spi/spi.c
Original file line number Diff line number Diff line change
Expand Up @@ -3369,7 +3369,8 @@ int spi_setup(struct spi_device *spi)
if (status)
return status;

if (!spi->max_speed_hz)
if (!spi->max_speed_hz ||
spi->max_speed_hz > spi->controller->max_speed_hz)
spi->max_speed_hz = spi->controller->max_speed_hz;

mutex_lock(&spi->controller->io_mutex);
Expand Down

0 comments on commit 9326e4f

Please sign in to comment.