From: Scott Wood Date: Wed, 16 Feb 2011 15:47:17 -0600 Subject: [U-Boot] [PATCH 2/2] cmd_sf: Add handler for +len arg for erase command. In-Reply-To: <1297888074-8344-3-git-send-email-RichardRetanubun@RuggedCom.com> References: <201102150434.39422.vapier@gentoo.org> <1297888074-8344-3-git-send-email-RichardRetanubun@RuggedCom.com> Message-ID: <20110216154717.39b0b3a7@schlenkerla> List-Id: MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: u-boot@lists.denx.de On Wed, 16 Feb 2011 15:27:54 -0500 Richard Retanubun wrote: > This patch adds [+]len handler for the erase command that will > automatically round up the requested erase length to the flash's > sector_size. > --- > common/cmd_sf.c | 53 +++++++++++++++++++++++++++++++++++++++++++++++++---- > 1 files changed, 49 insertions(+), 4 deletions(-) > > diff --git a/common/cmd_sf.c b/common/cmd_sf.c > index 6e7be81..bbd4842 100644 > --- a/common/cmd_sf.c > +++ b/common/cmd_sf.c > @@ -19,6 +19,48 @@ > > static struct spi_flash *flash; > > + > +/* > + * This function computes the length argument for the erase command. > + * The length on which the command is to operate can be given in two forms: > + * 1. offset len - operate on <'offset', 'len') > + * 2. offset +len - operate on <'offset', 'round_up(len)') > + * If the second form is used and the length doesn't fall on the > + * sector boundary, than it will be adjusted to the next sector boundary. > + * If it isn't in the flash, the function will fail (return -1). On NOR, + is used to indicate that the second argument is a length, as opposed to an ending address. Rounding seems like a side effect of length mode. On NAND we unconditionally round up erase lengths, as we don't support ending-address mode (looks like SPI doesn't either). -Scott