mirror of
https://github.com/brain-hackers/u-boot-brain
synced 2024-06-09 23:36:03 +09:00
NAND: formatting cleanups from env.oob support
Change if (ok) { bunch of stuff } else { error } to if (error) { get out } proceed with bunch of stuff Plus a few whitespace cleanups. Signed-off-by: Scott Wood <scottwood@freescale.com>
This commit is contained in:
parent
c9f7351b5b
commit
53504a2789
|
@ -201,7 +201,7 @@ static void do_nand_status(nand_info_t *nand)
|
||||||
unsigned long nand_env_oob_offset;
|
unsigned long nand_env_oob_offset;
|
||||||
|
|
||||||
int do_nand_env_oob(cmd_tbl_t *cmdtp, nand_info_t *nand,
|
int do_nand_env_oob(cmd_tbl_t *cmdtp, nand_info_t *nand,
|
||||||
int argc, char * const argv[])
|
int argc, char * const argv[])
|
||||||
{
|
{
|
||||||
int ret;
|
int ret;
|
||||||
uint32_t oob_buf[ENV_OFFSET_SIZE/sizeof(uint32_t)];
|
uint32_t oob_buf[ENV_OFFSET_SIZE/sizeof(uint32_t)];
|
||||||
|
@ -210,10 +210,10 @@ int do_nand_env_oob(cmd_tbl_t *cmdtp, nand_info_t *nand,
|
||||||
|
|
||||||
if (!strcmp(cmd, "get")) {
|
if (!strcmp(cmd, "get")) {
|
||||||
ret = get_nand_env_oob(nand, &nand_env_oob_offset);
|
ret = get_nand_env_oob(nand, &nand_env_oob_offset);
|
||||||
if (!ret)
|
if (ret)
|
||||||
printf("0x%08lx\n", nand_env_oob_offset);
|
|
||||||
else
|
|
||||||
return 1;
|
return 1;
|
||||||
|
|
||||||
|
printf("0x%08lx\n", nand_env_oob_offset);
|
||||||
} else if (!strcmp(cmd, "set")) {
|
} else if (!strcmp(cmd, "set")) {
|
||||||
ulong addr;
|
ulong addr;
|
||||||
size_t dummy_size;
|
size_t dummy_size;
|
||||||
|
@ -222,17 +222,17 @@ int do_nand_env_oob(cmd_tbl_t *cmdtp, nand_info_t *nand,
|
||||||
if (argc < 3)
|
if (argc < 3)
|
||||||
goto usage;
|
goto usage;
|
||||||
|
|
||||||
if (arg_off_size(argc-2, argv + 2, nand, &addr,
|
if (arg_off_size(argc - 2, argv + 2, nand, &addr,
|
||||||
&dummy_size) < 0) {
|
&dummy_size) < 0) {
|
||||||
printf("Offset or partition name expected\n");
|
printf("Offset or partition name expected\n");
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (nand->oobavail < ENV_OFFSET_SIZE) {
|
if (nand->oobavail < ENV_OFFSET_SIZE) {
|
||||||
printf("Insufficient available OOB bytes: %d OOB bytes"
|
printf("Insufficient available OOB bytes:\n"
|
||||||
" available but %d required for env.oob support\n",
|
"%d OOB bytes available but %d required for "
|
||||||
nand->oobavail,
|
"env.oob support\n",
|
||||||
ENV_OFFSET_SIZE);
|
nand->oobavail, ENV_OFFSET_SIZE);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -251,23 +251,23 @@ int do_nand_env_oob(cmd_tbl_t *cmdtp, nand_info_t *nand,
|
||||||
oob_buf[1] = addr / nand->erasesize;
|
oob_buf[1] = addr / nand->erasesize;
|
||||||
|
|
||||||
ret = nand->write_oob(nand, ENV_OFFSET_SIZE, &ops);
|
ret = nand->write_oob(nand, ENV_OFFSET_SIZE, &ops);
|
||||||
if (!ret) {
|
if (ret) {
|
||||||
ret = get_nand_env_oob(nand, &nand_env_oob_offset);
|
|
||||||
if (ret) {
|
|
||||||
printf("Error reading env offset in OOB\n");
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (addr != nand_env_oob_offset) {
|
|
||||||
printf("Verification of env offset in OOB "
|
|
||||||
"failed: 0x%08lx expected but got "
|
|
||||||
"0x%08lx\n", addr, nand_env_oob_offset);
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
printf("Error writing OOB block 0\n");
|
printf("Error writing OOB block 0\n");
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ret = get_nand_env_oob(nand, &nand_env_oob_offset);
|
||||||
|
if (ret) {
|
||||||
|
printf("Error reading env offset in OOB\n");
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (addr != nand_env_oob_offset) {
|
||||||
|
printf("Verification of env offset in OOB failed: "
|
||||||
|
"0x%08lx expected but got 0x%08lx\n",
|
||||||
|
addr, nand_env_oob_offset);
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
goto usage;
|
goto usage;
|
||||||
}
|
}
|
||||||
|
@ -369,8 +369,10 @@ int do_nand(cmd_tbl_t * cmdtp, int flag, int argc, char * const argv[])
|
||||||
|
|
||||||
#ifdef CONFIG_ENV_OFFSET_OOB
|
#ifdef CONFIG_ENV_OFFSET_OOB
|
||||||
/* this command operates only on the first nand device */
|
/* this command operates only on the first nand device */
|
||||||
if (strcmp(cmd, "env.oob") == 0)
|
if (strcmp(cmd, "env.oob") == 0) {
|
||||||
return do_nand_env_oob(cmdtp, &nand_info[0], argc - 1, argv + 1);
|
return do_nand_env_oob(cmdtp, &nand_info[0],
|
||||||
|
argc - 1, argv + 1);
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* the following commands operate on the current device */
|
/* the following commands operate on the current device */
|
||||||
|
|
|
@ -299,23 +299,21 @@ int get_nand_env_oob(nand_info_t *nand, unsigned long *result)
|
||||||
ops.oobbuf = (void *) oob_buf;
|
ops.oobbuf = (void *) oob_buf;
|
||||||
|
|
||||||
ret = nand->read_oob(nand, ENV_OFFSET_SIZE, &ops);
|
ret = nand->read_oob(nand, ENV_OFFSET_SIZE, &ops);
|
||||||
|
if (ret) {
|
||||||
if (!ret) {
|
|
||||||
if (oob_buf[0] == ENV_OOB_MARKER) {
|
|
||||||
*result = oob_buf[1] * nand->erasesize;
|
|
||||||
} else if (oob_buf[0] == ENV_OOB_MARKER_OLD) {
|
|
||||||
*result = oob_buf[1];
|
|
||||||
} else {
|
|
||||||
printf("No dynamic environment marker in OOB block 0"
|
|
||||||
"\n");
|
|
||||||
ret = -ENOENT;
|
|
||||||
goto fail;
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
printf("error reading OOB block 0\n");
|
printf("error reading OOB block 0\n");
|
||||||
|
return ret;
|
||||||
}
|
}
|
||||||
fail:
|
|
||||||
return ret;
|
if (oob_buf[0] == ENV_OOB_MARKER) {
|
||||||
|
*result = oob_buf[1] * nand->erasesize;
|
||||||
|
} else if (oob_buf[0] == ENV_OOB_MARKER_OLD) {
|
||||||
|
*result = oob_buf[1];
|
||||||
|
} else {
|
||||||
|
printf("No dynamic environment marker in OOB block 0\n");
|
||||||
|
return -ENOENT;
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user