summaryrefslogtreecommitdiffstats
path: root/drivers/mtd/ubi/upd.c
diff options
context:
space:
mode:
authorSascha Hauer <s.hauer@pengutronix.de>2010-06-28 13:33:28 +0200
committerSascha Hauer <s.hauer@pengutronix.de>2010-07-05 15:07:14 +0200
commite0677920d6e61e246d6906cd931263d35292dc7e (patch)
treea90eb89efef852773cd6ff041d7e48759890147f /drivers/mtd/ubi/upd.c
parent8dbed40da9c07f106246584e91980dba856dad1e (diff)
downloadbarebox-e0677920d6e61e246d6906cd931263d35292dc7e.tar.gz
barebox-e0677920d6e61e246d6906cd931263d35292dc7e.tar.xz
barebox ubi changes
This adds the layer between barebox and UBI. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Diffstat (limited to 'drivers/mtd/ubi/upd.c')
-rw-r--r--drivers/mtd/ubi/upd.c36
1 files changed, 20 insertions, 16 deletions
diff --git a/drivers/mtd/ubi/upd.c b/drivers/mtd/ubi/upd.c
index 8267b1adc5..fda2043183 100644
--- a/drivers/mtd/ubi/upd.c
+++ b/drivers/mtd/ubi/upd.c
@@ -173,6 +173,23 @@ int ubi_start_update(struct ubi_device *ubi, struct ubi_volume *vol,
return 0;
}
+int ubi_finish_update(struct ubi_device *ubi, struct ubi_volume *vol)
+{
+ int err;
+
+ /* The update is finished, clear the update marker */
+ err = clear_update_marker(ubi, vol, vol->upd_bytes);
+ if (err)
+ return err;
+ err = ubi_wl_flush(ubi);
+ if (err == 0) {
+ vol->updating = 0;
+ vfree(vol->upd_buf);
+ }
+
+ return err;
+}
+
/**
* ubi_start_leb_change - start atomic LEB change.
* @ubi: UBI device description object
@@ -320,13 +337,12 @@ int ubi_more_update_data(struct ubi_device *ubi, struct ubi_volume *vol,
if (err)
return -EFAULT;
- if (offs + len == vol->usable_leb_size ||
- vol->upd_received + len == vol->upd_bytes) {
+ if (offs + len == vol->usable_leb_size) {
int flush_len = offs + len;
/*
- * OK, we gathered either the whole eraseblock or this
- * is the last chunk, it's time to flush the buffer.
+ * OK, we gathered the whole eraseblock, it's time to flush
+ * the buffer.
*/
ubi_assert(flush_len <= vol->usable_leb_size);
err = write_leb(ubi, vol, lnum, vol->upd_buf, flush_len,
@@ -370,18 +386,6 @@ int ubi_more_update_data(struct ubi_device *ubi, struct ubi_volume *vol,
}
ubi_assert(vol->upd_received <= vol->upd_bytes);
- if (vol->upd_received == vol->upd_bytes) {
- /* The update is finished, clear the update marker */
- err = clear_update_marker(ubi, vol, vol->upd_bytes);
- if (err)
- return err;
- err = ubi_wl_flush(ubi);
- if (err == 0) {
- vol->updating = 0;
- err = to_write;
- vfree(vol->upd_buf);
- }
- }
return err;
}