return 0;
}
-static int do_bcb_load(struct cmd_tbl *cmdtp, int flag, int argc,
- char *const argv[])
+static int __bcb_load(int devnum, const char *partp)
{
struct blk_desc *desc;
struct disk_partition info;
char *endp;
int part, ret;
- ret = blk_get_device_by_str("mmc", argv[1], &desc);
- if (ret < 0)
+ desc = blk_get_devnum_by_type(IF_TYPE_MMC, devnum);
+ if (!desc) {
+ ret = -ENODEV;
goto err_read_fail;
+ }
- part = simple_strtoul(argv[2], &endp, 0);
+ part = simple_strtoul(partp, &endp, 0);
if (*endp == '\0') {
ret = part_get_info(desc, part, &info);
if (ret)
goto err_read_fail;
} else {
- part = part_get_info_by_name(desc, argv[2], &info);
+ part = part_get_info_by_name(desc, partp, &info);
if (part < 0) {
ret = part;
goto err_read_fail;
return CMD_RET_SUCCESS;
err_read_fail:
- printf("Error: mmc %s:%s read failed (%d)\n", argv[1], argv[2], ret);
+ printf("Error: mmc %d:%s read failed (%d)\n", devnum, partp, ret);
goto err;
err_too_small:
- printf("Error: mmc %s:%s too small!", argv[1], argv[2]);
+ printf("Error: mmc %d:%s too small!", devnum, partp);
goto err;
err:
bcb_dev = -1;
return CMD_RET_FAILURE;
}
+static int do_bcb_load(struct cmd_tbl *cmdtp, int flag, int argc,
+ char * const argv[])
+{
+ char *endp;
+ int devnum = simple_strtoul(argv[1], &endp, 0);
+
+ if (*endp != '\0') {
+ printf("Error: Device id '%s' not a number\n", argv[1]);
+ return CMD_RET_FAILURE;
+ }
+
+ return __bcb_load(devnum, argv[2]);
+}
+
static int do_bcb_set(struct cmd_tbl *cmdtp, int flag, int argc,
char *const argv[])
{