net: ks8851: Replace malloc()+memset() with calloc()
authorMarek Vasut <marex@denx.de>
Wed, 25 Mar 2020 15:52:38 +0000 (16:52 +0100)
committerMarek Vasut <marex@denx.de>
Fri, 22 May 2020 17:46:45 +0000 (19:46 +0200)
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>
drivers/net/ks8851_mll.c

index 6643d1e9c134a6db3cfb807bb80fd8b523120a94..51113a89819516d14bf28d4ad65aa896fcab1733 100644 (file)
@@ -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;