From mboxrd@z Thu Jan 1 00:00:00 1970 From: Lukasz Majewski Date: Sat, 22 Feb 2014 13:03:35 +0100 Subject: [U-Boot] [PATCH] dfu: mmc: Replace calls to u-boot commands with native mmc API In-Reply-To: <0C4AF804-EDB6-46DE-BEDE-D77221AA3FB5@antoniou-consulting.com> References: <1392967380-18842-1-git-send-email-l.majewski@samsung.com> <0C4AF804-EDB6-46DE-BEDE-D77221AA3FB5@antoniou-consulting.com> Message-ID: <20140222130335.529f73e4@jawa> List-Id: MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: u-boot@lists.denx.de Hi Pantelis, > Hi Lukasz, > > Looks fine to me. > Let me run a few tests over the weekend I was wondering if we could share tests for DFU? Will it be suitable to put it in the ./test/dfu? > and I'll > apply. > > Thanks > > -- Pantelis > > On Feb 21, 2014, at 9:23 AM, Lukasz Majewski wrote: > > > For some time we have been using the run_command() with properly > > crafted string. Such approach turned to be unreliable and error > > prone. > > > > Switch to "native" mmc subsystem API would allow better type > > checking and shall improve speed. > > > > Also, it seems that this API is changing less often than u-boot > > commands. The approach similar to env operations on the eMMC has > > been reused. > > > > Signed-off-by: Lukasz Majewski > > --- > > drivers/dfu/dfu_mmc.c | 31 ++++++++++++++++++++++++------- > > 1 file changed, 24 insertions(+), 7 deletions(-) > > > > diff --git a/drivers/dfu/dfu_mmc.c b/drivers/dfu/dfu_mmc.c > > index 0816f46..651cfff 100644 > > --- a/drivers/dfu/dfu_mmc.c > > +++ b/drivers/dfu/dfu_mmc.c > > @@ -12,6 +12,7 @@ > > #include > > #include > > #include > > +#include > > > > static unsigned char __aligned(CONFIG_SYS_CACHELINE_SIZE) > > dfu_file_buf[CONFIG_SYS_DFU_MAX_FILE_SIZE]; > > @@ -20,8 +21,8 @@ static long dfu_file_buf_len; > > static int mmc_block_op(enum dfu_op op, struct dfu_entity *dfu, > > u64 offset, void *buf, long *len) > > { > > - char cmd_buf[DFU_CMD_BUF_SIZE]; > > - u32 blk_start, blk_count; > > + struct mmc *mmc = find_mmc_device(dfu->dev_num); > > + u32 blk_start, blk_count, n = 0; > > > > /* > > * We must ensure that we work in lba_blk_size chunks, so > > ALIGN @@ -38,12 +39,28 @@ static int mmc_block_op(enum dfu_op op, > > struct dfu_entity *dfu, return -EINVAL; > > } > > > > - sprintf(cmd_buf, "mmc %s %p %x %x", > > - op == DFU_OP_READ ? "read" : "write", > > - buf, blk_start, blk_count); > > + 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); > > + switch (op) { > > + case DFU_OP_READ: > > + n = mmc->block_dev.block_read(dfu->dev_num, > > blk_start, > > + blk_count, buf); > > + break; > > + case DFU_OP_WRITE: > > + n = mmc->block_dev.block_write(dfu->dev_num, > > blk_start, > > + blk_count, buf); > > + break; > > + default: > > + error("Operation not supported\n"); > > + } > > > > - debug("%s: %s 0x%p\n", __func__, cmd_buf, cmd_buf); > > - return run_command(cmd_buf, 0); > > + if (n != blk_count) { > > + error("MMC operation failed"); > > + return -EIO; > > + } > > + > > + return 0; > > } > > > > static int mmc_file_buffer(struct dfu_entity *dfu, void *buf, long > > *len) -- > > 1.7.10.4 > > > -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 198 bytes Desc: not available URL: