Re: [PATCH v5 4/9] iio: adc: mcp3911: use resource-managed version of iio_device_register

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Tue, Aug 9, 2022 at 9:32 AM Marcus Folkesson
<marcus.folkesson@xxxxxxxxx> wrote:
>
> Keep using managed resources as much as possible.

...

> +static void mcp3911_cleanup_clock(void *_adc)
> +{
> +       struct mcp3911 *adc = _adc;
> +       clk_disable_unprepare(adc->clki);
> +}

You may rather switch to devm_clk_get_enabled() and drop this.

...

>                         dev_err(&adc->spi->dev,
>                                 "failed to get adc clk (%ld)\n",
>                                 PTR_ERR(adc->clki));
> -                       ret = PTR_ERR(adc->clki);
> -                       goto reg_disable;
> +                       return PTR_ERR(adc->clki);
>                 }
>         } else {
>                 ret = clk_prepare_enable(adc->clki);
>                 if (ret < 0) {
>                         dev_err(&adc->spi->dev,
>                                 "Failed to enable clki: %d\n", ret);
> -                       goto reg_disable;
> +                       return ret;
>                 }
> +
> +               ret = devm_add_action_or_reset(&spi->dev,
> +                               mcp3911_cleanup_clock, adc);
> +               if (ret)
> +                       return ret;
>         }

As per above.

-- 
With Best Regards,
Andy Shevchenko



[Index of Archives]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Input]     [Linux Kernel]     [Linux SCSI]     [X.org]

  Powered by Linux