diff options
Diffstat (limited to 'src/barebox-state/backend_bucket_circular.c')
-rw-r--r-- | src/barebox-state/backend_bucket_circular.c | 18 |
1 files changed, 9 insertions, 9 deletions
diff --git a/src/barebox-state/backend_bucket_circular.c b/src/barebox-state/backend_bucket_circular.c index aec17b3..0906268 100644 --- a/src/barebox-state/backend_bucket_circular.c +++ b/src/barebox-state/backend_bucket_circular.c @@ -1,3 +1,4 @@ +/* SPDX-License-Identifier: GPL-2.0-only */ /* * Copyright (C) 2016 Pengutronix, Markus Pargmann <mpa@pengutronix.de> * @@ -95,6 +96,7 @@ static int state_mtd_peb_read(struct state_backend_storage_bucket_circular *circ if (ret == -EBADMSG) { ret = mtd_peb_torture(circ->mtd, circ->eraseblock); if (ret == -EIO) { + mtd_peb_mark_bad(circ->mtd, circ->eraseblock); dev_err(circ->dev, "Tortured eraseblock failed and is marked bad now, PEB %u\n", circ->eraseblock); return -EIO; @@ -132,6 +134,7 @@ static int state_mtd_peb_write(struct state_backend_storage_bucket_circular *cir if (ret == -EBADMSG) { ret = mtd_peb_torture(circ->mtd, circ->eraseblock); if (ret == -EIO) { + mtd_peb_mark_bad(circ->mtd, circ->eraseblock); dev_err(circ->dev, "Tortured eraseblock failed and is marked bad now, PEB %u\n", circ->eraseblock); return -EIO; @@ -162,11 +165,10 @@ static int state_mtd_peb_read(struct state_backend_storage_bucket_circular *circ offset += (off_t)circ->eraseblock * circ->mtd->erasesize; - ret = lseek(circ->fd, offset, SEEK_SET); - if (ret < 0) { + if (lseek(circ->fd, offset, SEEK_SET) != offset) { dev_err(circ->dev, "Failed to set circular read position to %lld, %d\n", - (long long) offset, ret); - return ret; + (long long) offset, -errno); + return -errno; } dev_dbg(circ->dev, "Read state from %lld length %d\n", (long long) offset, @@ -177,7 +179,6 @@ static int state_mtd_peb_read(struct state_backend_storage_bucket_circular *circ if (ret < 0) { dev_err(circ->dev, "Failed to read circular storage len %d, %d\n", len, ret); - free(buf); return ret; } @@ -192,11 +193,10 @@ static int state_mtd_peb_write(struct state_backend_storage_bucket_circular *cir offset += circ->eraseblock * circ->mtd->erasesize; - ret = lseek(circ->fd, offset, SEEK_SET); - if (ret < 0) { + if (lseek(circ->fd, offset, SEEK_SET) != offset) { dev_err(circ->dev, "Failed to set position for circular write %lld, %d\n", - (long long) offset, ret); - return ret; + (long long) offset, -errno); + return -errno; } ret = write_full(circ->fd, buf, len); |