mtd: mtdparts: introduce mtd_get_device_size
[firefly-linux-kernel-4.4.55.git] / drivers / mtd / mtdpart.c
index 85005846f30d5eeba0862cb48aceb435f017c81f..3a49e6de5e603e2641acc86acb50025bde9b69a6 100644 (file)
@@ -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);