summaryrefslogtreecommitdiffstats
path: root/drivers/iio/adc
diff options
context:
space:
mode:
authorFabrice Gasnier <fabrice.gasnier@st.com>2018-02-23 13:51:01 +0100
committerJonathan Cameron <Jonathan.Cameron@huawei.com>2018-04-28 16:17:59 +0100
commit4cfcb2bfdd07b130f05a3fb39edd6bfa2a59bf7a (patch)
treeb87452dc0efdff5a696e0b1dcc629ca61e2b3c9d /drivers/iio/adc
parentdfa105b1f602bdd63296ab0abd2c6ec2cb09eb89 (diff)
downloadlinux-4cfcb2bfdd07b130f05a3fb39edd6bfa2a59bf7a.tar.bz2
iio: adc: stm32-dfsdm: add check on spi-max-frequency
spi-max-frequency is requested for SPI master mode (only), to tune output clock. It may happen requested frequency isn't reachable. Add explicit check, so probe fails with error in this case. Otherwise, output clock may simply be silently turned off (conversions fail). Signed-off-by: Fabrice Gasnier <fabrice.gasnier@st.com> Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Diffstat (limited to 'drivers/iio/adc')
-rw-r--r--drivers/iio/adc/stm32-dfsdm-core.c5
1 files changed, 5 insertions, 0 deletions
diff --git a/drivers/iio/adc/stm32-dfsdm-core.c b/drivers/iio/adc/stm32-dfsdm-core.c
index 6290332cfd3f..540d42cf6f4c 100644
--- a/drivers/iio/adc/stm32-dfsdm-core.c
+++ b/drivers/iio/adc/stm32-dfsdm-core.c
@@ -219,6 +219,11 @@ static int stm32_dfsdm_parse_of(struct platform_device *pdev,
}
priv->spi_clk_out_div = div_u64_rem(clk_freq, spi_freq, &rem) - 1;
+ if (!priv->spi_clk_out_div) {
+ /* spi_clk_out_div == 0 means ckout is OFF */
+ dev_err(&pdev->dev, "spi-max-frequency not achievable\n");
+ return -EINVAL;
+ }
priv->dfsdm.spi_master_freq = spi_freq;
if (rem) {