diff options
author | Simon Glass <sjg@chromium.org> | 2012-07-03 20:03:23 -0700 |
---|---|---|
committer | Gerrit <chrome-bot@google.com> | 2012-07-03 23:51:09 -0700 |
commit | a60fdbdfcb73b521e91006eda46c2c47bf2a51f1 (patch) | |
tree | 5c7c27a2d5e316c8a9fbed1d090147a18c30eb81 /include/flash.h | |
parent | 9a4205faf3a378987cf534018e30be3892fcce26 (diff) | |
download | chrome-ec-a60fdbdfcb73b521e91006eda46c2c47bf2a51f1.tar.gz |
Fix flash_dataptr() to support flash at zero
If flash starts at zero, then flash_dataptr() will return NULL for a valid
region. Change the function around so that it can be used in this case.
BUG=chrome-os-partner:10146
TEST=manual:
Modify code it print out parameters and problems, then:
Writing 256 bytes to 0x0...
0 256 64
ok 131072
Command returned error 1
> flashwrite 0 256
Writing 256 bytes to 0x0...
0 256 64
ok 131072
Command returned error 1
> flashwrite 0 255
Writing 255 bytes to 0x0...
0 255 64
Command usage/param invalid.
Usage: flashwrite offset [size]
Change-Id: I5683fc181ef780310ceff50f120735659e973784
Signed-off-by: Simon Glass <sjg@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/26749
Reviewed-by: David Hendricks <dhendrix@chromium.org>
Reviewed-by: Rong Chang <rongchang@chromium.org>
Diffstat (limited to 'include/flash.h')
-rw-r--r-- | include/flash.h | 14 |
1 files changed, 7 insertions, 7 deletions
diff --git a/include/flash.h b/include/flash.h index 7611639add..3dcce216c6 100644 --- a/include/flash.h +++ b/include/flash.h @@ -73,19 +73,19 @@ int flash_get_size(void); * contiguous from this start address through to the end of the usable * flash. * - * This function returns NULL if offset + size_req extends beyond the end - * of flash, or if either size_req or offset are not aligned to 'align'. + * This function returns -1 if offset + size_req extends beyond the end + * of flash, the offset is out of range, or if either size_req or offset + * are not aligned to 'align'. * * @param offset Flash offset to get address of * @param size_req Number of bytes requested * @param align Ensure offset and size_req are aligned to given * power of two. - * @param sizep If not NULL, returns amount of flash available at - * this memory addr, unless function fails, iwc it is - * unset. - * @return pointer to flash, or NULL on error + * @param ptrp If not NULL, returns a pointer to this flash offset + * in memory, unless function fails, iwc it is unset. + * @return size of flash region available at *ptrp, or -1 on error */ -char *flash_dataptr(int offset, int size_req, int align, int *sizep); +int flash_dataptr(int offset, int size_req, int align, char **ptrp); /* Reads <size> bytes of data from offset <offset> into <data>. */ int flash_read(int offset, int size, char *data); |