mirror of
https://github.com/Fishwaldo/u-boot.git
synced 2025-03-19 05:31:32 +00:00
mmc: use block layer in mmc command
Call blk_dread, blk_dwrite, blk_derase to ensure that the block cache is used if enabled and to remove build breakage when CONFIG_BLK is enabled. Signed-off-by: Eric Nelson <eric@nelint.com> Reviewed-by: Tom Rini <trini@konsulko.com>
This commit is contained in:
parent
e40cf34a29
commit
bcfde7ffb0
1 changed files with 4 additions and 3 deletions
|
@ -150,6 +150,7 @@ static struct mmc *init_mmc_device(int dev, bool force_init)
|
||||||
printf("no mmc device at slot %x\n", dev);
|
printf("no mmc device at slot %x\n", dev);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (force_init)
|
if (force_init)
|
||||||
mmc->has_init = 0;
|
mmc->has_init = 0;
|
||||||
if (mmc_init(mmc))
|
if (mmc_init(mmc))
|
||||||
|
@ -345,7 +346,7 @@ static int do_mmc_read(cmd_tbl_t *cmdtp, int flag,
|
||||||
printf("\nMMC read: dev # %d, block # %d, count %d ... ",
|
printf("\nMMC read: dev # %d, block # %d, count %d ... ",
|
||||||
curr_device, blk, cnt);
|
curr_device, blk, cnt);
|
||||||
|
|
||||||
n = mmc->block_dev.block_read(&mmc->block_dev, blk, cnt, addr);
|
n = blk_dread(&mmc->block_dev, blk, cnt, addr);
|
||||||
/* flush cache after read */
|
/* flush cache after read */
|
||||||
flush_cache((ulong)addr, cnt * 512); /* FIXME */
|
flush_cache((ulong)addr, cnt * 512); /* FIXME */
|
||||||
printf("%d blocks read: %s\n", n, (n == cnt) ? "OK" : "ERROR");
|
printf("%d blocks read: %s\n", n, (n == cnt) ? "OK" : "ERROR");
|
||||||
|
@ -377,7 +378,7 @@ static int do_mmc_write(cmd_tbl_t *cmdtp, int flag,
|
||||||
printf("Error: card is write protected!\n");
|
printf("Error: card is write protected!\n");
|
||||||
return CMD_RET_FAILURE;
|
return CMD_RET_FAILURE;
|
||||||
}
|
}
|
||||||
n = mmc->block_dev.block_write(&mmc->block_dev, blk, cnt, addr);
|
n = blk_dwrite(&mmc->block_dev, blk, cnt, addr);
|
||||||
printf("%d blocks written: %s\n", n, (n == cnt) ? "OK" : "ERROR");
|
printf("%d blocks written: %s\n", n, (n == cnt) ? "OK" : "ERROR");
|
||||||
|
|
||||||
return (n == cnt) ? CMD_RET_SUCCESS : CMD_RET_FAILURE;
|
return (n == cnt) ? CMD_RET_SUCCESS : CMD_RET_FAILURE;
|
||||||
|
@ -405,7 +406,7 @@ static int do_mmc_erase(cmd_tbl_t *cmdtp, int flag,
|
||||||
printf("Error: card is write protected!\n");
|
printf("Error: card is write protected!\n");
|
||||||
return CMD_RET_FAILURE;
|
return CMD_RET_FAILURE;
|
||||||
}
|
}
|
||||||
n = mmc->block_dev.block_erase(&mmc->block_dev, blk, cnt);
|
n = blk_derase(&mmc->block_dev, blk, cnt);
|
||||||
printf("%d blocks erased: %s\n", n, (n == cnt) ? "OK" : "ERROR");
|
printf("%d blocks erased: %s\n", n, (n == cnt) ? "OK" : "ERROR");
|
||||||
|
|
||||||
return (n == cnt) ? CMD_RET_SUCCESS : CMD_RET_FAILURE;
|
return (n == cnt) ? CMD_RET_SUCCESS : CMD_RET_FAILURE;
|
||||||
|
|
Loading…
Add table
Reference in a new issue