linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2] clk: Use str_enable_disable-like helpers
@ 2025-01-14 19:06 Krzysztof Kozlowski
  2025-01-14 20:26 ` Stephen Boyd
  2025-01-15  7:21 ` Stanislav Jakubek
  0 siblings, 2 replies; 4+ messages in thread
From: Krzysztof Kozlowski @ 2025-01-14 19:06 UTC (permalink / raw)
  To: Michael Turquette, Stephen Boyd, Florian Fainelli, Ray Jui,
	Scott Branden, Broadcom internal kernel review list,
	Linus Walleij, Bjorn Andersson, linux-clk, linux-kernel,
	linux-arm-kernel, linux-arm-msm
  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.

Reviewed-by: Florian Fainelli <florian.fainelli@broadcom.com>
Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>

---

Changes in v2:
1. Also: drivers/clk/clk-xgene.c
2. Rb tag
---
 drivers/clk/bcm/clk-kona.c  | 3 ++-
 drivers/clk/clk-nomadik.c   | 5 +++--
 drivers/clk/clk-xgene.c     | 4 ++--
 drivers/clk/qcom/clk-rpmh.c | 3 ++-
 4 files changed, 9 insertions(+), 6 deletions(-)

diff --git a/drivers/clk/bcm/clk-kona.c b/drivers/clk/bcm/clk-kona.c
index ec5749e301ba..2b0ea882f1e4 100644
--- a/drivers/clk/bcm/clk-kona.c
+++ b/drivers/clk/bcm/clk-kona.c
@@ -10,6 +10,7 @@
 #include <linux/io.h>
 #include <linux/kernel.h>
 #include <linux/clk-provider.h>
+#include <linux/string_choices.h>
 
 /*
  * "Policies" affect the frequencies of bus clocks provided by a
@@ -502,7 +503,7 @@ static int clk_gate(struct ccu_data *ccu, const char *name,
 		return 0;
 
 	pr_err("%s: failed to %s gate for %s\n", __func__,
-		enable ? "enable" : "disable", name);
+		str_enable_disable(enable), name);
 
 	return -EIO;
 }
diff --git a/drivers/clk/clk-nomadik.c b/drivers/clk/clk-nomadik.c
index 06245681dac7..f3a73ac5a1b9 100644
--- a/drivers/clk/clk-nomadik.c
+++ b/drivers/clk/clk-nomadik.c
@@ -17,6 +17,7 @@
 #include <linux/debugfs.h>
 #include <linux/seq_file.h>
 #include <linux/spinlock.h>
+#include <linux/string_choices.h>
 #include <linux/reboot.h>
 
 /*
@@ -116,9 +117,9 @@ static void __init nomadik_src_init(void)
 
 	val = readl(src_base + SRC_XTALCR);
 	pr_info("SXTALO is %s\n",
-		(val & SRC_XTALCR_SXTALDIS) ? "disabled" : "enabled");
+		str_enabled_disabled(val & SRC_XTALCR_SXTALDIS));
 	pr_info("MXTAL is %s\n",
-		(val & SRC_XTALCR_MXTALSTAT) ? "enabled" : "disabled");
+		str_enabled_disabled(val & SRC_XTALCR_MXTALSTAT));
 	if (of_property_read_bool(np, "disable-sxtalo")) {
 		/* The machine uses an external oscillator circuit */
 		val |= SRC_XTALCR_SXTALDIS;
diff --git a/drivers/clk/clk-xgene.c b/drivers/clk/clk-xgene.c
index 0c3d0cee98c8..96946a8e2854 100644
--- a/drivers/clk/clk-xgene.c
+++ b/drivers/clk/clk-xgene.c
@@ -7,6 +7,7 @@
  */
 #include <linux/module.h>
 #include <linux/spinlock.h>
+#include <linux/string_choices.h>
 #include <linux/io.h>
 #include <linux/of.h>
 #include <linux/clkdev.h>
@@ -520,8 +521,7 @@ static int xgene_clk_is_enabled(struct clk_hw *hw)
 		data = xgene_clk_read(pclk->param.csr_reg +
 					pclk->param.reg_clk_offset);
 		pr_debug("%s clock is %s\n", clk_hw_get_name(hw),
-			data & pclk->param.reg_clk_mask ? "enabled" :
-							"disabled");
+			str_enabled_disabled(data & pclk->param.reg_clk_mask));
 	} else {
 		return 1;
 	}
diff --git a/drivers/clk/qcom/clk-rpmh.c b/drivers/clk/qcom/clk-rpmh.c
index 18de31889525..c7675930fde1 100644
--- a/drivers/clk/qcom/clk-rpmh.c
+++ b/drivers/clk/qcom/clk-rpmh.c
@@ -9,6 +9,7 @@
 #include <linux/module.h>
 #include <linux/of.h>
 #include <linux/platform_device.h>
+#include <linux/string_choices.h>
 #include <soc/qcom/cmd-db.h>
 #include <soc/qcom/rpmh.h>
 #include <soc/qcom/tcs.h>
@@ -206,7 +207,7 @@ static int clk_rpmh_aggregate_state_send_command(struct clk_rpmh *c,
 		c->state = c->valid_state_mask;
 
 	WARN(1, "clk: %s failed to %s\n", c->res_name,
-	     enable ? "enable" : "disable");
+	     str_enable_disable(enable));
 	return ret;
 }
 
-- 
2.43.0



^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH v2] clk: Use str_enable_disable-like helpers
  2025-01-14 19:06 [PATCH v2] clk: Use str_enable_disable-like helpers Krzysztof Kozlowski
@ 2025-01-14 20:26 ` Stephen Boyd
  2025-01-15  7:21 ` Stanislav Jakubek
  1 sibling, 0 replies; 4+ messages in thread
From: Stephen Boyd @ 2025-01-14 20:26 UTC (permalink / raw)
  To: Bjorn Andersson, Broadcom internal kernel review list,
	Florian Fainelli, Krzysztof Kozlowski, Linus Walleij,
	Michael Turquette, Ray Jui, Scott Branden, linux-arm-kernel,
	linux-arm-msm, linux-clk, linux-kernel
  Cc: Krzysztof Kozlowski

Quoting Krzysztof Kozlowski (2025-01-14 11:06:12)
> 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.
> 
> Reviewed-by: Florian Fainelli <florian.fainelli@broadcom.com>
> Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
> 
> ---

Applied to clk-next


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH v2] clk: Use str_enable_disable-like helpers
  2025-01-14 19:06 [PATCH v2] clk: Use str_enable_disable-like helpers Krzysztof Kozlowski
  2025-01-14 20:26 ` Stephen Boyd
@ 2025-01-15  7:21 ` Stanislav Jakubek
  2025-01-15  8:10   ` Krzysztof Kozlowski
  1 sibling, 1 reply; 4+ messages in thread
From: Stanislav Jakubek @ 2025-01-15  7:21 UTC (permalink / raw)
  To: Krzysztof Kozlowski
  Cc: Michael Turquette, Stephen Boyd, Florian Fainelli, Ray Jui,
	Scott Branden, Broadcom internal kernel review list,
	Linus Walleij, Bjorn Andersson, linux-clk, linux-kernel,
	linux-arm-kernel, linux-arm-msm

Hi Krzysztof, 1 note below.

On Tue, Jan 14, 2025 at 08:06:12PM +0100, Krzysztof Kozlowski wrote:
> Replace ternary (condition ? "enable" : "disable") syntax with helpers
> from string_choices.h because:

[snip]

> diff --git a/drivers/clk/clk-nomadik.c b/drivers/clk/clk-nomadik.c
> index 06245681dac7..f3a73ac5a1b9 100644
> --- a/drivers/clk/clk-nomadik.c
> +++ b/drivers/clk/clk-nomadik.c
> @@ -17,6 +17,7 @@
>  #include <linux/debugfs.h>
>  #include <linux/seq_file.h>
>  #include <linux/spinlock.h>
> +#include <linux/string_choices.h>
>  #include <linux/reboot.h>
>  
>  /*
> @@ -116,9 +117,9 @@ static void __init nomadik_src_init(void)
>  
>  	val = readl(src_base + SRC_XTALCR);
>  	pr_info("SXTALO is %s\n",
> -		(val & SRC_XTALCR_SXTALDIS) ? "disabled" : "enabled");
> +		str_enabled_disabled(val & SRC_XTALCR_SXTALDIS));

It seems like you flipped the logic here. Was this intentional?

Regards,
Stanislav


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH v2] clk: Use str_enable_disable-like helpers
  2025-01-15  7:21 ` Stanislav Jakubek
@ 2025-01-15  8:10   ` Krzysztof Kozlowski
  0 siblings, 0 replies; 4+ messages in thread
From: Krzysztof Kozlowski @ 2025-01-15  8:10 UTC (permalink / raw)
  To: Stanislav Jakubek
  Cc: Michael Turquette, Stephen Boyd, Florian Fainelli, Ray Jui,
	Scott Branden, Broadcom internal kernel review list,
	Linus Walleij, Bjorn Andersson, linux-clk, linux-kernel,
	linux-arm-kernel, linux-arm-msm

On 15/01/2025 08:21, Stanislav Jakubek wrote:
> Hi Krzysztof, 1 note below.
> 
> On Tue, Jan 14, 2025 at 08:06:12PM +0100, Krzysztof Kozlowski wrote:
>> Replace ternary (condition ? "enable" : "disable") syntax with helpers
>> from string_choices.h because:
> 
> [snip]
> 
>> diff --git a/drivers/clk/clk-nomadik.c b/drivers/clk/clk-nomadik.c
>> index 06245681dac7..f3a73ac5a1b9 100644
>> --- a/drivers/clk/clk-nomadik.c
>> +++ b/drivers/clk/clk-nomadik.c
>> @@ -17,6 +17,7 @@
>>  #include <linux/debugfs.h>
>>  #include <linux/seq_file.h>
>>  #include <linux/spinlock.h>
>> +#include <linux/string_choices.h>
>>  #include <linux/reboot.h>
>>  
>>  /*
>> @@ -116,9 +117,9 @@ static void __init nomadik_src_init(void)
>>  
>>  	val = readl(src_base + SRC_XTALCR);
>>  	pr_info("SXTALO is %s\n",
>> -		(val & SRC_XTALCR_SXTALDIS) ? "disabled" : "enabled");
>> +		str_enabled_disabled(val & SRC_XTALCR_SXTALDIS));
> 
> It seems like you flipped the logic here. Was this intentional?
No, overlook. Thanks for noticing.

Best regards,
Krzysztof


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2025-01-15  8:11 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-01-14 19:06 [PATCH v2] clk: Use str_enable_disable-like helpers Krzysztof Kozlowski
2025-01-14 20:26 ` Stephen Boyd
2025-01-15  7:21 ` Stanislav Jakubek
2025-01-15  8:10   ` Krzysztof Kozlowski

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).