Simplify nand indentation.

Removes check covered by new nand_command_get_device_by_num helper.
Reverses logic of probe check to further reduce indentation.
__archive__
Zachary T Welch 2009-11-05 18:40:52 -08:00
parent ff61e6a37c
commit ca00483a95
1 changed files with 320 additions and 347 deletions

View File

@ -1135,10 +1135,12 @@ static int handle_nand_info_command(struct command_context_s *cmd_ctx, char *cmd
break;
}
if (p)
{
if (p->device)
if (NULL == p->device)
{
command_print(cmd_ctx, "#%s: not probed", args[0]);
return ERROR_OK;
}
if (first >= p->num_blocks)
first = p->num_blocks - 1;
@ -1174,12 +1176,6 @@ static int handle_nand_info_command(struct command_context_s *cmd_ctx, char *cmd
erase_state,
bad_state);
}
}
else
{
command_print(cmd_ctx, "#%s: not probed", args[0]);
}
}
return ERROR_OK;
}
@ -1196,8 +1192,6 @@ static int handle_nand_probe_command(struct command_context_s *cmd_ctx, char *cm
if (ERROR_OK != retval)
return retval;
if (p)
{
if ((retval = nand_probe(p)) == ERROR_OK)
{
command_print(cmd_ctx, "NAND flash device '%s' found", p->device->name);
@ -1210,7 +1204,6 @@ static int handle_nand_probe_command(struct command_context_s *cmd_ctx, char *cm
{
command_print(cmd_ctx, "unknown error when probing NAND flash device");
}
}
return ERROR_OK;
}
@ -1228,8 +1221,6 @@ static int handle_nand_erase_command(struct command_context_s *cmd_ctx, char *cm
if (ERROR_OK != retval)
return retval;
if (p)
{
unsigned long offset;
unsigned long length;
@ -1269,7 +1260,6 @@ static int handle_nand_erase_command(struct command_context_s *cmd_ctx, char *cm
{
command_print(cmd_ctx, "unknown error when erasing NAND flash device");
}
}
return ERROR_OK;
}
@ -1353,8 +1343,6 @@ static int handle_nand_write_command(struct command_context_s *cmd_ctx, char *cm
if (ERROR_OK != retval)
return retval;
if (p)
{
uint8_t *page = NULL;
uint32_t page_size = 0;
uint8_t *oob = NULL;
@ -1495,7 +1483,6 @@ static int handle_nand_write_command(struct command_context_s *cmd_ctx, char *cm
args[1], args[0], offset, duration_text);
free(duration_text);
duration_text = NULL;
}
return ERROR_OK;
}
@ -1512,14 +1499,15 @@ static int handle_nand_dump_command(struct command_context_s *cmd_ctx, char *cmd
if (ERROR_OK != retval)
return retval;
if (p)
{
if (p->device)
if (NULL == p->device)
{
command_print(cmd_ctx, "#%s: not probed", args[0]);
return ERROR_OK;
}
fileio_t fileio;
duration_t duration;
char *duration_text;
int retval;
uint8_t *page = NULL;
uint32_t page_size = 0;
@ -1612,12 +1600,6 @@ static int handle_nand_dump_command(struct command_context_s *cmd_ctx, char *cmd
command_print(cmd_ctx, "dumped %lld byte in %s", fileio.size, duration_text);
free(duration_text);
duration_text = NULL;
}
else
{
command_print(cmd_ctx, "#%s: not probed", args[0]);
}
}
return ERROR_OK;
}
@ -1634,33 +1616,24 @@ static int handle_nand_raw_access_command(struct command_context_s *cmd_ctx, cha
if (ERROR_OK != retval)
return retval;
if (p)
{
if (p->device)
if (NULL == p->device)
{
command_print(cmd_ctx, "#%s: not probed", args[0]);
return ERROR_OK;
}
if (argc == 2)
{
if (strcmp("enable", args[1]) == 0)
{
p->use_raw = 1;
}
else if (strcmp("disable", args[1]) == 0)
{
p->use_raw = 0;
}
else
{
return ERROR_COMMAND_SYNTAX_ERROR;
}
}
command_print(cmd_ctx, "raw access is %s", (p->use_raw) ? "enabled" : "disabled");
}
else
{
command_print(cmd_ctx, "#%s: not probed", args[0]);
}
}
const char *msg = p->use_raw ? "enabled" : "disabled";
command_print(cmd_ctx, "raw access is %s", msg);
return ERROR_OK;
}