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

Cyril Bur cyril.bur at au1.ibm.com
Thu Mar 15 16:58:15 AEDT 2018


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

diff --git a/external/pflash/pflash.c b/external/pflash/pflash.c
index 3ac94849..3bc84758 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,19 +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%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' : '-',
-				has_flag(ent, FFS_MISCFLAGS_VOLATILE) ? 'V' : '-',
-				has_flag(ent, FFS_MISCFLAGS_CLEARECC) ? 'C' : '-');
-		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 7377c71a..6dfa9216 100644
--- a/external/pflash/test/results/01-info.out
+++ b/external/pflash/test/results/01-info.out
@@ -6,10 +6,10 @@ Erase granule =  0KB           F:REPROVISION, V:VOLATILE, C:CLEARECC
 
 TOC at 0x00000000 Partitions:
 -----------
-ID=00            part 0x00000000..0x00001000 (actual=0x00001000) [-------]
-ID=01             ONE 0x00003000..0x00004000 (actual=0x00001000) [E----V-]
-ID=02             TWO 0x00004000..0x00005000 (actual=0x00001000) [E---F--]
-ID=03           THREE 0x00005000..0x00006000 (actual=0x00001000) [E---F--]
-ID=04            FOUR 0x00006000..0x00007000 (actual=0x00001000) [E---F--]
-ID=05            FIVE 0x00007000..0x00008000 (actual=0x00001000) [-------]
-ID=06             SIX 0x00008000..0x00009000 (actual=0x00001000) [------C]
+ID=00            part 0x00000000..0x00001000 (actual=0x00001000) [----------]
+ID=01             ONE 0x00003000..0x00004000 (actual=0x00001000) [E--------V]
+ID=02             TWO 0x00004000..0x00005000 (actual=0x00001000) [E-----F---]
+ID=03           THREE 0x00005000..0x00006000 (actual=0x00001000) [E-----F---]
+ID=04            FOUR 0x00006000..0x00007000 (actual=0x00001000) [E-----F---]
+ID=05            FIVE 0x00007000..0x00008000 (actual=0x00001000) [-L--------]
+ID=06             SIX 0x00008000..0x00009000 (actual=0x00001000) [--------C-]
-- 
2.16.2



More information about the Skiboot mailing list