Commit 4004912e authored by Uwe Kleine-König's avatar Uwe Kleine-König Committed by Jonathan Cameron

iio: adc: lpc18xx: Benefit from devm_clk_get_enabled() to simplify

Make use of devm_clk_get_enabled() to replace some code that effectively
open codes this new function.
Reviewed-by: default avatarAndy Shevchenko <andy.shevchenko@gmail.com>
Signed-off-by: default avatarUwe Kleine-König <u.kleine-koenig@pengutronix.de>
Link: https://lore.kernel.org/r/20220808204740.307667-5-u.kleine-koenig@pengutronix.deSigned-off-by: default avatarJonathan Cameron <Jonathan.Cameron@huawei.com>
parent 51f2f910
...@@ -121,11 +121,6 @@ static void lpc18xx_clear_cr_reg(void *data) ...@@ -121,11 +121,6 @@ static void lpc18xx_clear_cr_reg(void *data)
writel(0, adc->base + LPC18XX_ADC_CR); writel(0, adc->base + LPC18XX_ADC_CR);
} }
static void lpc18xx_clk_disable(void *clk)
{
clk_disable_unprepare(clk);
}
static void lpc18xx_regulator_disable(void *vref) static void lpc18xx_regulator_disable(void *vref)
{ {
regulator_disable(vref); regulator_disable(vref);
...@@ -151,7 +146,7 @@ static int lpc18xx_adc_probe(struct platform_device *pdev) ...@@ -151,7 +146,7 @@ static int lpc18xx_adc_probe(struct platform_device *pdev)
if (IS_ERR(adc->base)) if (IS_ERR(adc->base))
return PTR_ERR(adc->base); return PTR_ERR(adc->base);
adc->clk = devm_clk_get(&pdev->dev, NULL); adc->clk = devm_clk_get_enabled(&pdev->dev, NULL);
if (IS_ERR(adc->clk)) if (IS_ERR(adc->clk))
return dev_err_probe(&pdev->dev, PTR_ERR(adc->clk), return dev_err_probe(&pdev->dev, PTR_ERR(adc->clk),
"error getting clock\n"); "error getting clock\n");
...@@ -177,17 +172,6 @@ static int lpc18xx_adc_probe(struct platform_device *pdev) ...@@ -177,17 +172,6 @@ static int lpc18xx_adc_probe(struct platform_device *pdev)
if (ret) if (ret)
return ret; return ret;
ret = clk_prepare_enable(adc->clk);
if (ret) {
dev_err(&pdev->dev, "unable to enable clock\n");
return ret;
}
ret = devm_add_action_or_reset(&pdev->dev, lpc18xx_clk_disable,
adc->clk);
if (ret)
return ret;
rate = clk_get_rate(adc->clk); rate = clk_get_rate(adc->clk);
clkdiv = DIV_ROUND_UP(rate, LPC18XX_ADC_CLK_TARGET); clkdiv = DIV_ROUND_UP(rate, LPC18XX_ADC_CLK_TARGET);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment