All of lore.kernel.org
 help / color / mirror / Atom feed
From: Scott Wood <scottwood@freescale.com>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH] [DFU] Implement NAND dfu support
Date: Mon, 10 Dec 2012 19:09:55 -0600	[thread overview]
Message-ID: <1355188195.5334.24@snotra> (raw)
In-Reply-To: <1355153072-6047-1-git-send-email-panto@antoniou-consulting.com> (from panto@antoniou-consulting.com on Mon Dec 10 09:24:32 2012)

On 12/10/2012 09:24:32 AM, Pantelis Antoniou wrote:
> Introduce on-the fly DFU NAND support.
> 
> Signed-off-by: Pantelis Antoniou <panto@antoniou-consulting.com>
> ---
>  drivers/dfu/Makefile   |   1 +
>  drivers/dfu/dfu.c      |   7 ++
>  drivers/dfu/dfu_nand.c | 194  
> +++++++++++++++++++++++++++++++++++++++++++++++++
>  include/dfu.h          |  23 ++++++
>  4 files changed, 225 insertions(+)
>  create mode 100644 drivers/dfu/dfu_nand.c

What is DFU?  I don't see anything in README or doc/, despite there  
already being CONFIG symbols for it.

> +static int nand_block_op(enum dfu_nand_op op, struct dfu_entity *dfu,
> +			u64 offset, void *buf, long *len)
> +{
> +	char cmd_buf[DFU_CMD_BUF_SIZE];
> +	u64 start, count;
> +	int ret;
> +	int dev;
> +	loff_t actual;
> +
> +	/* if buf == NULL return total size of the area */
> +	if (buf == NULL) {
> +		*len = dfu->data.nand.size;
> +		return 0;
> +	}
> +
> +	start = dfu->data.nand.start + offset + dfu->bad_skip;
> +	count = *len;
> +	if (start + count >
> +			dfu->data.nand.start + dfu->data.nand.size) {
> +		printf("%s: block_op out of bounds\n", __func__);
> +		return -1;
> +	}
> +	dev = nand_curr_device;
> +	if (dev < 0 || dev >= CONFIG_SYS_MAX_NAND_DEVICE ||
> +		!nand_info[dev].name) {
> +		printf("%s: invalid nand device\n", __func__);
> +		return -1;
> +	}
> +
> +	sprintf(cmd_buf, "nand %s %p %llx %llx",
> +		op == DFU_OP_READ ? "read" : "write",
> +		 buf, start, count);
> +
> +	debug("%s: %s 0x%p\n", __func__, cmd_buf, cmd_buf);
> +	ret = run_command(cmd_buf, 0);

Why not use the C interface to NAND?

> +	/* find out how much actual bytes have been written */
> +	/* the difference is the amount of skip we must add from now on  
> */
> +	actual = nand_extent_skip_bad(&nand_info[dev], start, count);

...especially since you already need to interact with it here?

-Scott

  reply	other threads:[~2012-12-11  1:09 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-12-10 15:24 [U-Boot] [PATCH] [DFU] Implement NAND dfu support Pantelis Antoniou
2012-12-11  1:09 ` Scott Wood [this message]
2012-12-11  1:16   ` Tom Rini
2012-12-11 22:24     ` Scott Wood
2012-12-11 22:40       ` Tom Rini
2012-12-11  7:56   ` Lukasz Majewski
2012-12-11 22:23     ` Scott Wood
2012-12-12  8:35       ` Lukasz Majewski
2012-12-11  9:38   ` Pantelis Antoniou

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=1355188195.5334.24@snotra \
    --to=scottwood@freescale.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.