diff options
author | Ratan Gupta <ratagupt@in.ibm.com> | 2017-05-31 15:47:55 +0530 |
---|---|---|
committer | Ratan Gupta <ratagupt@in.ibm.com> | 2017-06-29 22:08:39 +0530 |
commit | dc50ce5a787fe4979d084355c485301b84396967 (patch) | |
tree | 57fe92479a24c40833b02be0c7da892df54f17e7 /mboxd_flash.c | |
parent | 6a98e18394fa529c281a28175494423fec920ffb (diff) | |
download | phosphor-mboxd-dc50ce5a787fe4979d084355c485301b84396967.tar.gz phosphor-mboxd-dc50ce5a787fe4979d084355c485301b84396967.zip |
Implement write flash function for vpnor
Opens the partition file from the vpnor,
Memory map to it and then copy the given data
from the reserved memory area to the vpnor.
Change-Id: I29f44482155d890622221695deee255b222e9a49
Signed-off-by: Ratan Gupta <ratagupt@in.ibm.com>
Diffstat (limited to 'mboxd_flash.c')
-rw-r--r-- | mboxd_flash.c | 40 |
1 files changed, 0 insertions, 40 deletions
diff --git a/mboxd_flash.c b/mboxd_flash.c index 240c660..4b6c1f7 100644 --- a/mboxd_flash.c +++ b/mboxd_flash.c @@ -230,43 +230,3 @@ int erase_flash(struct mbox_context *context, uint32_t offset, uint32_t count) return 0; } - -/* - * write_flash() - Write the flash from a provided buffer - * @context: The mbox context pointer - * @offset: The flash offset to write to (bytes) - * @buf: The buffer to write from (must be of atleast size) - * @size: The number of bytes to write - * - * Return: 0 on success otherwise negative error code - */ -int write_flash(struct mbox_context *context, uint32_t offset, void *buf, - uint32_t count) -{ - uint32_t buf_offset = 0; - int rc; - - MSG_DBG("Write flash @ 0x%.8x for 0x%.8x from %p\n", offset, count, buf); - - if (lseek(context->fds[MTD_FD].fd, offset, SEEK_SET) != offset) { - MSG_ERR("Couldn't seek flash at pos: %u %s\n", offset, - strerror(errno)); - return -MBOX_R_SYSTEM_ERROR; - } - - while (count) { - rc = write(context->fds[MTD_FD].fd, buf + buf_offset, count); - if (rc < 0) { - MSG_ERR("Couldn't write to flash, write lost: %s\n", - strerror(errno)); - return -MBOX_R_WRITE_ERROR; - } - /* Mark *NOT* erased where we just wrote */ - set_flash_bytemap(context, offset + buf_offset, rc, - FLASH_DIRTY); - count -= rc; - buf_offset += rc; - } - - return 0; -} |