[U-Boot] [PATCH 3/5] net: sandbox: Convert sandbox mock eth driver to livetree
Simon Glass
sjg at chromium.org
Tue Jun 26 23:28:04 UTC 2018
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.
Reviewed-by: Simon Glass <sjg at chromium.org>
Regards,
Simon
More information about the U-Boot
mailing list