Skip to content

Commit 62082e5

Browse files
rgenouddedekind
authored andcommitted
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>
1 parent 5dee467 commit 62082e5

2 files changed

Lines changed: 11 additions & 0 deletions

File tree

‎drivers/mtd/mtdpart.c‎

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -760,3 +760,13 @@ int mtd_is_partition(const struct mtd_info *mtd)
760760
return ispart;
761761
}
762762
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);

‎include/linux/mtd/partitions.h‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,5 +83,6 @@ int mtd_is_partition(const struct mtd_info *mtd);
8383
int mtd_add_partition(struct mtd_info *master, char *name,
8484
long long offset, long long length);
8585
int mtd_del_partition(struct mtd_info *master, int partno);
86+
uint64_t mtd_get_device_size(const struct mtd_info *mtd);
8687

8788
#endif

0 commit comments

Comments
 (0)