[U-Boot] [PATCH v7 75/87] mtd: spi-nor: Not required to memset dummy byte

Jagan Teki jteki at openedev.com
Tue Mar 22 08:38:27 CET 2016


Dummy byte(s) are need to send followed by address opcode
for read operation, and that dummy byte(s) not required
to malloc as well memset.

Cc: Simon Glass <sjg at chromium.org>
Cc: Bin Meng <bmeng.cn at gmail.com>
Cc: Mugunthan V N <mugunthanvnm at ti.com>
Cc: Michal Simek <michal.simek at xilinx.com>
Cc: Siva Durga Prasad Paladugu <sivadur at xilinx.com>
Signed-off-by: Jagan Teki <jteki at openedev.com>
---
 drivers/mtd/spi-nor/spi-nor.c | 9 +--------
 1 file changed, 1 insertion(+), 8 deletions(-)

diff --git a/drivers/mtd/spi-nor/spi-nor.c b/drivers/mtd/spi-nor/spi-nor.c
index befee67..97f5eaa 100644
--- a/drivers/mtd/spi-nor/spi-nor.c
+++ b/drivers/mtd/spi-nor/spi-nor.c
@@ -617,7 +617,7 @@ static int spi_nor_read(struct mtd_info *mtd, loff_t from, size_t len,
 {
 	struct spi_nor *nor = mtd->priv;
 	u32 remain_len, read_len, read_addr;
-	u8 *cmd, cmdsz;
+	u8 cmd[SNOR_MAX_CMD_SIZE], cmdsz;
 	int bank_sel = 0;
 	int ret = -1;
 
@@ -633,12 +633,6 @@ static int spi_nor_read(struct mtd_info *mtd, loff_t from, size_t len,
 	}
 
 	cmdsz = SNOR_MAX_CMD_SIZE + nor->read_dummy;
-	cmd = calloc(1, cmdsz);
-	if (!cmd) {
-		debug("spi-nor: Failed to allocate cmd\n");
-		return -ENOMEM;
-	}
-
 	cmd[0] = nor->read_opcode;
 	while (len) {
 		read_addr = from;
@@ -672,7 +666,6 @@ static int spi_nor_read(struct mtd_info *mtd, loff_t from, size_t len,
 		*retlen += read_len;
 	}
 
-	free(cmd);
 	return ret;
 }
 
-- 
1.9.1



More information about the U-Boot mailing list