From: Lukasz Majewski <l.majewski@samsung.com>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH] dfu: mmc: Replace calls to u-boot commands with native mmc API
Date: Mon, 17 Mar 2014 14:43:59 +0100 [thread overview]
Message-ID: <20140317144359.5f2bc729@amdc2363> (raw)
In-Reply-To: <1392967380-18842-1-git-send-email-l.majewski@samsung.com>
Hi Lukasz,
> 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 <l.majewski@samsung.com>
> ---
> 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 <errno.h>
> #include <div64.h>
> #include <dfu.h>
> +#include <mmc.h>
>
> 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)
Applied to u-boot-dfu.
--
Best regards,
Lukasz Majewski
Samsung R&D Institute Poland (SRPOL) | Linux Platform Group
prev parent reply other threads:[~2014-03-17 13:43 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-02-21 7:23 [U-Boot] [PATCH] dfu: mmc: Replace calls to u-boot commands with native mmc API Lukasz Majewski
2014-02-21 13:20 ` Pantelis Antoniou
2014-02-22 12:03 ` Lukasz Majewski
2014-02-27 8:36 ` Lukasz Majewski
2014-02-27 8:39 ` Pantelis Antoniou
2014-02-27 9:21 ` Lukasz Majewski
2014-02-27 9:22 ` Pantelis Antoniou
2014-03-06 12:08 ` Lukasz Majewski
2014-03-12 8:06 ` Lukasz Majewski
2014-03-12 10:12 ` Pantelis Antoniou
2014-03-12 11:12 ` Lukasz Majewski
2014-03-12 11:15 ` Pantelis Antoniou
2014-03-17 13:43 ` Lukasz Majewski [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20140317144359.5f2bc729@amdc2363 \
--to=l.majewski@samsung.com \
--cc=u-boot@lists.denx.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox