At present spi_flash_cmd_read_ops() allocates and frees a few bytes of
memory every time it is called. It is faster to use the stack for this
and this is now supported by the minimum GCC version required by U-Boot.
Remove the allocation and use a variable-sized array instead.
Signed-off-by: Simon Glass <sjg@chromium.org>
size_t len, void *data)
{
struct spi_slave *spi = flash->spi;
- u8 *cmd, cmdsz;
+ u8 cmdsz;
u32 remain_len, read_len, read_addr;
int bank_sel = 0;
int ret = -1;
}
cmdsz = SPI_FLASH_CMD_LEN + flash->dummy_byte;
- cmd = calloc(1, cmdsz);
- if (!cmd) {
- debug("SF: Failed to allocate cmd\n");
- return -ENOMEM;
- }
+ u8 cmd[cmdsz];
cmd[0] = flash->read_cmd;
while (len) {
ret = clean_bar(flash);
#endif
- free(cmd);
return ret;
}