Re: [PATCH 2/2] leds: Add support for rohm,bd65b60 led driver

From: Krzysztof Kozlowski
Date: Fri Mar 10 2023 - 05:49:04 EST


On 10/03/2023 11:44, Bogdan Ionescu wrote:
>>> + /* Check required properties */
>>> + if (!fwnode_property_present(child, "rohm,enable-outputs")) {
>>> + dev_err(dev, "No rohm,enable-outputs property found");
>>> + return -ENOENT;
>>> + }
>>> +
>>> + ret = fwnode_property_read_u32(child, "rohm,enable-outputs",
> &led->enable);
>>> + if (ret || (led->enable & LEDSEL_MASK) != led->enable) {
>>> + dev_err(dev, "Failed to read rohm,enable-outputs property");
>>
>> No need to check for properties twice...
>
> I understand that you can just check the return value, but what is then
> the point of the fwnode_property_present() function? Where is it otherwise
> supposed to be used?
>
> I am happy to remove the first check, but I would like to understand the
> reasoning behind it. I found value in separating a value not found error
> from an incorrect value error.

ENOENT is not valid code - No such file or directory. Thus you cannot
return different codes. The code should be simple and printing error on
fwnode_property_read_u32() is enough to report it to the developer.



Best regards,
Krzysztof