diff options
author | Ulrich Ölmann <u.oelmann@pengutronix.de> | 2018-12-18 14:57:56 +0100 |
---|---|---|
committer | Roland Hieber <rhi@pengutronix.de> | 2019-01-07 15:47:56 +0100 |
commit | bfd82b755f32e2e54e3f27b10fb801092cb99c7c (patch) | |
tree | af0f1bf70f2914b237e24a7bc0983a96eda7ffbd | |
parent | ea60eb9e5a7d08f4faba6ff170cc93f2faaa2bdc (diff) | |
download | dt-utils-bfd82b755f32e2e54e3f27b10fb801092cb99c7c.tar.gz dt-utils-bfd82b755f32e2e54e3f27b10fb801092cb99c7c.tar.xz |
state: backend_bucket_circular: fix for non power of 2 writesize
This includes sys/param.h to have the definition of roundup() and ports the
following barebox commit:
| commit f70141447cf1aedd77a40d8bf76657927bb73840
| Author: Ladislav Michl <ladis@linux-mips.org>
| Date: Tue Sep 25 12:58:45 2018 +0200
|
| state: backend_bucket_circular: fix for non power of 2 writesize
|
| backend_bucket_circular currently assumes writesize is power of 2,
| which makes it fail on dataflash devices, where this assumption
| is false.
|
| Signed-off-by: Ladislav Michl <ladis@linux-mips.org>
| Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Signed-off-by: Ulrich Ölmann <u.oelmann@pengutronix.de>
Signed-off-by: Roland Hieber <rhi@pengutronix.de>
-rw-r--r-- | src/barebox-state/backend_bucket_circular.c | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/src/barebox-state/backend_bucket_circular.c b/src/barebox-state/backend_bucket_circular.c index ec78748..f71e5c2 100644 --- a/src/barebox-state/backend_bucket_circular.c +++ b/src/barebox-state/backend_bucket_circular.c @@ -23,6 +23,10 @@ #include <mtd/mtd-peb.h> #include <string.h> +#ifndef __BAREBOX__ +#include <sys/param.h> +#endif + #include "state.h" /* @@ -249,7 +253,7 @@ static int state_backend_bucket_circular_read(struct state_backend_storage_bucke circ->write_area = 0; dev_info(circ->dev, "Detected old on-storage format\n"); } else if (circ->last_written_length > circ->write_area - || !IS_ALIGNED(circ->last_written_length, circ->writesize)) { + || (circ->last_written_length % circ->writesize != 0)) { circ->write_area = 0; dev_err(circ->dev, "Error, invalid number of bytes written last time %d\n", circ->last_written_length); @@ -296,7 +300,7 @@ static int state_backend_bucket_circular_write(struct state_backend_storage_buck get_bucket_circular(bucket); off_t offset; struct state_backend_storage_bucket_circular_meta *meta; - uint32_t written_length = ALIGN(len + sizeof(*meta), circ->writesize); + uint32_t written_length = roundup(len + sizeof(*meta), circ->writesize); int ret; void *write_buf; |