Re: [PATCH] gnss: ubx: Use devm_regulator_get_enable_optional()
From: Johan Hovold
Date: Tue Jun 20 2023 - 04:59:13 EST
On Sat, Jun 17, 2023 at 12:01:22PM +0200, Christophe JAILLET wrote:
> Use devm_regulator_get_enable_optional() instead of hand writing it. It
> saves some line of code.
>
> Signed-off-by: Christophe JAILLET <christophe.jaillet@xxxxxxxxxx>
> ---
> - data->v_bckp = devm_regulator_get_optional(&serdev->dev, "v-bckp");
> - if (IS_ERR(data->v_bckp)) {
> - ret = PTR_ERR(data->v_bckp);
> - if (ret == -ENODEV)
> - data->v_bckp = NULL;
> - else
> - goto err_free_gserial;
> - }
> -
> - if (data->v_bckp) {
> - ret = regulator_enable(data->v_bckp);
> - if (ret)
> - goto err_free_gserial;
> - }
> + ret = devm_regulator_get_enable_optional(&serdev->dev, "v-bckp");
> + if (ret)
> + goto err_free_gserial;
Same here, this breaks the driver as -ENODEV is returned when the
optional resource is not present.
Johan