]> git.dujemihanovic.xyz Git - u-boot.git/commitdiff
net: smc911x: Replace malloc()+memset() with calloc()
authorMarek Vasut <marek.vasut+renesas@gmail.com>
Sun, 15 Mar 2020 14:14:18 +0000 (15:14 +0100)
committermarex <marex@desktop.lan>
Fri, 1 May 2020 10:35:21 +0000 (12:35 +0200)
Replace combination of malloc()+memset() with calloc() as the behavior
is exactly the same and the amount of code is reduced.

Signed-off-by: Marek Vasut <marek.vasut+renesas@gmail.com>
Cc: Joe Hershberger <joe.hershberger@ni.com>
Cc: Masahiro Yamada <yamada.masahiro@socionext.com>
drivers/net/smc911x.c

index 24b4eaeb3fdd828e777885b99fbf316674e58df0..2c72e3469d59bcb29152b3955124cdf1b0da9513 100644 (file)
@@ -242,11 +242,9 @@ int smc911x_initialize(u8 dev_num, int base_addr)
        unsigned long addrl, addrh;
        struct eth_device *dev;
 
-       dev = malloc(sizeof(*dev));
-       if (!dev) {
-               return -1;
-       }
-       memset(dev, 0, sizeof(*dev));
+       dev = calloc(1, sizeof(*dev));
+       if (!dev)
+               return -ENOMEM;
 
        dev->iobase = base_addr;