public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
* [PATCH 01/12] net: ks8851: Replace malloc()+memset() with calloc()
@ 2020-03-25 18:44 Marek Vasut
  2020-03-25 18:44 ` [PATCH 02/12] net: ks8851: Remove RXQCR cache Marek Vasut
                   ` (12 more replies)
  0 siblings, 13 replies; 14+ messages in thread
From: Marek Vasut @ 2020-03-25 18:44 UTC (permalink / raw)
  To: u-boot

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 | 9 +++------
 1 file changed, 3 insertions(+), 6 deletions(-)

diff --git a/drivers/net/ks8851_mll.c b/drivers/net/ks8851_mll.c
index 718a7dd019..4386763bac 100644
--- a/drivers/net/ks8851_mll.c
+++ b/drivers/net/ks8851_mll.c
@@ -602,12 +602,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;
 
-- 
2.25.1

^ permalink raw reply related	[flat|nested] 14+ messages in thread

end of thread, other threads:[~2020-04-16 13:57 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2020-03-25 18:44 [PATCH 01/12] net: ks8851: Replace malloc()+memset() with calloc() Marek Vasut
2020-03-25 18:44 ` [PATCH 02/12] net: ks8851: Remove RXQCR cache Marek Vasut
2020-03-25 18:44 ` [PATCH 03/12] net: ks8851: Use 16bit RXQCR access Marek Vasut
2020-03-25 18:44 ` [PATCH 04/12] net: ks8851: Trim down struct ks_net Marek Vasut
2020-03-25 18:44 ` [PATCH 05/12] net: ks8851: Remove type_frame_head Marek Vasut
2020-03-25 18:44 ` [PATCH 06/12] net: ks8851: Clean up chip ID readout Marek Vasut
2020-03-25 18:44 ` [PATCH 07/12] net: ks8851: Checkpatch cleanup Marek Vasut
2020-03-25 18:44 ` [PATCH 08/12] net: ks8851: Pass around driver private data Marek Vasut
2020-03-25 18:44 ` [PATCH 09/12] net: ks8851: Split non-DM specific bits from common code Marek Vasut
2020-03-25 18:44 ` [PATCH 10/12] net: ks8851: Receive one packet per recv call Marek Vasut
2020-03-25 18:45 ` [PATCH 11/12] net: ks8851: Add DM support Marek Vasut
2020-03-25 18:45 ` [PATCH 12/12] net: ks8851: Add Kconfig entries Marek Vasut
2020-04-16 13:06 ` [PATCH 01/12] net: ks8851: Replace malloc()+memset() with calloc() Marek Vasut
2020-04-16 13:57 ` Joe Hershberger

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox