Skip to content

Commit

Permalink
mtd: mtdparts: introduce mtd_get_device_size
Browse files Browse the repository at this point in the history
'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>
  • Loading branch information
Richard Genoud authored and Artem Bityutskiy committed Sep 4, 2012
1 parent 5dee467 commit 62082e5
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
10 changes: 10 additions & 0 deletions drivers/mtd/mtdpart.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
1 change: 1 addition & 0 deletions include/linux/mtd/partitions.h
Original file line number Diff line number Diff line change
Expand Up @@ -83,5 +83,6 @@ int mtd_is_partition(const struct mtd_info *mtd);
int mtd_add_partition(struct mtd_info *master, char *name,
long long offset, long long length);
int mtd_del_partition(struct mtd_info *master, int partno);
uint64_t mtd_get_device_size(const struct mtd_info *mtd);

#endif

0 comments on commit 62082e5

Please sign in to comment.