From 5dee4674c8dd4398f4806aae153888319c7e2be9 Mon Sep 17 00:00:00 2001 From: Richard Genoud Date: Tue, 10 Jul 2012 18:23:39 +0200 Subject: mtd: mark mtd_is_partition argument as constant 'struct mtd_info' is not modified by 'mtd_is_partition()' so it can be marked as "const". Signed-off-by: Richard Genoud Signed-off-by: Artem Bityutskiy --- drivers/mtd/mtdpart.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'drivers/mtd/mtdpart.c') diff --git a/drivers/mtd/mtdpart.c b/drivers/mtd/mtdpart.c index d518e4d..8500584 100644 --- a/drivers/mtd/mtdpart.c +++ b/drivers/mtd/mtdpart.c @@ -744,7 +744,7 @@ int parse_mtd_partitions(struct mtd_info *master, const char **types, return ret; } -int mtd_is_partition(struct mtd_info *mtd) +int mtd_is_partition(const struct mtd_info *mtd) { struct mtd_part *part; int ispart = 0; -- cgit v1.1 From 62082e56cbb807cb325a8968f35dbd922432eb48 Mon Sep 17 00:00:00 2001 From: Richard Genoud Date: Tue, 10 Jul 2012 18:23:40 +0200 Subject: 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 Signed-off-by: Artem Bityutskiy --- drivers/mtd/mtdpart.c | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'drivers/mtd/mtdpart.c') diff --git a/drivers/mtd/mtdpart.c b/drivers/mtd/mtdpart.c index 8500584..3a49e6d 100644 --- a/drivers/mtd/mtdpart.c +++ b/drivers/mtd/mtdpart.c @@ -760,3 +760,13 @@ int mtd_is_partition(const struct mtd_info *mtd) return ispart; } EXPORT_SYMBOL_GPL(mtd_is_partition); + +/* Returns the size of the entire flash chip */ +uint64_t mtd_get_device_size(const struct mtd_info *mtd) +{ + if (!mtd_is_partition(mtd)) + return mtd->size; + + return PART(mtd)->master->size; +} +EXPORT_SYMBOL_GPL(mtd_get_device_size); -- cgit v1.1