diff options
author | Artem Bityutskiy <Artem.Bityutskiy@nokia.com> | 2008-07-10 11:38:33 -0400 |
---|---|---|
committer | Artem Bityutskiy <Artem.Bityutskiy@nokia.com> | 2008-07-24 06:32:56 -0400 |
commit | a5bf6190417cbbf80443a9f71c65b653e13e9982 (patch) | |
tree | 341b656517b02efe8ee49446d4591625da69171a | |
parent | 73789a3d9fd8e500e121c1d4a5a2b16dd748ab5f (diff) |
UBI: add ubi_sync() interface
To flush MTD device caches.
Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
-rw-r--r-- | drivers/mtd/ubi/kapi.c | 24 | ||||
-rw-r--r-- | 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 51508832566d..e65c8e0bcd5d 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) | |||
632 | return vol->eba_tbl[lnum] >= 0; | 632 | return vol->eba_tbl[lnum] >= 0; |
633 | } | 633 | } |
634 | EXPORT_SYMBOL_GPL(ubi_is_mapped); | 634 | EXPORT_SYMBOL_GPL(ubi_is_mapped); |
635 | |||
636 | /** | ||
637 | * ubi_sync - synchronize UBI device buffers. | ||
638 | * @ubi_num: UBI device to synchronize | ||
639 | * | ||
640 | * The underlying MTD device may cache data in hardware or in software. This | ||
641 | * function ensures the caches are flushed. Returns zero in case of success and | ||
642 | * a negative error code in case of failure. | ||
643 | */ | ||
644 | int ubi_sync(int ubi_num) | ||
645 | { | ||
646 | struct ubi_device *ubi; | ||
647 | |||
648 | ubi = ubi_get_device(ubi_num); | ||
649 | if (!ubi) | ||
650 | return -ENODEV; | ||
651 | |||
652 | if (ubi->mtd->sync) | ||
653 | ubi->mtd->sync(ubi->mtd); | ||
654 | |||
655 | ubi_put_device(ubi); | ||
656 | return 0; | ||
657 | } | ||
658 | EXPORT_SYMBOL_GPL(ubi_sync); | ||
diff --git a/include/linux/mtd/ubi.h b/include/linux/mtd/ubi.h index f71201d0f3e7..83302bbbddb4 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); | |||
152 | int ubi_leb_unmap(struct ubi_volume_desc *desc, int lnum); | 152 | int ubi_leb_unmap(struct ubi_volume_desc *desc, int lnum); |
153 | int ubi_leb_map(struct ubi_volume_desc *desc, int lnum, int dtype); | 153 | int ubi_leb_map(struct ubi_volume_desc *desc, int lnum, int dtype); |
154 | int ubi_is_mapped(struct ubi_volume_desc *desc, int lnum); | 154 | int ubi_is_mapped(struct ubi_volume_desc *desc, int lnum); |
155 | int ubi_sync(int ubi_num); | ||
155 | 156 | ||
156 | /* | 157 | /* |
157 | * This function is the same as the 'ubi_leb_read()' function, but it does not | 158 | * This function is the same as the 'ubi_leb_read()' function, but it does not |