aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRichard Genoud <richard.genoud@gmail.com>2012-07-10 12:23:40 -0400
committerArtem Bityutskiy <artem.bityutskiy@linux.intel.com>2012-09-04 02:38:58 -0400
commit62082e56cbb807cb325a8968f35dbd922432eb48 (patch)
tree7774c4a45743e1b7bbefb1c7363c9af3185a51c5
parent5dee4674c8dd4398f4806aae153888319c7e2be9 (diff)
mtd: mtdparts: introduce mtd_get_device_size
'mtd_get_device_size()' returns the size of the whole MTD device, that is the mtd_info master size. This will be used by UBI to calculate the maximum number of bad blocks (MBB) on a MTD device. Artem: amended the patch a bit. Signed-off-by: Richard Genoud <richard.genoud@gmail.com> Signed-off-by: Artem Bityutskiy <artem.bityutskiy@linux.intel.com>
-rw-r--r--drivers/mtd/mtdpart.c10
-rw-r--r--include/linux/mtd/partitions.h1
2 files changed, 11 insertions, 0 deletions
diff --git a/drivers/mtd/mtdpart.c b/drivers/mtd/mtdpart.c
index 85005846f30d..3a49e6de5e60 100644
--- a/drivers/mtd/mtdpart.c
+++ b/drivers/mtd/mtdpart.c
@@ -760,3 +760,13 @@ int mtd_is_partition(const struct mtd_info *mtd)
760 return ispart; 760 return ispart;
761} 761}
762EXPORT_SYMBOL_GPL(mtd_is_partition); 762EXPORT_SYMBOL_GPL(mtd_is_partition);
763
764/* Returns the size of the entire flash chip */
765uint64_t mtd_get_device_size(const struct mtd_info *mtd)
766{
767 if (!mtd_is_partition(mtd))
768 return mtd->size;
769
770 return PART(mtd)->master->size;
771}
772EXPORT_SYMBOL_GPL(mtd_get_device_size);
diff --git a/include/linux/mtd/partitions.h b/include/linux/mtd/partitions.h
index 02a51157a173..1f8d24bdafda 100644
--- a/include/linux/mtd/partitions.h
+++ b/include/linux/mtd/partitions.h
@@ -83,5 +83,6 @@ int mtd_is_partition(const struct mtd_info *mtd);
83int mtd_add_partition(struct mtd_info *master, char *name, 83int mtd_add_partition(struct mtd_info *master, char *name,
84 long long offset, long long length); 84 long long offset, long long length);
85int mtd_del_partition(struct mtd_info *master, int partno); 85int mtd_del_partition(struct mtd_info *master, int partno);
86uint64_t mtd_get_device_size(const struct mtd_info *mtd);
86 87
87#endif 88#endif