From mboxrd@z Thu Jan 1 00:00:00 1970 From: Derek Ou Date: Tue, 17 Feb 2009 13:54:00 -0700 Subject: [U-Boot] [PATCH] Pad data length for nand write In-Reply-To: <20090217185155.GA31737@ld0162-tx32.am.freescale.net> References: <1234890907-934-1-git-send-email-dou@siconix.com> <1234890907-934-2-git-send-email-dou@siconix.com> <20090217185155.GA31737@ld0162-tx32.am.freescale.net> Message-ID: <499B23E8.30607@siconix.com> List-Id: MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: u-boot@lists.denx.de This routine is copied from nand_write_opts() at nand_util.c of v1.3.4. It maybe better to pad data length and data buffer in do_nand() at cmd_nand.c. But I don't see real difference. I didn't allocate a new buffer since the data length is defined in the command arguments and I have no knowledge of a safe location and large enough memory space to store data. Maybe we should implement, like Wolfgang said, a "+length" syntax in the "nand write" command to indicates "round up to the next page boundary". In this case, do_nand() can assume that it's safe to write pass memory address (add + length) and Flash offset (off + length). Derek Scott Wood wrote: > On Tue, Feb 17, 2009 at 10:15:07AM -0700, Derek Ou wrote: > >> + /* now, pad data with 0xff */ >> + if (page_offset != 0) >> + memset(buffer + *length, 0xff, pad_len); >> > You cannot write to the caller's buffer (or worse, past the end of the > caller's buffer) like this. You'll need to allocate a new, padded > buffer. > > -Scott >