summaryrefslogtreecommitdiff
path: root/drivers/dfu/dfu_mmc.c
diff options
context:
space:
mode:
authorStephen Warren <swarren@nvidia.com>2014-06-11 16:03:33 -0600
committerTom Rini <trini@ti.com>2014-08-09 11:16:58 -0400
commitdd64827eb60de9f71b1a1d6aecf488104cdd7b96 (patch)
treee4d46c84e1d4b118a284261213eb5cc3db9ea4eb /drivers/dfu/dfu_mmc.c
parent3ee9593fce0b58124e667734d7bc8d44b11a7be2 (diff)
dfu: defer parsing of device string to IO backend
Devices are not all identified by a single integer. To support this, defer the parsing of the device string to the IO backed, so that it can apply the appropriate rules. SPI devices are specified as controller:chip_select. SPI/SF support will be added soon. MMC devices can also be specified as controller[.hwpart][:partition] in many commands, although we don't support that syntax in DFU. Signed-off-by: Stephen Warren <swarren@nvidia.com>
Diffstat (limited to 'drivers/dfu/dfu_mmc.c')
-rw-r--r--drivers/dfu/dfu_mmc.c21
1 files changed, 12 insertions, 9 deletions
diff --git a/drivers/dfu/dfu_mmc.c b/drivers/dfu/dfu_mmc.c
index 322bd8c5d2d..72fa03eedae 100644
--- a/drivers/dfu/dfu_mmc.c
+++ b/drivers/dfu/dfu_mmc.c
@@ -27,7 +27,7 @@ static int mmc_access_part(struct dfu_entity *dfu, struct mmc *mmc, int part)
if (part == mmc->part_num)
return 0;
- ret = mmc_switch_part(dfu->dev_num, part);
+ ret = mmc_switch_part(dfu->data.mmc.dev_num, part);
if (ret) {
error("Cannot switch to partition %d\n", part);
return ret;
@@ -40,7 +40,7 @@ static int mmc_access_part(struct dfu_entity *dfu, struct mmc *mmc, int part)
static int mmc_block_op(enum dfu_op op, struct dfu_entity *dfu,
u64 offset, void *buf, long *len)
{
- struct mmc *mmc = find_mmc_device(dfu->dev_num);
+ struct mmc *mmc = find_mmc_device(dfu->data.mmc.dev_num);
u32 blk_start, blk_count, n = 0;
int ret, part_num_bkp = 0;
@@ -67,15 +67,15 @@ static int mmc_block_op(enum dfu_op op, struct dfu_entity *dfu,
}
debug("%s: %s dev: %d start: %d cnt: %d buf: 0x%p\n", __func__,
- op == DFU_OP_READ ? "MMC READ" : "MMC WRITE", dfu->dev_num,
- blk_start, blk_count, buf);
+ op == DFU_OP_READ ? "MMC READ" : "MMC WRITE",
+ dfu->data.mmc.dev_num, blk_start, blk_count, buf);
switch (op) {
case DFU_OP_READ:
- n = mmc->block_dev.block_read(dfu->dev_num, blk_start,
+ n = mmc->block_dev.block_read(dfu->data.mmc.dev_num, blk_start,
blk_count, buf);
break;
case DFU_OP_WRITE:
- n = mmc->block_dev.block_write(dfu->dev_num, blk_start,
+ n = mmc->block_dev.block_write(dfu->data.mmc.dev_num, blk_start,
blk_count, buf);
break;
default:
@@ -270,7 +270,7 @@ int dfu_read_medium_mmc(struct dfu_entity *dfu, u64 offset, void *buf,
* 4th (optional):
* mmcpart <num> (access to HW eMMC partitions)
*/
-int dfu_fill_entity_mmc(struct dfu_entity *dfu, char *s)
+int dfu_fill_entity_mmc(struct dfu_entity *dfu, char *devstr, char *s)
{
const char *entity_type;
size_t second_arg;
@@ -281,6 +281,8 @@ int dfu_fill_entity_mmc(struct dfu_entity *dfu, char *s)
const char *argv[3];
const char **parg = argv;
+ dfu->data.mmc.dev_num = simple_strtoul(devstr, NULL, 10);
+
for (; parg < argv + sizeof(argv) / sizeof(*argv); ++parg) {
*parg = strsep(&s, " ");
if (*parg == NULL) {
@@ -297,9 +299,10 @@ int dfu_fill_entity_mmc(struct dfu_entity *dfu, char *s)
second_arg = simple_strtoul(argv[1], NULL, 0);
third_arg = simple_strtoul(argv[2], NULL, 0);
- mmc = find_mmc_device(dfu->dev_num);
+ mmc = find_mmc_device(dfu->data.mmc.dev_num);
if (mmc == NULL) {
- error("Couldn't find MMC device no. %d.\n", dfu->dev_num);
+ error("Couldn't find MMC device no. %d.\n",
+ dfu->data.mmc.dev_num);
return -ENODEV;
}