[U-Boot] [PATCH v2 3/3] dm: core: Add uclass_first/next_device_check()
Mario Six
mario.six at gdsys.cc
Fri Jun 9 05:49:56 UTC 2017
Hi Simon,
On Fri, Jun 9, 2017 at 12:41 AM, Simon Glass <sjg at chromium.org> wrote:
> Hi,
>
> On 23 April 2017 at 20:10, Simon Glass <sjg at chromium.org> wrote:
>> Sometimes it is useful to iterate through all devices in a uclass and
>> skip over those which do not work correctly (e.g fail to probe). Add two
>> new functions to provide this feature.
>>
>> The caller must check the return value each time to make sure that the
>> device is valid. But the device pointer is always returned.
>>
>> Signed-off-by: Simon Glass <sjg at chromium.org>
>> ---
>>
>> Changes in v2:
>> - Return even device, even those with errors
>> - Rename the functions
>>
>> drivers/core/uclass.c | 27 +++++++++++++++++
>> include/dm/uclass.h | 31 ++++++++++++++++++++
>> test/dm/test-fdt.c | 80 +++++++++++++++++++++++++++++++++++++++++++++++++++
>> 3 files changed, 138 insertions(+)
>
>
> This patch has been sitting around for a while. Does anyone think it is useful?
>
> Regards,
> Simon
> _______________________________________________
I actually made a patch for one of our boards with two functions that have the
same semantics in our repository (just named uclass_{first,next}_device_skip).
The background is that on this board we have a network interface controlled by
an FPGA and another interface controlled by the SoC. The problem I faced was
that when the interfaces were brought up in net/eth-uclass.c the FPGA was not
yet running, hence the probe of the FPGA's network interface (which came first)
failed. But since the process then stopped there, the SoC's interface was not
activated either, which left the board without a network connection (which
would be a problem in production).
Aside from that, I think there are many use cases where the "skipping behavior"
would be prudent. For example in the gpio command: if any of the GPIO
controllers fail to probe for some reason, then "gpio st -a" will stop at this
particular controller, and won't show the state of any other controllers.
So, in conclusion, yes, I think it would be a nice addition.
Best regards,
Mario
More information about the U-Boot
mailing list