public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
From: Marek Vasut <marex@denx.de>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH 7/9] Add a partition type target
Date: Wed, 28 Nov 2012 10:22:20 +0100	[thread overview]
Message-ID: <201211281022.20345.marex@denx.de> (raw)
In-Reply-To: <12C58391-97C6-4E7E-9437-BDB9504BFA20@antoniou-consulting.com>

Dear Pantelis Antoniou,

> Hi Marek,
> 
> On Nov 28, 2012, at 4:48 AM, Marek Vasut wrote:
> > Dear Pantelis Antoniou,
> > 
> >> Dealing with raw block numbers with the dfu is very annoying.
> >> Introduce a partition method.
> >> 
> >> Signed-off-by: Pantelis Antoniou <panto@antoniou-consulting.com>
> >> ---
> >> drivers/dfu/dfu_mmc.c | 29 +++++++++++++++++++++++++++++
> >> 1 file changed, 29 insertions(+)
> >> 
> >> diff --git a/drivers/dfu/dfu_mmc.c b/drivers/dfu/dfu_mmc.c
> >> index 5d504df..3733b21 100644
> >> --- a/drivers/dfu/dfu_mmc.c
> >> +++ b/drivers/dfu/dfu_mmc.c
> >> @@ -153,6 +153,10 @@ int dfu_read_medium_mmc(struct dfu_entity *dfu,
> >> void *buf, long *len)
> >> 
> >> int dfu_fill_entity_mmc(struct dfu_entity *dfu, char *s)
> >> {
> >> +	int dev, part;
> >> +	struct mmc *mmc;
> >> +	block_dev_desc_t *blk_dev;
> >> +	disk_partition_t partinfo;
> >> 
> >> 	char *st;
> >> 	
> >> 	dfu->dev_type = DFU_DEV_MMC;
> >> 
> >> @@ -166,8 +170,33 @@ int dfu_fill_entity_mmc(struct dfu_entity *dfu,
> >> char *s) dfu->layout = DFU_FS_FAT;
> >> 
> >> 	} else if (!strcmp(st, "ext4")) {
> >> 	
> >> 		dfu->layout = DFU_FS_EXT4;
> >> 
> >> +	} else if (!strcmp(st, "part")) {
> >> +
> >> +		dfu->layout = DFU_RAW_ADDR;
> >> +
> >> +		dev = simple_strtoul(s, &s, 10);
> >> +		part = simple_strtoul(++s, &s, 10);
> > 
> > ++s ... this is unreadable and definitelly prone to breakage.
> 
> Just following what the existing code does. Look around this line.
> Perhaps we should modify that too.

Yes, that'd be really nice ... but in a separate patch please.

> >> +
> >> +		mmc = find_mmc_device(dev);
> >> +		if (mmc == NULL || mmc_init(mmc)) {
> >> +			printf("%s: could not find mmc device #%d!\n", __func__,
> > 
> > dev);
> > 
> >> +			return -1;
> >> +		}
> >> +
> >> +		blk_dev = &mmc->block_dev;
> >> +		if (get_partition_info(blk_dev, part, &partinfo) != 0) {
> >> +			printf("%s: could not find partition #%d on mmc device
> > 
> > #%d!\n",
> > 
> >> +					__func__, part, dev);
> >> +			return -1;
> > 
> > Try using regular errno.h ... fix all around.
> 
> The whole file doesn't use errno.h at all. Changing this single thing will
> stick out like a sore thumb.

:-(

> >> +		}
> >> +
> >> +		dfu->data.mmc.lba_start = partinfo.start;
> >> +		dfu->data.mmc.lba_size = partinfo.size;
> >> +		dfu->data.mmc.lba_blk_size = partinfo.blksz;
> >> +
> >> 
> >> 	} else {
> >> 	
> >> 		printf("%s: Memory layout (%s) not supported!\n", __func__, st);
> >> 
> >> +		return -1;
> > 
> > This is new ... does it fit into this patch at all?
> 
> It should, it's an error condition and the code just blindly continued.

Even more :-((

> >> 	}
> >> 	
> >> 	if (dfu->layout == DFU_FS_EXT4 || dfu->layout == DFU_FS_FAT) {
> > 
> > Best regards,
> > Marek Vasut
> 
> Regards
> 
> -- Pantelis

  reply	other threads:[~2012-11-28  9:22 UTC|newest]

Thread overview: 32+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-11-28 12:43 [U-Boot] [PATCH 0/9] DFU on am35xx_evm (against u-boot-usb) Pantelis Antoniou
2012-11-28 12:43 ` [U-Boot] [PATCH 1/9] Remove obsolete header file Pantelis Antoniou
2012-11-27 16:45   ` Tom Rini
2012-11-27 22:00     ` Marek Vasut
2012-11-28  3:01       ` Tom Rini
2012-11-28 12:43 ` [U-Boot] [PATCH 2/9] Fix bug when both DFU & ETHER are defined Pantelis Antoniou
2012-11-28  2:43   ` Marek Vasut
2012-11-28  8:24     ` Pantelis Antoniou
2012-11-29  6:30       ` Marek Vasut
2012-11-28 12:43 ` [U-Boot] [PATCH 3/9] Only perform DFU board_usb_init() for TRATS Pantelis Antoniou
2012-11-28  2:45   ` Marek Vasut
2012-11-28  8:26     ` Pantelis Antoniou
2012-11-29  6:28       ` Marek Vasut
2012-11-28 12:43 ` [U-Boot] [PATCH 4/9] Fix crash when wrong number of arguments given Pantelis Antoniou
2012-11-28 12:43 ` [U-Boot] [PATCH 5/9] Generate appropriate responses for DFU Pantelis Antoniou
2012-11-28  2:46   ` Marek Vasut
2012-11-28  8:27     ` Pantelis Antoniou
2012-11-28 12:43 ` [U-Boot] [PATCH 6/9] Properly zero out timeout value Pantelis Antoniou
2012-11-28  2:46   ` Marek Vasut
2012-11-28  8:28     ` Pantelis Antoniou
2012-11-28 10:23       ` Marek Vasut
2012-11-28 12:44 ` [U-Boot] [PATCH 7/9] Add a partition type target Pantelis Antoniou
2012-11-28  2:48   ` Marek Vasut
2012-11-28  8:31     ` Pantelis Antoniou
2012-11-28  9:22       ` Marek Vasut [this message]
2012-11-28 12:44 ` [U-Boot] [PATCH 8/9] Issue connect/disconnect as appropriate Pantelis Antoniou
2012-11-28  2:50   ` Marek Vasut
2012-11-28  3:03     ` Tom Rini
2012-11-28 12:44 ` [U-Boot] [PATCH 9/9] Add DFU config Pantelis Antoniou
2012-11-28  2:52   ` Marek Vasut
2012-11-28  3:04     ` Tom Rini
2012-11-28  8:32       ` 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=201211281022.20345.marex@denx.de \
    --to=marex@denx.de \
    --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