* [PATCH] cpufreq: Use str_enable_disable-like helpers
@ 2025-01-14 10:56 Krzysztof Kozlowski
2025-01-14 18:23 ` Krzysztof Kozlowski
0 siblings, 1 reply; 2+ messages in thread
From: Krzysztof Kozlowski @ 2025-01-14 10:56 UTC (permalink / raw)
To: Rafael J. Wysocki, Viresh Kumar, Michael Ellerman,
Nicholas Piggin, Christophe Leroy, Naveen N Rao,
Madhavan Srinivasan, linux-pm, linux-kernel, linuxppc-dev
Cc: Krzysztof Kozlowski
Replace ternary (condition ? "enable" : "disable") syntax with helpers
from string_choices.h because:
1. Simple function call with one argument is easier to read. Ternary
operator has three arguments and with wrapping might lead to quite
long code.
2. Is slightly shorter thus also easier to read.
3. It brings uniformity in the text - same string.
4. Allows deduping by the linker, which results in a smaller binary
file.
Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
---
drivers/cpufreq/cpufreq.c | 7 ++++---
drivers/cpufreq/powernv-cpufreq.c | 3 ++-
2 files changed, 6 insertions(+), 4 deletions(-)
diff --git a/drivers/cpufreq/cpufreq.c b/drivers/cpufreq/cpufreq.c
index 418236fef172..fba62124b56a 100644
--- a/drivers/cpufreq/cpufreq.c
+++ b/drivers/cpufreq/cpufreq.c
@@ -25,6 +25,7 @@
#include <linux/mutex.h>
#include <linux/pm_qos.h>
#include <linux/slab.h>
+#include <linux/string_choices.h>
#include <linux/suspend.h>
#include <linux/syscore_ops.h>
#include <linux/tick.h>
@@ -602,12 +603,12 @@ static ssize_t store_boost(struct kobject *kobj, struct kobj_attribute *attr,
if (cpufreq_boost_trigger_state(enable)) {
pr_err("%s: Cannot %s BOOST!\n",
- __func__, enable ? "enable" : "disable");
+ __func__, str_enable_disable(enable));
return -EINVAL;
}
pr_debug("%s: cpufreq BOOST %s\n",
- __func__, enable ? "enabled" : "disabled");
+ __func__, str_enable_disable(enable));
return count;
}
@@ -2812,7 +2813,7 @@ int cpufreq_boost_trigger_state(int state)
write_unlock_irqrestore(&cpufreq_driver_lock, flags);
pr_err("%s: Cannot %s BOOST\n",
- __func__, state ? "enable" : "disable");
+ __func__, str_enable_disable(state));
return ret;
}
diff --git a/drivers/cpufreq/powernv-cpufreq.c b/drivers/cpufreq/powernv-cpufreq.c
index 8de759247771..ae79d909943b 100644
--- a/drivers/cpufreq/powernv-cpufreq.c
+++ b/drivers/cpufreq/powernv-cpufreq.c
@@ -18,6 +18,7 @@
#include <linux/of.h>
#include <linux/reboot.h>
#include <linux/slab.h>
+#include <linux/string_choices.h>
#include <linux/cpu.h>
#include <linux/hashtable.h>
#include <trace/events/power.h>
@@ -281,7 +282,7 @@ static int init_powernv_pstates(void)
pr_info("cpufreq pstate min 0x%x nominal 0x%x max 0x%x\n", pstate_min,
pstate_nominal, pstate_max);
pr_info("Workload Optimized Frequency is %s in the platform\n",
- (powernv_pstate_info.wof_enabled) ? "enabled" : "disabled");
+ str_enabled_disabled(powernv_pstate_info.wof_enabled));
pstate_ids = of_get_property(power_mgt, "ibm,pstate-ids", &len_ids);
if (!pstate_ids) {
--
2.43.0
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [PATCH] cpufreq: Use str_enable_disable-like helpers
2025-01-14 10:56 [PATCH] cpufreq: Use str_enable_disable-like helpers Krzysztof Kozlowski
@ 2025-01-14 18:23 ` Krzysztof Kozlowski
0 siblings, 0 replies; 2+ messages in thread
From: Krzysztof Kozlowski @ 2025-01-14 18:23 UTC (permalink / raw)
To: Rafael J. Wysocki, Viresh Kumar, Michael Ellerman,
Nicholas Piggin, Christophe Leroy, Naveen N Rao,
Madhavan Srinivasan, linux-pm, linux-kernel, linuxppc-dev
On 14/01/2025 11:56, Krzysztof Kozlowski wrote:
> if (cpufreq_boost_trigger_state(enable)) {
> pr_err("%s: Cannot %s BOOST!\n",
> - __func__, enable ? "enable" : "disable");
> + __func__, str_enable_disable(enable));
> return -EINVAL;
> }
>
> pr_debug("%s: cpufreq BOOST %s\n",
> - __func__, enable ? "enabled" : "disabled");
> + __func__, str_enable_disable(enable));
This needs fix - enabled, not enable. V2.
Best regards,
Krzysztof
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2025-01-14 18:23 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2025-01-14 10:56 [PATCH] cpufreq: Use str_enable_disable-like helpers Krzysztof Kozlowski
2025-01-14 18:23 ` Krzysztof Kozlowski
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®