Skip to contentSkip to conversation

fadump: Use str_yes_no() helper in fadump_show_config()

PATCH Superseded Thorsten Blum 3 participants 3 messages Dec 30, 2024 – Jan 13, 2025 PowerPC

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 fadump: Use str_yes_no() helper in fadump_show_config()

Remove hard-coded strings by using the str_yes_no() helper function.

---
 arch/powerpc/kernel/fadump.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)
arch/powerpc/kernel/fadump.c +2 -4
index 4b371c738213..8c531533dd3e 100644
@@ -289,10 +289,8 @@ static void __init fadump_show_config(void)
 	if (!fw_dump.fadump_supported)
 		return;
 
-	pr_debug("Fadump enabled    : %s\n",
-				(fw_dump.fadump_enabled ? "yes" : "no"));
-	pr_debug("Dump Active       : %s\n",
-				(fw_dump.dump_active ? "yes" : "no"));
+	pr_debug("Fadump enabled    : %s\n", str_yes_no(fw_dump.fadump_enabled));
+	pr_debug("Dump Active       : %s\n", str_yes_no(fw_dump.dump_active));
 	pr_debug("Dump section sizes:\n");
 	pr_debug("    CPU state data size: %lx\n", fw_dump.cpu_state_data_size);
 	pr_debug("    HPTE region size   : %lx\n", fw_dump.hpte_region_size);
Signature · 1 line
2.47.1
Reviewed-by on v1 1/1
#1 lore raw
Quoted 14 lines · Thorsten Blum

Remove hard-coded strings by using the str_yes_no() helper function.

---
  arch/powerpc/kernel/fadump.c | 6 ++----
  1 file changed, 2 insertions(+), 4 deletions(-)
arch/powerpc/kernel/fadump.c +0 -0
index 4b371c738213..8c531533dd3e 100644
@@ -289,10 +289,8 @@ static void __init fadump_show_config(void)
  	if (!fw_dump.fadump_supported)
  		return;

arch/powerpc/kernel/fadump.c static void __init fadump_show_config(void) · line 296

Quoted 10 lines
arch/powerpc/kernel/fadump.c +2 -4
 
-	pr_debug("Fadump enabled    : %s\n",
-				(fw_dump.fadump_enabled ? "yes" : "no"));
-	pr_debug("Dump Active       : %s\n",
-				(fw_dump.dump_active ? "yes" : "no"));
+	pr_debug("Fadump enabled    : %s\n", str_yes_no(fw_dump.fadump_enabled));
+	pr_debug("Dump Active       : %s\n", str_yes_no(fw_dump.dump_active));
  	pr_debug("Dump section sizes:\n");
  	pr_debug("    CPU state data size: %lx\n", fw_dump.cpu_state_data_size);
  	pr_debug("    HPTE region size   : %lx\n", fw_dump.hpte_region_size);

Yes, it is better to use str_yes_no() instead of hard-coded strings.

I have also tested your patch, and everything is working fine.

Thanks,
Sourabh Jain

reviewer Reviewed-by on v1 1/1
#2 lore raw
In reply to Thorsten Blum
Quoted 6 lines · Thorsten Blum

Remove hard-coded strings by using the str_yes_no() helper function.

---
 arch/powerpc/kernel/fadump.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

In fadump.c file we have implicit include of string_choices.h i.e.

    include/linux/seq_file.h -> linux/string_helpers.h -> linux/string_choices.h 

Directly having string_choices include could be better.

    #include <linux/string_choices.h>

However no hard preferences. The patch functionally looks correct to me.

Please feel free to add -

Quoted 20 lines
arch/powerpc/kernel/fadump.c +2 -4
index 4b371c738213..8c531533dd3e 100644
@@ -289,10 +289,8 @@ static void __init fadump_show_config(void)
 	if (!fw_dump.fadump_supported)
 		return;
 
-	pr_debug("Fadump enabled    : %s\n",
-				(fw_dump.fadump_enabled ? "yes" : "no"));
-	pr_debug("Dump Active       : %s\n",
-				(fw_dump.dump_active ? "yes" : "no"));
+	pr_debug("Fadump enabled    : %s\n", str_yes_no(fw_dump.fadump_enabled));
+	pr_debug("Dump Active       : %s\n", str_yes_no(fw_dump.dump_active));
 	pr_debug("Dump section sizes:\n");
 	pr_debug("    CPU state data size: %lx\n", fw_dump.cpu_state_data_size);
 	pr_debug("    HPTE region size   : %lx\n", fw_dump.hpte_region_size);
Signature · 1 line
2.47.1