[U-Boot] [PATCH 3/5] net: sandbox: Convert sandbox mock eth driver to livetree

Joe Hershberger joe.hershberger at ni.com
Wed Jun 27 00:29:23 UTC 2018


On Tue, Jun 26, 2018 at 6:28 PM, Simon Glass <sjg at chromium.org> wrote:
> Hi Joe,
>
> On 26 June 2018 at 16:25, Joe Hershberger <joe.hershberger at ni.com> wrote:
>> Hi Simon,
>>
>> On Tue, Jun 26, 2018 at 6:18 PM, Simon Glass <sjg at chromium.org> wrote:
>>> Hi Joe,
>>>
>>> On 26 June 2018 at 14:19, Joe Hershberger <joe.hershberger at ni.com> wrote:
>>>> Use the dev_ functions to access DT properties.
>>>>
>>>> Also correct the reading of the fake MAC address. The format from the DT
>>>> is u32s, so to accurately read the MAC from the DT, we need to cast each
>>>> value to a u8.
>>>>
>>>> Signed-off-by: Joe Hershberger <joe.hershberger at ni.com>
>>>> ---
>>>>
>>>>  drivers/net/sandbox.c | 15 +++++++++++----
>>>>  1 file changed, 11 insertions(+), 4 deletions(-)
>>>>
>>>> diff --git a/drivers/net/sandbox.c b/drivers/net/sandbox.c
>>>> index b34712bd06..d5a30c05b8 100644
>>>> --- a/drivers/net/sandbox.c
>>>> +++ b/drivers/net/sandbox.c
>>>> @@ -56,13 +56,20 @@ void sandbox_eth_skip_timeout(void)
>>>>  static int sb_eth_start(struct udevice *dev)
>>>>  {
>>>>         struct eth_sandbox_priv *priv = dev_get_priv(dev);
>>>> +       /* The DT integers are 32-bits */
>>>> +       const u32 mac[ARP_HLEN];
>>>>
>>>>         debug("eth_sandbox: Start\n");
>>>>
>>>> -       fdtdec_get_byte_array(gd->fdt_blob, dev_of_offset(dev),
>>>> -                             "fake-host-hwaddr", priv->fake_host_hwaddr,
>>>> -                             ARP_HLEN);
>>>> +       if (dev_read_u32_array(dev, "fake-host-hwaddr", mac, ARP_HLEN)) {
>>>> +               printf("'fake-host-hwaddr' is missing from the DT\n");
>>>> +               return -EINVAL;
>>>> +       }
>>>
>>> This is not equivalent  - I think you need a dev_read_u8_array() or similar.
>>
>> Yes, I know it's not equivalent... I noted that in the commit log.
>> This is fixing a bug too.
>
> Yes I see that, but I didn't realise there was a bug in the code.

OK, turns out this is the result of an inconsistency in the dts files,
and should actually be able to be u8s.

I'll correct it for v2.

> Reviewed-by: Simon Glass <sjg at chromium.org>
>
> Regards,
> Simon
> _______________________________________________
> U-Boot mailing list
> U-Boot at lists.denx.de
> https://lists.denx.de/listinfo/u-boot


More information about the U-Boot mailing list