diff options
Diffstat (limited to 'common/cmd_sata.c')
-rw-r--r-- | common/cmd_sata.c | 22 |
1 files changed, 16 insertions, 6 deletions
diff --git a/common/cmd_sata.c b/common/cmd_sata.c index dd6f1d9..e849778 100644 --- a/common/cmd_sata.c +++ b/common/cmd_sata.c @@ -31,7 +31,7 @@ int curr_device = -1; block_dev_desc_t sata_dev_desc[CONFIG_SYS_SATA_MAX_DEVICE]; -int sata_initialize(void) +int __sata_initialize(void) { int rc; int i; @@ -55,6 +55,7 @@ int sata_initialize(void) curr_device = 0; return rc; } +int sata_initialize(void) __attribute__((weak,alias("__sata_initialize"))); block_dev_desc_t *sata_get_dev(int dev) { @@ -65,10 +66,18 @@ int do_sata(cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]) { int rc = 0; + if (argc == 2 && strcmp(argv[1], "init") == 0) + return sata_initialize(); + + /* If the user has not yet run `sata init`, do it now */ + if (curr_device == -1) + if (sata_initialize()) + return 1; + switch (argc) { case 0: case 1: - printf("Usage:\n%s\n", cmdtp->usage); + cmd_usage(cmdtp); return 1; case 2: if (strncmp(argv[1],"inf", 3) == 0) { @@ -106,7 +115,7 @@ int do_sata(cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]) } return rc; } - printf("Usage:\n%s\n", cmdtp->usage); + cmd_usage(cmdtp); return 1; case 3: if (strncmp(argv[1], "dev", 3) == 0) { @@ -138,7 +147,7 @@ int do_sata(cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]) } return rc; } - printf ("Usage:\n%s\n", cmdtp->usage); + cmd_usage(cmdtp); return 1; default: /* at least 4 args */ @@ -175,7 +184,7 @@ int do_sata(cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]) n, (n == cnt) ? "OK" : "ERROR"); return (n == cnt) ? 0 : 1; } else { - printf("Usage:\n%s\n", cmdtp->usage); + cmd_usage(cmdtp); rc = 1; } @@ -185,7 +194,8 @@ int do_sata(cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]) U_BOOT_CMD( sata, 5, 1, do_sata, - "sata - SATA sub system\n", + "SATA sub system", + "sata init - init SATA sub system\n" "sata info - show available SATA devices\n" "sata device [dev] - show or set current device\n" "sata part [dev] - print partition table\n" |