diff options
author | André Gustavo Nakagomi Lopez <andregnl@usp.br> | 2021-10-25 09:19:50 -0300 |
---|---|---|
committer | Jonathan Cameron <Jonathan.Cameron@huawei.com> | 2021-11-17 17:51:31 +0000 |
commit | 8eebe6281ac1062764db23d181e3feb3305a3690 (patch) | |
tree | 74eb8d30562aad6d182234baaa4f9b32e6e397c4 /drivers/iio/adc | |
parent | fa55b7dcdc43c1aa1ba12bca9d2dd4318c2a0dbf (diff) | |
download | linux-8eebe6281ac1062764db23d181e3feb3305a3690.tar.bz2 |
iio: adc: lpc18xx_adc: Reorder clk_get_rate() function call
clk_get_rate() is not guaranteed to work if called before
clk_prepare_enable().
Reorder clk_get_rate(), so it's called after clk_prepare_enable() and
after devm_add_action_or_reset() of lpc18xx_clk_disable().
Not that this is not a problem on this particular device, but it is
good to remove a case that might get copied elsewhere.
Suggested-by: Jonathan Cameron <jic23@kernel.org>
Acked-by: Vladimir Zapolskiy <vz@mleia.com>
Signed-off-by: André Gustavo Nakagomi Lopez <andregnl@usp.br>
Link: https://lore.kernel.org/r/YXag5l4xBkGQH3tq@Andryuu.br
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Diffstat (limited to 'drivers/iio/adc')
-rw-r--r-- | drivers/iio/adc/lpc18xx_adc.c | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/drivers/iio/adc/lpc18xx_adc.c b/drivers/iio/adc/lpc18xx_adc.c index ceefa4d793cf..ae9c9384f23e 100644 --- a/drivers/iio/adc/lpc18xx_adc.c +++ b/drivers/iio/adc/lpc18xx_adc.c @@ -157,9 +157,6 @@ static int lpc18xx_adc_probe(struct platform_device *pdev) return dev_err_probe(&pdev->dev, PTR_ERR(adc->clk), "error getting clock\n"); - rate = clk_get_rate(adc->clk); - clkdiv = DIV_ROUND_UP(rate, LPC18XX_ADC_CLK_TARGET); - adc->vref = devm_regulator_get(&pdev->dev, "vref"); if (IS_ERR(adc->vref)) return dev_err_probe(&pdev->dev, PTR_ERR(adc->vref), @@ -192,6 +189,9 @@ static int lpc18xx_adc_probe(struct platform_device *pdev) if (ret) return ret; + rate = clk_get_rate(adc->clk); + clkdiv = DIV_ROUND_UP(rate, LPC18XX_ADC_CLK_TARGET); + adc->cr_reg = (clkdiv << LPC18XX_ADC_CR_CLKDIV_SHIFT) | LPC18XX_ADC_CR_PDN; writel(adc->cr_reg, adc->base + LPC18XX_ADC_CR); |