summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJagannadha Sutradharudu Teki <jagannadha.sutradharudu-teki@xilinx.com>2014-02-04 21:36:13 +0530
committerJagannadha Sutradharudu Teki <jaganna@xilinx.com>2014-03-17 21:54:57 +0530
commitc6136aad91da493c446f22af8f5d774a74dec9d1 (patch)
tree197d355b9d0c44e977a9eb9d865239dd666c6978
parentcc56f13392197d6195ec6df2569bec1ce4d7b9ce (diff)
downloadu-boot-imx-c6136aad91da493c446f22af8f5d774a74dec9d1.zip
u-boot-imx-c6136aad91da493c446f22af8f5d774a74dec9d1.tar.gz
u-boot-imx-c6136aad91da493c446f22af8f5d774a74dec9d1.tar.bz2
sf: ops: Squash the malloc+memset combo
Squash the malloc()+memset() combo in favor of calloc(). Signed-off-by: Jagannadha Sutradharudu Teki <jaganna@xilinx.com> Acked-by: Marek Vasut <marex@denx.de>
-rw-r--r--drivers/mtd/spi/sf_ops.c8
1 files changed, 6 insertions, 2 deletions
diff --git a/drivers/mtd/spi/sf_ops.c b/drivers/mtd/spi/sf_ops.c
index 1f1bb36..ef91b92 100644
--- a/drivers/mtd/spi/sf_ops.c
+++ b/drivers/mtd/spi/sf_ops.c
@@ -9,6 +9,7 @@
*/
#include <common.h>
+#include <errno.h>
#include <malloc.h>
#include <spi.h>
#include <spi_flash.h>
@@ -381,8 +382,11 @@ int spi_flash_cmd_read_ops(struct spi_flash *flash, u32 offset,
}
cmdsz = SPI_FLASH_CMD_LEN + flash->dummy_byte;
- cmd = malloc(cmdsz);
- memset(cmd, 0, cmdsz);
+ cmd = calloc(1, cmdsz);
+ if (!cmd) {
+ debug("SF: Failed to allocate cmd\n");
+ return -ENOMEM;
+ }
cmd[0] = flash->read_cmd;
while (len) {