UBI: add ubi_sync() interface
Linux-MTD Mailing List
linux-mtd at lists.infradead.org
Fri Jul 25 10:59:03 EDT 2008
Gitweb: http://git.infradead.org/?p=mtd-2.6.git;a=commit;h=a5bf6190417cbbf80443a9f71c65b653e13e9982
Commit: a5bf6190417cbbf80443a9f71c65b653e13e9982
Parent: 73789a3d9fd8e500e121c1d4a5a2b16dd748ab5f
Author: Artem Bityutskiy <Artem.Bityutskiy at nokia.com>
AuthorDate: Thu Jul 10 18:38:33 2008 +0300
Committer: Artem Bityutskiy <Artem.Bityutskiy at nokia.com>
CommitDate: Thu Jul 24 13:32:56 2008 +0300
UBI: add ubi_sync() interface
To flush MTD device caches.
Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy at nokia.com>
---
drivers/mtd/ubi/kapi.c | 24 ++++++++++++++++++++++++
include/linux/mtd/ubi.h | 1 +
2 files changed, 25 insertions(+), 0 deletions(-)
diff --git a/drivers/mtd/ubi/kapi.c b/drivers/mtd/ubi/kapi.c
index 5150883..e65c8e0 100644
--- a/drivers/mtd/ubi/kapi.c
+++ b/drivers/mtd/ubi/kapi.c
@@ -632,3 +632,27 @@ int ubi_is_mapped(struct ubi_volume_desc *desc, int lnum)
return vol->eba_tbl[lnum] >= 0;
}
EXPORT_SYMBOL_GPL(ubi_is_mapped);
+
+/**
+ * ubi_sync - synchronize UBI device buffers.
+ * @ubi_num: UBI device to synchronize
+ *
+ * The underlying MTD device may cache data in hardware or in software. This
+ * function ensures the caches are flushed. Returns zero in case of success and
+ * a negative error code in case of failure.
+ */
+int ubi_sync(int ubi_num)
+{
+ struct ubi_device *ubi;
+
+ ubi = ubi_get_device(ubi_num);
+ if (!ubi)
+ return -ENODEV;
+
+ if (ubi->mtd->sync)
+ ubi->mtd->sync(ubi->mtd);
+
+ ubi_put_device(ubi);
+ return 0;
+}
+EXPORT_SYMBOL_GPL(ubi_sync);
diff --git a/include/linux/mtd/ubi.h b/include/linux/mtd/ubi.h
index f71201d..83302bb 100644
--- a/include/linux/mtd/ubi.h
+++ b/include/linux/mtd/ubi.h
@@ -152,6 +152,7 @@ int ubi_leb_erase(struct ubi_volume_desc *desc, int lnum);
int ubi_leb_unmap(struct ubi_volume_desc *desc, int lnum);
int ubi_leb_map(struct ubi_volume_desc *desc, int lnum, int dtype);
int ubi_is_mapped(struct ubi_volume_desc *desc, int lnum);
+int ubi_sync(int ubi_num);
/*
* This function is the same as the 'ubi_leb_read()' function, but it does not
More information about the linux-mtd-cvs
mailing list