
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@chromium.org Cc: Bin Meng bmeng.cn@gmail.com Cc: Mugunthan V N mugunthanvnm@ti.com Cc: Michal Simek michal.simek@xilinx.com Cc: Siva Durga Prasad Paladugu sivadur@xilinx.com Signed-off-by: Jagan Teki jteki@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; }