public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
From: Mike Frysinger <vapier@gentoo.org>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH v4] cmd_sf: add "update" subcommand to do smart SPI flash update
Date: Sun, 21 Aug 2011 12:35:14 -0400	[thread overview]
Message-ID: <201108211235.15600.vapier@gentoo.org> (raw)
In-Reply-To: <CAPnjgZ3j4Zteat1AvtSXDB9XB2rd34tNg==6bKmx6iAAZwDQLA@mail.gmail.com>

On Sunday, August 21, 2011 06:37:30 Simon Glass wrote:
> On Sat, Aug 20, 2011 at 5:04 PM, Marek Vasut wrote:
> > On Sunday, August 21, 2011 12:35:51 AM Mike Frysinger wrote:
> >> +{
> >> +     debug("offset=%#x, sector_size=%#x, len=%#x\n",
> >> +             offset, flash->sector_size, len);
> >> +     if (spi_flash_read(flash, offset, len, cmp_buf))
> >> +             return "read";
> >> +     if (memcmp(cmp_buf, buf, len) == 0) {
> >> +             debug("Skip region %x size %x: no change\n",
> >> +                     offset, len);
> >> +             *skipped += len;
> >> +             return NULL;
> >> +     }
> >> +     if (spi_flash_erase(flash, offset, len))
> >> +             return "erase";
> >> +     if (spi_flash_write(flash, offset, len, buf))
> >> +             return "write";
> > 
> > Numeric value won't be ok ? You can have these in the calling function
> > instead of returning a char *.
> 
> Yes it's a bit odd, but the alternative is quite a bit more verbose:
> 
> enum {
>    OPER_MALLOC,
>    OPER_READ,
>    OPER_ERASE,
>    ...
> };
> 
> static const char *names[OPER...] = {

static const char * const names[] = {

>    "malloc",
>    "read",
>    "erase"
> ...
> };
> 
> Is that better?

only if the code size is smaller ;)
-mike
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 836 bytes
Desc: This is a digitally signed message part.
Url : http://lists.denx.de/pipermail/u-boot/attachments/20110821/419a1cad/attachment.pgp 

  reply	other threads:[~2011-08-21 16:35 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-08-19 19:28 [U-Boot] [PATCH v3] Add 'sf update' command to do smart SPI flash update Simon Glass
2011-08-19 21:15 ` Mike Frysinger
2011-08-19 21:25   ` Simon Glass
2011-08-19 22:28     ` Mike Frysinger
2011-08-23 22:01       ` Simon Glass
2011-08-23 22:16         ` Mike Frysinger
2011-08-24  3:41           ` Che-liang Chiou
2011-08-24  4:11             ` Simon Glass
2011-08-20 22:35 ` [U-Boot] [PATCH v4] cmd_sf: add "update" subcommand " Mike Frysinger
2011-08-20 23:04   ` Marek Vasut
2011-08-21 10:37     ` Simon Glass
2011-08-21 16:35       ` Mike Frysinger [this message]
2011-08-22 22:53         ` Simon Glass
2011-08-21 10:27   ` Simon Glass
2011-08-21 16:34     ` Mike Frysinger

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=201108211235.15600.vapier@gentoo.org \
    --to=vapier@gentoo.org \
    --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