[U-Boot] [PATCH] net: zynq_gem: Return 0 on success, not -ENOSYS
Olliver Schinagl
oliver at schinagl.nl
Mon Nov 28 11:41:46 CET 2016
On 28-11-16 08:22, Michal Simek wrote:
> On 25.11.2016 16:41, Olliver Schinagl wrote:
>> The .read_rom_hwaddr net_ops hook does not check the return value, which
>> is why it was never caught that we are currently returning 0 if the
>> read_rom_hwaddr function return -ENOSYS and -ENOSYS otherwise.
>>
>> In this case we can simplify this by just returning the result of the
>> function.
>>
>> Signed-off-by: Olliver Schinagl <oliver at schinagl.nl>
>> ---
>> drivers/net/zynq_gem.c | 8 +++-----
>> 1 file changed, 3 insertions(+), 5 deletions(-)
>>
>> diff --git a/drivers/net/zynq_gem.c b/drivers/net/zynq_gem.c
>> index 8b7c1be..04a3fd4 100644
>> --- a/drivers/net/zynq_gem.c
>> +++ b/drivers/net/zynq_gem.c
>> @@ -593,14 +593,12 @@ __weak int zynq_board_read_rom_ethaddr(unsigned char *ethaddr)
>>
>> static int zynq_gem_read_rom_mac(struct udevice *dev)
>> {
>> - int retval;
>> struct eth_pdata *pdata = dev_get_platdata(dev);
>>
>> - retval = zynq_board_read_rom_ethaddr(pdata->enetaddr);
>> - if (retval == -ENOSYS)
>> - retval = 0;
>> + if (!dev)
>> + return -ENOSYS;
>>
>> - return retval;
>> + return zynq_board_read_rom_ethaddr(pdata->enetaddr);
>> }
>>
>> static int zynq_gem_miiphy_read(struct mii_dev *bus, int addr,
>>
> Not a problem with the patch above but I hope to get rid of this whole
> function by using MAC reading from eeprom.
Yeah I agree, once the eeprom bit has matured, this could (in your case
for your board) be dropped.
>
> Also board specific functions should return error value when read is not
> possible.
As an unwritten rule you mean? I think the intention is that
*_board_read_rom_hwaddr returns 0 on success < 0 on error.
>
> Acked-by: Michal Simek <michal.simek at xilinx.com>
>
> Thanks,
> Michal
>
More information about the U-Boot
mailing list