aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/spi
diff options
context:
space:
mode:
authorTudor Ambarus <tudor.ambarus@microchip.com>2020-12-09 19:35:14 +0200
committerMark Brown <broonie@kernel.org>2020-12-11 13:21:36 +0000
commit9326e4f1e5dd1a4410c429638d3c412b6fc17040 (patch)
tree8aecb1d047b1df2abbfa1ef323d2a724a6a61c77 /drivers/spi
parentspi: dw: Fix error return code in dw_spi_bt1_probe() (diff)
downloadlinux-dev-9326e4f1e5dd1a4410c429638d3c412b6fc17040.tar.xz
linux-dev-9326e4f1e5dd1a4410c429638d3c412b6fc17040.zip
spi: Limit the spi device max speed to controller's max speed
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>
Diffstat (limited to 'drivers/spi')
-rw-r--r--drivers/spi/spi.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/drivers/spi/spi.c b/drivers/spi/spi.c
index fc9a59788d2e..45021d271da2 100644
--- a/drivers/spi/spi.c
+++ b/drivers/spi/spi.c
@@ -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);