Created
March 12, 2017 02:30
-
-
Save h-yamamo/e0f7e2d0e94337d5c30cf62cc29e9f3e to your computer and use it in GitHub Desktop.
Display block count of eMMC/SD card for linux 4.10
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
; mmc: Display media block count | |
; | |
# linux 4.10 | |
--- linux.orig/drivers/mmc/core/block.c | |
+++ linux.new/drivers/mmc/core/block.c | |
@@ -2170,6 +2170,7 @@ | |
static int mmc_blk_probe(struct mmc_card *card) | |
{ | |
struct mmc_blk_data *md, *part_md; | |
+ sector_t capacity; | |
char cap_str[10]; | |
/* | |
@@ -2184,11 +2185,12 @@ | |
if (IS_ERR(md)) | |
return PTR_ERR(md); | |
- string_get_size((u64)get_capacity(md->disk), 512, STRING_UNITS_2, | |
+ capacity = get_capacity(md->disk); | |
+ string_get_size((u64)capacity, 512, STRING_UNITS_2, | |
cap_str, sizeof(cap_str)); | |
- pr_info("%s: %s %s %s %s\n", | |
+ pr_info("%s: %s '%s' %llu 512-byte logical blocks: %s %s\n", | |
md->disk->disk_name, mmc_card_id(card), mmc_card_name(card), | |
- cap_str, md->read_only ? "(ro)" : ""); | |
+ capacity, cap_str, md->read_only ? "(ro)" : ""); | |
if (mmc_blk_alloc_parts(card, md)) | |
goto out; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Official kernel does not display accurate block count - only GB/MB size.
This patch display block count like HDD or USB storage.