summaryrefslogtreecommitdiff
path: root/drivers/spi/spi-axi-spi-engine.c
diff options
context:
space:
mode:
authorDavid Lechner <dlechner@baylibre.com>2023-11-17 14:12:59 -0600
committerMark Brown <broonie@kernel.org>2023-11-20 13:29:10 +0000
commite6d5eb85e84aeace5e231b951ece86b20df9f63a (patch)
tree070746556da931937dce713323bf585f231bef8f /drivers/spi/spi-axi-spi-engine.c
parente16e71e3f3c4b73b20f8c79f7ce8465542a337e9 (diff)
downloadlwn-e6d5eb85e84aeace5e231b951ece86b20df9f63a.tar.gz
lwn-e6d5eb85e84aeace5e231b951ece86b20df9f63a.zip
spi: axi-spi-engine: check for valid clock rate
This adds a check for a valid SCLK rate in the axi-spi-engine driver during probe. A valid rate is required to get accurate timing for delays and by not allowing 0 we can avoid divide by zero errors later without additional checks. Signed-off-by: David Lechner <dlechner@baylibre.com> Link: https://lore.kernel.org/r/20231117-axi-spi-engine-series-1-v1-8-cc59db999b87@baylibre.com Signed-off-by: Mark Brown <broonie@kernel.org>
Diffstat (limited to 'drivers/spi/spi-axi-spi-engine.c')
-rw-r--r--drivers/spi/spi-axi-spi-engine.c3
1 files changed, 3 insertions, 0 deletions
diff --git a/drivers/spi/spi-axi-spi-engine.c b/drivers/spi/spi-axi-spi-engine.c
index 819744246952..8a6fbb3bb3f1 100644
--- a/drivers/spi/spi-axi-spi-engine.c
+++ b/drivers/spi/spi-axi-spi-engine.c
@@ -532,6 +532,9 @@ static int spi_engine_probe(struct platform_device *pdev)
host->transfer_one_message = spi_engine_transfer_one_message;
host->num_chipselect = 8;
+ if (host->max_speed_hz == 0)
+ return dev_err_probe(&pdev->dev, -EINVAL, "spi_clk rate is 0");
+
ret = devm_spi_register_controller(&pdev->dev, host);
if (ret)
return ret;