diff mbox series

[041/120] MIPS: PS2: ROM: Resolve the name for the type in the ROMVER file

Message ID 6a096d0e6a7532194907863bc0286059fddb7bef.1567326213.git.noring@nocrew.org (mailing list archive)
State RFC
Headers show
Series Linux for the PlayStation 2 | expand

Commit Message

Fredrik Noring Sept. 1, 2019, 3:52 p.m. UTC
'C' indicates CEX for retail, 'D' indicates DEX for debug, and 'T'
indicates a TOOL machine.

Signed-off-by: Fredrik Noring <noring@nocrew.org>
---
 arch/mips/include/asm/mach-ps2/rom.h |  4 ++++
 arch/mips/ps2/rom.c                  | 20 ++++++++++++++++++--
 2 files changed, 22 insertions(+), 2 deletions(-)
diff mbox series

Patch

diff --git a/arch/mips/include/asm/mach-ps2/rom.h b/arch/mips/include/asm/mach-ps2/rom.h
index 42e520f32f65..0b0e7c4162f5 100644
--- a/arch/mips/include/asm/mach-ps2/rom.h
+++ b/arch/mips/include/asm/mach-ps2/rom.h
@@ -135,6 +135,8 @@  struct rom_extinfo rom_read_extinfo(const char *name,
  * @date.month: month ROM was created
  * @date.day: day ROM was created
  *
+ * The @type name can be resolved with rom_type_name().
+ *
  * Note that the Namco System 246 arcade systems are TOOL types as well.
  *
  * A ROM version is considered to be invalid if @number is zero, in which
@@ -153,6 +155,8 @@  struct rom_ver {
 
 struct rom_ver rom_version(void);
 
+const char *rom_type_name(char type);
+
 bool rom_empty_dir(const struct rom_dir dir);
 
 bool rom_terminating_file(const struct rom_file file);
diff --git a/arch/mips/ps2/rom.c b/arch/mips/ps2/rom.c
index 32ae8ec839c4..9adea705cbca 100644
--- a/arch/mips/ps2/rom.c
+++ b/arch/mips/ps2/rom.c
@@ -383,6 +383,22 @@  struct rom_ver rom_version(void)
 }
 EXPORT_SYMBOL_GPL(rom_version);
 
+/**
+ * rom_type_name - name for the ROM type character in the ROMVER file in ROM0
+ * @type: &rom_ver.type type character.
+ *
+ * Context: any
+ * Return: ROM type name, ``"-"`` if undefined or ``"?"`` if unrecognised
+ */
+const char *rom_type_name(char type)
+{
+	return type == 'C' ? "CEX" :
+	       type == 'D' ? "DEX" :
+	       type == 'T' ? "TOOL" :
+	       type == '-' ? "-" : "?";
+}
+EXPORT_SYMBOL_GPL(rom_type_name);
+
 /**
  * find_reset_string - find the offset to the ``"RESET"`` string, if it exists
  * @rom: ROM to search in
@@ -659,8 +675,8 @@  static int __init ps2_rom_init(void)
 	rom1_dir = rom_dir_init("rom1", ROM1_BASE, ROM1_SIZE);
 
 	v = rom_version();
-	pr_info("rom0: Version %04x %c %c %04d-%02d-%02d\n",
-		v.number, v.region, v.type,
+	pr_info("rom0: Version %04x %c %s %04d-%02d-%02d\n",
+		v.number, v.region, rom_type_name(v.type),
 		v.date.year, v.date.month, v.date.day);
 
 	return 0;