All of lore.kernel.org
 help / color / mirror / Atom feed
From: Lukasz Majewski <l.majewski@samsung.com>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH] dfu:mmc: When doing block operations, operate on the given length
Date: Fri, 08 Mar 2013 16:41:22 +0100	[thread overview]
Message-ID: <20130308164122.6ffe5599@amdc308.digital.local> (raw)
In-Reply-To: <1362666344-21856-1-git-send-email-trini@ti.com>

Hi Tom,

> When working on RAW partitions, it's possible that the whole area
> is larger than DDR.  So what we need to do is make sure that the
> length we are given is aligned with the LBA block size, then pass
> that length in as our count of LBA blocks to operate on.  In doing
> this, we no longer need to modify *len on read operations.
> 
> Cc: Lukasz Majewski <l.majewski@samsung.com>
> Signed-off-by: Tom Rini <trini@ti.com>
> ---
>  drivers/dfu/dfu_mmc.c |   21 ++++++++++++++-------
>  1 file changed, 14 insertions(+), 7 deletions(-)
> 
> diff --git a/drivers/dfu/dfu_mmc.c b/drivers/dfu/dfu_mmc.c
> index 083d745..0bed405 100644
> --- a/drivers/dfu/dfu_mmc.c
> +++ b/drivers/dfu/dfu_mmc.c
> @@ -34,14 +34,21 @@ static int mmc_block_op(enum dfu_mmc_op op,
> struct dfu_entity *dfu, {
>  	char cmd_buf[DFU_CMD_BUF_SIZE];
>  
> -	sprintf(cmd_buf, "mmc %s 0x%x %x %x",
> -		op == DFU_OP_READ ? "read" : "write",
> -		(unsigned int) buf,
> -		dfu->data.mmc.lba_start,
> -		dfu->data.mmc.lba_size);
> +	/*
> +	 * We must ensure that we read in lba_blk_size chunks, so
> ALIGN
> +	 * this value.
> +	 */
> +	*len = ALIGN(*len, dfu->data.mmc.lba_blk_size);
> +
> +	if (*len > (dfu->data.mmc.lba_size *
> dfu->data.mmc.lba_blk_size)) {
> +		puts("Request would exceed designated area!\n");
> +		return -EINVAL;
> +	}
>  
> -	if (op == DFU_OP_READ)
> -		*len = dfu->data.mmc.lba_blk_size *
> dfu->data.mmc.lba_size;
> +	sprintf(cmd_buf, "mmc %s 0x%x %x %lx",
> +		op == DFU_OP_READ ? "read" : "write",
> +		(unsigned int) buf, dfu->data.mmc.lba_start,
> +		*len / dfu->data.mmc.lba_blk_size);
>  
>  	debug("%s: %s 0x%p\n", __func__, cmd_buf, cmd_buf);
>  	return run_command(cmd_buf, 0);

Acked-by: Lukasz Majewski <l.majewski@samsung.com>

Tested-at: TRATS (Exynos4210)
Tested-by: Lukasz Majewski <l.majewski@samsung.com>


-- 
Best regards,

Lukasz Majewski

Samsung R&D Poland (SRPOL) | Linux Platform Group

      parent reply	other threads:[~2013-03-08 15:41 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-03-07 14:25 [U-Boot] [PATCH] dfu:mmc: When doing block operations, operate on the given length Tom Rini
2013-03-07 23:19 ` Michael Cashwell
2013-03-07 23:33   ` Tom Rini
2013-03-08  0:14     ` Michael Cashwell
2013-03-08 15:06 ` Tom Rini
2013-03-08 15:41 ` 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=20130308164122.6ffe5599@amdc308.digital.local \
    --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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.