On Mon, 8 Aug 2022 22:47:32 +0200 Uwe Kleine-König <u.kleine-koenig@xxxxxxxxxxxxxx> wrote: > Make use of devm_clk_get_enabled() to replace some code that effectively > open codes this new function. > > Reviewed-by: Andy Shevchenko <andy.shevchenko@xxxxxxxxx> > Signed-off-by: Uwe Kleine-König <u.kleine-koenig@xxxxxxxxxxxxxx> This makes me very slightly nervous because it juggles the order of clock enabling and powering up the device (potentially anyway). It's always possible that will cause problems - though I think it is unlikely (and would cause all sorts of problems if someone used a fixed regulator or clock) to I'm applying this anyway. > --- > drivers/iio/adc/lpc18xx_adc.c | 18 +----------------- > 1 file changed, 1 insertion(+), 17 deletions(-) > > diff --git a/drivers/iio/adc/lpc18xx_adc.c b/drivers/iio/adc/lpc18xx_adc.c > index ae9c9384f23e..8bbc18aaa474 100644 > --- a/drivers/iio/adc/lpc18xx_adc.c > +++ b/drivers/iio/adc/lpc18xx_adc.c > @@ -122,11 +122,6 @@ static void lpc18xx_clear_cr_reg(void *data) > 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) > { > regulator_disable(vref); > @@ -152,7 +147,7 @@ static int lpc18xx_adc_probe(struct platform_device *pdev) > if (IS_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)) > return dev_err_probe(&pdev->dev, PTR_ERR(adc->clk), > "error getting clock\n"); > @@ -178,17 +173,6 @@ static int lpc18xx_adc_probe(struct platform_device *pdev) > if (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); > clkdiv = DIV_ROUND_UP(rate, LPC18XX_ADC_CLK_TARGET); >