[Skiboot] [RFC PATCH 03/13] external/pflash: Use ffs_entry_user_to_string() to standardise flag strings

Cyril Bur cyril.bur at au1.ibm.com
Tue Aug 29 16:24:56 AEST 2017


Signed-off-by: Cyril Bur <cyril.bur at au1.ibm.com>
---
 external/pflash/pflash.c                 | 14 +++++---------
 external/pflash/test/results/01-info.out | 10 +++++-----
 2 files changed, 10 insertions(+), 14 deletions(-)

diff --git a/external/pflash/pflash.c b/external/pflash/pflash.c
index a08ea946..3be43ac0 100644
--- a/external/pflash/pflash.c
+++ b/external/pflash/pflash.c
@@ -101,8 +101,8 @@ static uint32_t print_ffs_info(struct ffs_handle *ffsh, uint32_t toc)
 
 	for (i = 0;; i++) {
 		uint32_t start, size, act, end;
+		struct ffs_entry_user user;
 		char *name = NULL, *flags;
-		int l;
 
 		rc = ffs_part_info(ffsh, i, &name, &start, &size, &act, NULL);
 		if (rc == FFS_ERR_PART_NOT_FOUND)
@@ -115,17 +115,13 @@ static uint32_t print_ffs_info(struct ffs_handle *ffsh, uint32_t toc)
 		    goto out;
 		}
 
-		l = asprintf(&flags, "[%c%c%c%c%c]",
-				has_ecc(ent) ? 'E' : '-',
-				has_flag(ent, FFS_MISCFLAGS_PRESERVED) ? 'P' : '-',
-				has_flag(ent, FFS_MISCFLAGS_READONLY) ? 'R' : '-',
-				has_flag(ent, FFS_MISCFLAGS_BACKUP) ? 'B' : '-',
-				has_flag(ent, FFS_MISCFLAGS_REPROVISION) ? 'F' : '-');
-		if (l < 0)
+		user = ffs_entry_user_get(ent);
+		flags = ffs_entry_user_to_string(&user);
+		if (!flags)
 			goto out;
 
 		end = start + size;
-		printf("ID=%02d %15s 0x%08x..0x%08x (actual=0x%08x) %s\n",
+		printf("ID=%02d %15s 0x%08x..0x%08x (actual=0x%08x) [%s]\n",
 				i, name, start, end, act, flags);
 
 		if (strcmp(name, "OTHER_SIDE") == 0)
diff --git a/external/pflash/test/results/01-info.out b/external/pflash/test/results/01-info.out
index 43baf316..840890f4 100644
--- a/external/pflash/test/results/01-info.out
+++ b/external/pflash/test/results/01-info.out
@@ -6,8 +6,8 @@ Erase granule =  0KB           B:BACKUP, F:REPROVISION
 
 TOC at 0x00000000 Partitions:
 -----------
-ID=00            part 0x00000000..0x00000300 (actual=0x00000300) [-----]
-ID=01             ONE 0x00000300..0x00000400 (actual=0x00000100) [E----]
-ID=02             TWO 0x00000400..0x00000500 (actual=0x00000100) [E---F]
-ID=03           THREE 0x00000500..0x00000600 (actual=0x00000100) [E---F]
-ID=04            FOUR 0x00000600..0x00000700 (actual=0x00000100) [E---F]
+ID=00            part 0x00000000..0x00000300 (actual=0x00000300) [-------]
+ID=01             ONE 0x00000300..0x00000400 (actual=0x00000100) [EV-----]
+ID=02             TWO 0x00000400..0x00000500 (actual=0x00000100) [E-----F]
+ID=03           THREE 0x00000500..0x00000600 (actual=0x00000100) [E-----F]
+ID=04            FOUR 0x00000600..0x00000700 (actual=0x00000100) [E-----F]
-- 
2.14.1



More information about the Skiboot mailing list