From patchwork Wed Mar 25 15:36:37 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marek Vasut X-Patchwork-Id: 244249 List-Id: U-Boot discussion From: marek.vasut at gmail.com (Marek Vasut) Date: Wed, 25 Mar 2020 16:36:37 +0100 Subject: [PATCH V3 02/13] net: smc911x: Replace malloc()+memset() with calloc() In-Reply-To: <20200325153648.99993-1-marek.vasut+renesas@gmail.com> References: <20200325153648.99993-1-marek.vasut+renesas@gmail.com> Message-ID: <20200325153648.99993-3-marek.vasut+renesas@gmail.com> 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 Cc: Joe Hershberger Cc: Masahiro Yamada --- V2: - Use kzalloc() - Return -ENOMEM on alloc fail V3: - Switch back to calloc(), it's not worth pulling in all the linux-compatibility complexity --- drivers/net/smc911x.c | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/drivers/net/smc911x.c b/drivers/net/smc911x.c index 24b4eaeb3f..2c72e3469d 100644 --- a/drivers/net/smc911x.c +++ b/drivers/net/smc911x.c @@ -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;