Re: [PATCH 2/2] leds: ktd2692: Make aux-gpios optional
From: Andy Shevchenko
Date: Fri Apr 08 2022 - 07:08:48 EST
On Thu, Apr 7, 2022 at 1:33 PM Markuss Broks <markuss.broks@xxxxxxxxx> wrote:
>
> Make the AUX pin optional, since it isn't a core part of functionality,
> and the device is designed to be operational with only one CTRL pin.
>
> Also pick up maintainership for the LED driver and the yaml bindings.
maintenance?
...
> - gpiod_direction_output(led->aux_gpio, KTD2692_LOW);
> + if (led->aux_gpio)
> + gpiod_direction_output(led->aux_gpio, KTD2692_LOW);
Redundant change.
...
> - gpiod_direction_output(led->aux_gpio, KTD2692_HIGH);
> + if (led->aux_gpio)
> + gpiod_direction_output(led->aux_gpio, KTD2692_HIGH);
Ditto.
...
> - gpiod_direction_output(led->aux_gpio, KTD2692_LOW);
> + if (led->aux_gpio)
> + gpiod_direction_output(led->aux_gpio, KTD2692_LOW);
Ditto.
...
> - gpiod_direction_output(led->aux_gpio, KTD2692_LOW);
> + if (led->aux_gpio)
> + gpiod_direction_output(led->aux_gpio, KTD2692_LOW);
Ditto.
...
> ret = PTR_ERR_OR_ZERO(led->aux_gpio);
> - if (ret) {
> - dev_err(dev, "cannot get aux-gpios %d\n", ret);
> - return ret;
> - }
> + if (ret)
> + dev_info(dev, "aux-gpios not available, flash mode current might be reduced\n");
dev_warn()?
After this change the use of PTR_ERR_OR_ZERO() becomes unjustified, what about
if (IS_ERR(led->aux_gpio))
?
But the problem here is the ignorance of important error codes, such a
deferred probe.
What you need is to switch to devm_gpiod_get_optional().
--
With Best Regards,
Andy Shevchenko