mirror of
https://github.com/AsahiLinux/u-boot
synced 2024-09-21 15:12:04 +00:00
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>
This commit is contained in:
parent
cc56f13392
commit
c6136aad91
1 changed files with 6 additions and 2 deletions
|
@ -9,6 +9,7 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <common.h>
|
#include <common.h>
|
||||||
|
#include <errno.h>
|
||||||
#include <malloc.h>
|
#include <malloc.h>
|
||||||
#include <spi.h>
|
#include <spi.h>
|
||||||
#include <spi_flash.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;
|
cmdsz = SPI_FLASH_CMD_LEN + flash->dummy_byte;
|
||||||
cmd = malloc(cmdsz);
|
cmd = calloc(1, cmdsz);
|
||||||
memset(cmd, 0, cmdsz);
|
if (!cmd) {
|
||||||
|
debug("SF: Failed to allocate cmd\n");
|
||||||
|
return -ENOMEM;
|
||||||
|
}
|
||||||
|
|
||||||
cmd[0] = flash->read_cmd;
|
cmd[0] = flash->read_cmd;
|
||||||
while (len) {
|
while (len) {
|
||||||
|
|
Loading…
Reference in a new issue