[U-Boot] [PATCH 04/69] syscon: Avoid returning a device on failure

Simon Glass sjg at chromium.org
Sat Mar 12 06:04:22 CET 2016


Hi Bin,

On 10 March 2016 at 20:28, Bin Meng <bmeng.cn at gmail.com> wrote:
> Hi Simon,
>
> On Mon, Mar 7, 2016 at 10:27 AM, Simon Glass <sjg at chromium.org> wrote:
>> If the device cannot be probed, syscon_get_by_driver_data() will still
>> return a useful value in its devp parameter. Ensure that it returns NULL
>> instead.
>
> Shouldn't this be the caller's bug, that caller must check the return value?

Yes but it is confusing to return a valid device and also return an
error. I'm trying to make the function cleaner.

>
>>
>> Signed-off-by: Simon Glass <sjg at chromium.org>
>> ---
>>
>>  drivers/core/syscon-uclass.c | 1 +
>>  1 file changed, 1 insertion(+)
>>
>> diff --git a/drivers/core/syscon-uclass.c b/drivers/core/syscon-uclass.c
>> index a0666d0..e03f46a 100644
>> --- a/drivers/core/syscon-uclass.c
>> +++ b/drivers/core/syscon-uclass.c
>> @@ -38,6 +38,7 @@ int syscon_get_by_driver_data(ulong driver_data, struct udevice **devp)
>>         struct uclass *uc;
>>         int ret;
>>
>> +       *devp = NULL;
>>         ret = uclass_get(UCLASS_SYSCON, &uc);
>>         if (ret)
>>                 return ret;
>> --
>
> Regards,
> Bin

Regards,
Simon


More information about the U-Boot mailing list