Skip to contentSkip to conversation

powerpc: Use str_enabled_disabled() helper function

PATCH Applied Thorsten Blum 3 participants 3 messages Oct 27, 2024 – Nov 17, 2024 PowerPC

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 powerpc: Use str_enabled_disabled() helper function

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

---
 arch/powerpc/kernel/secure_boot.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
arch/powerpc/kernel/secure_boot.c +3 -2
index 9e0efb657f39..3a28795b4ed8 100644
@@ -5,6 +5,7 @@
  */
 #include <linux/types.h>
 #include <linux/of.h>
+#include <linux/string_choices.h>
 #include <asm/secure_boot.h>
 
 static struct device_node *get_ppc_fw_sb_node(void)
@@ -38,7 +39,7 @@ bool is_ppc_secureboot_enabled(void)
 	of_node_put(node);
 
 out:
-	pr_info("Secure boot mode %s\n", enabled ? "enabled" : "disabled");
+	pr_info("Secure boot mode %s\n", str_enabled_disabled(enabled));
 
 	return enabled;
 }
@@ -62,7 +63,7 @@ bool is_ppc_trustedboot_enabled(void)
 	of_node_put(node);
 
 out:
-	pr_info("Trusted boot mode %s\n", enabled ? "enabled" : "disabled");
+	pr_info("Trusted boot mode %s\n", str_enabled_disabled(enabled));
 
 	return enabled;
 }
Signature · 1 line
2.47.0
reviewer Reviewed-by on v1 1/1
#1 lore raw
Quoted 3 lines · Thorsten Blum

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

Looks like now a days LKP also reports this - e.g. [1] "opportunity for str_enabled_disabled(enable)"

[1]: https://lore.kernel.org/all/[email protected]/

I see more such oppotunities for later improvements in arch/powerpc/ root-> git grep "\"enabled\" : \"disabled\"" arch/powerpc/
arch/powerpc/kernel/secure_boot.c: pr_info("Secure boot mode %s\n", enabled ? "enabled" : "disabled");
arch/powerpc/kernel/secure_boot.c: pr_info("Trusted boot mode %s\n", enabled ? "enabled" : "disabled");
arch/powerpc/platforms/powermac/setup.c: "enabled" : "disabled");
arch/powerpc/sysdev/mpic.c: flags & HT_MSI_FLAGS_ENABLE ? "enabled" : "disabled", addr);

Quoted 5 lines
---
 arch/powerpc/kernel/secure_boot.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

For this patch it looks good to me. Please feel free to add -

Quoted 32 lines
arch/powerpc/kernel/secure_boot.c +3 -2
index 9e0efb657f39..3a28795b4ed8 100644
@@ -5,6 +5,7 @@
  */
 #include <linux/types.h>
 #include <linux/of.h>
+#include <linux/string_choices.h>
 #include <asm/secure_boot.h>
 
 static struct device_node *get_ppc_fw_sb_node(void)
@@ -38,7 +39,7 @@ bool is_ppc_secureboot_enabled(void)
 	of_node_put(node);
 
 out:
-	pr_info("Secure boot mode %s\n", enabled ? "enabled" : "disabled");
+	pr_info("Secure boot mode %s\n", str_enabled_disabled(enabled));
 
 	return enabled;
 }
@@ -62,7 +63,7 @@ bool is_ppc_trustedboot_enabled(void)
 	of_node_put(node);
 
 out:
-	pr_info("Trusted boot mode %s\n", enabled ? "enabled" : "disabled");
+	pr_info("Trusted boot mode %s\n", str_enabled_disabled(enabled));
 
 	return enabled;
 }
Signature · 1 line
2.47.0