summaryrefslogtreecommitdiffstats
path: root/common/state
diff options
context:
space:
mode:
authorLadislav Michl <ladis@linux-mips.org>2018-09-25 12:58:45 +0200
committerSascha Hauer <s.hauer@pengutronix.de>2018-09-26 08:57:09 +0200
commitf70141447cf1aedd77a40d8bf76657927bb73840 (patch)
tree49a3995ad3953d364df08fabc96634c09bf0e61c /common/state
parent9cfd8c2be3ec77db0164f5ba23ee221c184c1b93 (diff)
downloadbarebox-f70141447cf1aedd77a40d8bf76657927bb73840.tar.gz
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>
Diffstat (limited to 'common/state')
-rw-r--r--common/state/backend_bucket_circular.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/common/state/backend_bucket_circular.c b/common/state/backend_bucket_circular.c
index 933493e..0529421 100644
--- a/common/state/backend_bucket_circular.c
+++ b/common/state/backend_bucket_circular.c
@@ -248,7 +248,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);
@@ -295,7 +295,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;