aboutsummaryrefslogtreecommitdiffstats
path: root/common
diff options
context:
space:
mode:
authorStephen Warren2013-04-01 06:50:28 -0500
committerTom Rini2013-04-02 15:23:35 -0500
commit9fd383724cf49b5fd787c62169569d870857d611 (patch)
tree825f0847e12e13140ab6b9723d579379f0d0f1e0 /common
parent5993053fa42706b289a08f3661a9c00096158981 (diff)
downloadu-boot-9fd383724cf49b5fd787c62169569d870857d611.tar.gz
u-boot-9fd383724cf49b5fd787c62169569d870857d611.tar.xz
u-boot-9fd383724cf49b5fd787c62169569d870857d611.zip
mmc: don't allow extra cmdline arguments
The "mmc rescan" command takes no arguments. However, executing "mmc rescan 1" succeeds, leading the user to believe that MMC device 1 has been rescanned. In fact, the "current" MMC device has been rescanned, and the current device may well not be 1. Add error-checking to the "mmc" command to explicitly reject any extra command-line arguments so that it's more obvious when U-Boot isn't doing what the user thought they asked it to. Signed-off-by: Stephen Warren <swarren@nvidia.com>
Diffstat (limited to 'common')
-rw-r--r--common/cmd_mmc.c14
1 files changed, 12 insertions, 2 deletions
diff --git a/common/cmd_mmc.c b/common/cmd_mmc.c
index 8c53a10315..9f3d6c575b 100644
--- a/common/cmd_mmc.c
+++ b/common/cmd_mmc.c
@@ -164,8 +164,12 @@ static int do_mmcops(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
164 } 164 }
165 165
166 if (strcmp(argv[1], "rescan") == 0) { 166 if (strcmp(argv[1], "rescan") == 0) {
167 struct mmc *mmc = find_mmc_device(curr_device); 167 struct mmc *mmc;
168 168
169 if (argc != 2)
170 return CMD_RET_USAGE;
171
172 mmc = find_mmc_device(curr_device);
169 if (!mmc) { 173 if (!mmc) {
170 printf("no mmc device at slot %x\n", curr_device); 174 printf("no mmc device at slot %x\n", curr_device);
171 return 1; 175 return 1;
@@ -179,8 +183,12 @@ static int do_mmcops(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
179 return 0; 183 return 0;
180 } else if (strncmp(argv[1], "part", 4) == 0) { 184 } else if (strncmp(argv[1], "part", 4) == 0) {
181 block_dev_desc_t *mmc_dev; 185 block_dev_desc_t *mmc_dev;
182 struct mmc *mmc = find_mmc_device(curr_device); 186 struct mmc *mmc;
187
188 if (argc != 2)
189 return CMD_RET_USAGE;
183 190
191 mmc = find_mmc_device(curr_device);
184 if (!mmc) { 192 if (!mmc) {
185 printf("no mmc device at slot %x\n", curr_device); 193 printf("no mmc device at slot %x\n", curr_device);
186 return 1; 194 return 1;
@@ -196,6 +204,8 @@ static int do_mmcops(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
196 puts("get mmc type error!\n"); 204 puts("get mmc type error!\n");
197 return 1; 205 return 1;
198 } else if (strcmp(argv[1], "list") == 0) { 206 } else if (strcmp(argv[1], "list") == 0) {
207 if (argc != 2)
208 return CMD_RET_USAGE;
199 print_mmc_devices('\n'); 209 print_mmc_devices('\n');
200 return 0; 210 return 0;
201 } else if (strcmp(argv[1], "dev") == 0) { 211 } else if (strcmp(argv[1], "dev") == 0) {