From: Mike Frysinger Date: Sun, 21 Aug 2011 12:35:14 -0400 Subject: [U-Boot] [PATCH v4] cmd_sf: add "update" subcommand to do smart SPI flash update In-Reply-To: References: <1313782128-7252-1-git-send-email-sjg@chromium.org> <201108210104.11721.marek.vasut@gmail.com> Message-ID: <201108211235.15600.vapier@gentoo.org> List-Id: MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: u-boot@lists.denx.de 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