Re: [bug report] mfd: lp87565: Handle optional reset pin

Luca Ceresoli
2021-11-18T12:46:04Z

Hi,

On 18/11/21 11:40, Dan Carpenter wrote:
> On Thu, Nov 18, 2021 at 10:22:52AM +0100, Luca Ceresoli wrote:
>>
>> As the author of the code to blame, I wrote this patch, but just needed
>> a little time to test it before sending:
>>
>> lp87565->reset_gpio = devm_gpiod_get_optional(lp87565->dev, "reset",
>> GPIOD_OUT_LOW);
>> if (IS_ERR(lp87565->reset_gpio))
>> return dev_err_probe(lp87565->dev, PTR_ERR(lp87565->reset_gpio),
>> "Failed getting reset GPIO");
>>
>> if (lp87565->reset_gpio) {
>> ...
>>
>> I prefer to exit on any error as it would be either -EPROBE_DEFER of a
>> _real_ error (e.g. GPIO already in use). If there's no GPIO specified,
>> then devm_gpiod_get_optional() returns NULL and libgpio ignores NULL
>> pointers gracefully.
>>
>> Would that work?
>
> I generally prefer that as well, because to me optional means it's up to
> the user not that it's up to the kernel. But it depends on if the
> system can boot without it etc...
>
> I guess in this case we know that no one was relying on the old behavior
> because that would have crashed so returning errors is safe.

I sent a patch using this approach. I hope it's OK, otherwise I can send
a v2.

Last but not least: thanks Dan for finding and reporting!

--
Luca