Commit 1b2a16ef authored by Marek Vasut's avatar Marek Vasut

mxssb: Clean up useless allocation in sb_tag_to_command()

The cmd allocation in sb_tag_to_command() is no longer needed.
It was needed temporarily for compatibility reasons during the
transition, but this is resolved now.
Signed-off-by: Marek Vasut's avatarMarek Vasut <marex@denx.de>
parent f4f3bcae
......@@ -348,14 +348,8 @@ static uint8_t sb_command_checksum(struct sb_command *inst)
}
static int sb_tag_to_command(struct sb_source_entry *src,
struct sb_command **rcmd)
struct sb_command *cmd)
{
struct sb_command *cmd;
cmd = calloc(1, sizeof(*cmd));
if (!cmd)
return -ENOMEM;
cmd->header.checksum = 0x5a;
cmd->header.tag = src->tag;
cmd->header.flags = src->flags;
......@@ -383,11 +377,9 @@ static int sb_tag_to_command(struct sb_source_entry *src,
goto unsupp;
}
*rcmd = cmd;
return 0;
unsupp:
free(cmd);
return -ENOTSUP;
}
......@@ -619,7 +611,6 @@ static int sb_parse_cmds(struct sb_section_ctx *sctx)
unsigned int insts = sb_get_boot_list_size(target_cpu);
uint32_t len = 0;
int ret;
struct sb_command *cmd;
while (insts--) {
cctx = calloc(1, sizeof(*cctx));
......@@ -629,14 +620,11 @@ static int sb_parse_cmds(struct sb_section_ctx *sctx)
if (!head)
head = cctx;
ret = sb_tag_to_command(src, &cmd);
ret = sb_tag_to_command(src, &cctx->payload);
if (ret)
goto err;
/* FIXME -- remove this useless allocation later. */
memcpy(&cctx->payload, cmd, sizeof(*cmd));
free(cmd);
len += sizeof(*cmd);
len += sizeof(struct sb_command);
/* FIXME -- this is where the file loading will happen. */
if (src->tag == ROM_LOAD_CMD) {
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment