Re: [PATCH 09/10] regulator: s5m8767: Let core handle GPIO descriptors

From: Charles Keepax
Date: Wed Nov 28 2018 - 10:17:22 EST


On Wed, Nov 28, 2018 at 11:43:49AM +0100, Linus Walleij wrote:
> Use the gpiod_get_from_of_node() rather than the devm_*
> version so that the regulator core can handle the lifecycle
> of these descriptors.
>
> Introduce an errorpath so we free any retrieved descriptors
> properly.
>
> This patch requires "gpio: Export gpiod_get_from_of_node()"
> to be applied first.
>
> Fixes: 9ae5cc75ceaa ("regulator: s5m8767: Pass descriptor instead of GPIO number")
> Signed-off-by: Linus Walleij <linus.walleij@xxxxxxxxxx>
> ---
> drivers/regulator/s5m8767.c | 37 ++++++++++++++++++++++++++-----------
> 1 file changed, 26 insertions(+), 11 deletions(-)
> @@ -674,6 +681,14 @@ static int s5m8767_pmic_dt_parse_pdata(struct platform_device *pdev,
> }
>
> return 0;
> +
> +err_gpiod_put:
> + while (j) {
> + gpiod_put(rdata->ext_control_gpiod);
> + rdata--;
> + j--;
> + }
> + return ret;
> }

These looks like it handles the error paths in
s5m8767_pmic_dt_parse_pdata, however there are still all the
error paths between the call to that function and the call to
regulator_register that need to be handled as well.

Thanks,
Charles