aboutsummaryrefslogtreecommitdiff
path: root/libflash/ecc.h
diff options
context:
space:
mode:
authorCyril Bur <cyril.bur@au1.ibm.com>2018-03-07 17:04:57 +1100
committerStewart Smith <stewart@linux.ibm.com>2018-04-09 03:45:23 -0500
commitf7713517d90a14853dc9cfb66ee33dbc084e6ddf (patch)
treec506168dc46997e30a8c75548c014bed276c0d60 /libflash/ecc.h
parent07c4573d06785b06ce36fd8feab28e153f4756f7 (diff)
downloadskiboot-f7713517d90a14853dc9cfb66ee33dbc084e6ddf.zip
skiboot-f7713517d90a14853dc9cfb66ee33dbc084e6ddf.tar.gz
skiboot-f7713517d90a14853dc9cfb66ee33dbc084e6ddf.tar.bz2
libflash/ecc: Add helpers to align a position within an ecc buffer
As part of ongoing work to make ECC invisible to higher levels up the stack this function converts a 'position' which should be ECC agnostic to the equivalent position within an ECC region starting at a specified location. Signed-off-by: Cyril Bur <cyril.bur@au1.ibm.com> Signed-off-by: Stewart Smith <stewart@linux.ibm.com>
Diffstat (limited to 'libflash/ecc.h')
-rw-r--r--libflash/ecc.h5
1 files changed, 5 insertions, 0 deletions
diff --git a/libflash/ecc.h b/libflash/ecc.h
index 2ce2215..bd66948 100644
--- a/libflash/ecc.h
+++ b/libflash/ecc.h
@@ -67,4 +67,9 @@ static inline uint64_t ecc_buffer_size_minus_ecc(uint64_t len)
return len * BYTES_PER_ECC / (BYTES_PER_ECC + 1);
}
+static inline uint64_t ecc_buffer_align(uint64_t start, uint64_t pos)
+{
+ return pos - ((pos - start) % (BYTES_PER_ECC + 1));
+}
+
#endif