Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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>

authored by

Richard Genoud and committed by
Artem Bityutskiy
62082e56 5dee4674

+11
+10
drivers/mtd/mtdpart.c
··· 760 760 return ispart; 761 761 } 762 762 EXPORT_SYMBOL_GPL(mtd_is_partition); 763 + 764 + /* Returns the size of the entire flash chip */ 765 + uint64_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 + } 772 + EXPORT_SYMBOL_GPL(mtd_get_device_size);
+1
include/linux/mtd/partitions.h
··· 83 83 int mtd_add_partition(struct mtd_info *master, char *name, 84 84 long long offset, long long length); 85 85 int mtd_del_partition(struct mtd_info *master, int partno); 86 + uint64_t mtd_get_device_size(const struct mtd_info *mtd); 86 87 87 88 #endif