aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrew Jeffery <andrew@aj.id.au>2019-10-03 15:23:37 +0930
committerOliver O'Halloran <oohall@gmail.com>2019-10-14 16:27:10 +1100
commit518db2b216af5178a18f8b7ad06769b6acc51bcc (patch)
tree23880f74ff9b4e7dc4d8312a4273dabd7009808d
parent5c935e78f335597f502e1fda1911ca50bbeed561 (diff)
downloadskiboot-518db2b216af5178a18f8b7ad06769b6acc51bcc.zip
skiboot-518db2b216af5178a18f8b7ad06769b6acc51bcc.tar.gz
skiboot-518db2b216af5178a18f8b7ad06769b6acc51bcc.tar.bz2
blocklevel: smart_write: Rename size variable for clarity
We're writing in chunks, so lets make it clear that size is relative to the chunk that we're writing. Signed-off-by: Andrew Jeffery <andrew@aj.id.au> Signed-off-by: Oliver O'Halloran <oohall@gmail.com>
-rw-r--r--libflash/blocklevel.c17
1 files changed, 9 insertions, 8 deletions
diff --git a/libflash/blocklevel.c b/libflash/blocklevel.c
index ae81c2b..f32db3c 100644
--- a/libflash/blocklevel.c
+++ b/libflash/blocklevel.c
@@ -562,19 +562,20 @@ int blocklevel_smart_write(struct blocklevel_device *bl, uint64_t pos, const voi
while (len > 0) {
uint32_t erase_block = pos & ~(erase_size - 1);
uint32_t block_offset = pos & (erase_size - 1);
- uint32_t size = erase_size > len ? len : erase_size;
+ uint32_t chunk_size = erase_size > len ? len : erase_size;
int cmp;
/* Write crosses an erase boundary, shrink the write to the boundary */
- if (erase_size < block_offset + size) {
- size = erase_size - block_offset;
+ if (erase_size < block_offset + chunk_size) {
+ chunk_size = erase_size - block_offset;
}
rc = bl->read(bl, erase_block, erase_buf, erase_size);
if (rc)
goto out;
- cmp = blocklevel_flashcmp(erase_buf + block_offset, write_buf, size);
+ cmp = blocklevel_flashcmp(erase_buf + block_offset, write_buf,
+ chunk_size);
FL_DBG("%s: region 0x%08x..0x%08x ", __func__,
erase_block, erase_size);
if (cmp != 0) {
@@ -584,16 +585,16 @@ int blocklevel_smart_write(struct blocklevel_device *bl, uint64_t pos, const voi
bl->erase(bl, erase_block, erase_size);
}
FL_DBG("write\n");
- memcpy(erase_buf + block_offset, write_buf, size);
+ memcpy(erase_buf + block_offset, write_buf, chunk_size);
rc = bl->write(bl, erase_block, erase_buf, erase_size);
if (rc)
goto out;
} else {
FL_DBG("clean\n");
}
- len -= size;
- pos += size;
- write_buf += size;
+ len -= chunk_size;
+ pos += chunk_size;
+ write_buf += chunk_size;
}
out: