On Mon, 8 Aug 2022 22:47:33 +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 might have side effects as it now enables the clock before calling the clk_set_rate(). Also changes the clock start up ordering. Neither is that scary a change, but on really fussy hardware they might cause problems. Add a few rock-chips people who have sent patches in last few years to hopefully take a look or even better run a test. Thanks, Jonathan > --- > drivers/iio/adc/rockchip_saradc.c | 44 ++----------------------------- > 1 file changed, 2 insertions(+), 42 deletions(-) > > diff --git a/drivers/iio/adc/rockchip_saradc.c b/drivers/iio/adc/rockchip_saradc.c > index b87ea7148b58..db1190faa223 100644 > --- a/drivers/iio/adc/rockchip_saradc.c > +++ b/drivers/iio/adc/rockchip_saradc.c > @@ -233,20 +233,6 @@ static void rockchip_saradc_reset_controller(struct reset_control *reset) > reset_control_deassert(reset); > } > > -static void rockchip_saradc_clk_disable(void *data) > -{ > - struct rockchip_saradc *info = data; > - > - clk_disable_unprepare(info->clk); > -} > - > -static void rockchip_saradc_pclk_disable(void *data) > -{ > - struct rockchip_saradc *info = data; > - > - clk_disable_unprepare(info->pclk); > -} > - > static void rockchip_saradc_regulator_disable(void *data) > { > struct rockchip_saradc *info = data; > @@ -380,12 +366,12 @@ static int rockchip_saradc_probe(struct platform_device *pdev) > return ret; > } > > - info->pclk = devm_clk_get(&pdev->dev, "apb_pclk"); > + info->pclk = devm_clk_get_enabled(&pdev->dev, "apb_pclk"); > if (IS_ERR(info->pclk)) > return dev_err_probe(&pdev->dev, PTR_ERR(info->pclk), > "failed to get pclk\n"); > > - info->clk = devm_clk_get(&pdev->dev, "saradc"); > + info->clk = devm_clk_get_enabled(&pdev->dev, "saradc"); > if (IS_ERR(info->clk)) > return dev_err_probe(&pdev->dev, PTR_ERR(info->clk), > "failed to get adc clock\n"); > @@ -427,32 +413,6 @@ static int rockchip_saradc_probe(struct platform_device *pdev) > > info->uv_vref = ret; > > - ret = clk_prepare_enable(info->pclk); > - if (ret < 0) { > - dev_err(&pdev->dev, "failed to enable pclk\n"); > - return ret; > - } > - ret = devm_add_action_or_reset(&pdev->dev, > - rockchip_saradc_pclk_disable, info); > - if (ret) { > - dev_err(&pdev->dev, "failed to register devm action, %d\n", > - ret); > - return ret; > - } > - > - ret = clk_prepare_enable(info->clk); > - if (ret < 0) { > - dev_err(&pdev->dev, "failed to enable converter clock\n"); > - return ret; > - } > - ret = devm_add_action_or_reset(&pdev->dev, > - rockchip_saradc_clk_disable, info); > - if (ret) { > - dev_err(&pdev->dev, "failed to register devm action, %d\n", > - ret); > - return ret; > - } > - > platform_set_drvdata(pdev, indio_dev); > > indio_dev->name = dev_name(&pdev->dev);