[PATCH 06/15] cmd: host: Print out the block size of the host device

Bin Meng bmeng at tinylab.org
Tue Sep 26 10:43:36 CEST 2023


It's useful if we can print out the block size of the host device
in the "host info" command.

Signed-off-by: Bin Meng <bmeng at tinylab.org>
---

 cmd/host.c     |  7 ++++---
 test/dm/host.c | 20 ++++++++++----------
 2 files changed, 14 insertions(+), 13 deletions(-)

diff --git a/cmd/host.c b/cmd/host.c
index 2334ccd9bc..c33c2a9787 100644
--- a/cmd/host.c
+++ b/cmd/host.c
@@ -160,8 +160,8 @@ static void show_host_dev(struct udevice *dev)
 		return;
 
 	desc = dev_get_uclass_plat(blk);
-	printf("%12lu %-15s %s\n", (unsigned long)desc->lba, plat->label,
-	       plat->filename);
+	printf("%12lu %6lu %-15s %s\n", (unsigned long)desc->lba, desc->blksz,
+	       plat->label, plat->filename);
 }
 
 static int do_host_info(struct cmd_tbl *cmdtp, int flag, int argc,
@@ -179,7 +179,8 @@ static int do_host_info(struct cmd_tbl *cmdtp, int flag, int argc,
 			return CMD_RET_FAILURE;
 	}
 
-	printf("%3s %12s %-15s %s\n", "dev", "blocks", "label", "path");
+	printf("%3s %12s %6s %-15s %s\n",
+	       "dev", "blocks", "blksz", "label", "path");
 	if (dev) {
 		show_host_dev(dev);
 	} else {
diff --git a/test/dm/host.c b/test/dm/host.c
index 19f6c67462..580b14cf79 100644
--- a/test/dm/host.c
+++ b/test/dm/host.c
@@ -114,7 +114,7 @@ static int dm_test_cmd_host(struct unit_test_state *uts)
 
 	/* first check 'host info' with binding */
 	ut_assertok(run_command("host info", 0));
-	ut_assert_nextline("dev       blocks label           path");
+	ut_assert_nextline("dev       blocks  blksz label           path");
 	ut_assert_console_end();
 
 	ut_assertok(run_commandf("host bind -r test2 %s", filename));
@@ -126,8 +126,8 @@ static int dm_test_cmd_host(struct unit_test_state *uts)
 	ut_asserteq(true, desc->removable);
 
 	ut_assertok(run_command("host info", 0));
-	ut_assert_nextline("dev       blocks label           path");
-	ut_assert_nextline("  0         4096 test2           2MB.ext2.img");
+	ut_assert_nextline("dev       blocks  blksz label           path");
+	ut_assert_nextline("  0         4096    512 test2           2MB.ext2.img");
 	ut_assert_console_end();
 
 	ut_assertok(run_commandf("host bind fat %s", filename2));
@@ -139,9 +139,9 @@ static int dm_test_cmd_host(struct unit_test_state *uts)
 	ut_asserteq(false, desc->removable);
 
 	ut_assertok(run_command("host info", 0));
-	ut_assert_nextline("dev       blocks label           path");
-	ut_assert_nextline("  0         4096 test2           2MB.ext2.img");
-	ut_assert_nextline("  1         2048 fat             1MB.fat32.img");
+	ut_assert_nextline("dev       blocks  blksz label           path");
+	ut_assert_nextline("  0         4096    512 test2           2MB.ext2.img");
+	ut_assert_nextline("  1         2048    512 fat             1MB.fat32.img");
 	ut_assert_console_end();
 
 	ut_asserteq(1, run_command("host info test", 0));
@@ -149,8 +149,8 @@ static int dm_test_cmd_host(struct unit_test_state *uts)
 	ut_assert_console_end();
 
 	ut_assertok(run_command("host info fat", 0));
-	ut_assert_nextline("dev       blocks label           path");
-	ut_assert_nextline("  1         2048 fat             1MB.fat32.img");
+	ut_assert_nextline("dev       blocks  blksz label           path");
+	ut_assert_nextline("  1         2048    512 fat             1MB.fat32.img");
 	ut_assert_console_end();
 
 	/* check 'host dev' */
@@ -186,8 +186,8 @@ static int dm_test_cmd_host(struct unit_test_state *uts)
 	ut_assert_console_end();
 
 	ut_assertok(run_command("host info", 0));
-	ut_assert_nextline("dev       blocks label           path");
-	ut_assert_nextline("  1         2048 fat             1MB.fat32.img");
+	ut_assert_nextline("dev       blocks  blksz label           path");
+	ut_assert_nextline("  1         2048    512 fat             1MB.fat32.img");
 	ut_assert_console_end();
 
 	return 0;
-- 
2.25.1



More information about the U-Boot mailing list