diff options
author | Marek Vasut <marex@denx.de> | 2020-03-25 16:52:38 +0100 |
---|---|---|
committer | Marek Vasut <marex@denx.de> | 2020-05-22 19:46:45 +0200 |
commit | e3b54cda6893726703a1fae66e9521bc231464cf (patch) | |
tree | 1dc2fb0ab8cdbf87a452a511f0002dd61610cd0f /drivers/net/ks8851_mll.c | |
parent | 2fa581ba910368d0f7f995fb906d6c5e4218b594 (diff) |
net: ks8851: Replace malloc()+memset() with calloc()
Replace combination of malloc()+memset() with calloc() as the behavior
is exactly the same and the amount of code is reduced. Moreover, remove
printf() in the fail path, as it is useless, and return proper -ENOMEM
return code.
Signed-off-by: Marek Vasut <marex@denx.de>
Cc: Eugen Hristev <eugen.hristev@microchip.com>
Cc: Joe Hershberger <joe.hershberger@ni.com>
Diffstat (limited to 'drivers/net/ks8851_mll.c')
-rw-r--r-- | drivers/net/ks8851_mll.c | 9 |
1 files changed, 3 insertions, 6 deletions
diff --git a/drivers/net/ks8851_mll.c b/drivers/net/ks8851_mll.c index 6643d1e9c13..51113a89819 100644 --- a/drivers/net/ks8851_mll.c +++ b/drivers/net/ks8851_mll.c @@ -604,12 +604,9 @@ int ks8851_mll_initialize(u8 dev_num, int base_addr) { struct eth_device *dev; - dev = malloc(sizeof(*dev)); - if (!dev) { - printf("Error: Failed to allocate memory\n"); - return -1; - } - memset(dev, 0, sizeof(*dev)); + dev = calloc(1, sizeof(*dev)); + if (!dev) + return -ENOMEM; dev->iobase = base_addr; |