linux-clk.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH][next] clk: moxart: Make read-only array div_idx static const
@ 2025-06-19  8:30 Colin Ian King
  2025-06-19 17:42 ` Krzysztof Kozlowski
  2025-06-19 19:53 ` Stephen Boyd
  0 siblings, 2 replies; 5+ messages in thread
From: Colin Ian King @ 2025-06-19  8:30 UTC (permalink / raw)
  To: Krzysztof Kozlowski, Michael Turquette, Stephen Boyd,
	linux-arm-kernel, linux-clk
  Cc: kernel-janitors, linux-kernel

Don't populate the read-only array div_idx on the stack at run time,
instead make it static const.

Signed-off-by: Colin Ian King <colin.i.king@gmail.com>
---
 drivers/clk/clk-moxart.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/clk/clk-moxart.c b/drivers/clk/clk-moxart.c
index 3786a0153ad1..4d34d1d18dbd 100644
--- a/drivers/clk/clk-moxart.c
+++ b/drivers/clk/clk-moxart.c
@@ -58,7 +58,7 @@ static void __init moxart_of_apb_clk_init(struct device_node *node)
 	struct clk_hw *hw;
 	struct clk *pll_clk;
 	unsigned int div, val;
-	unsigned int div_idx[] = { 2, 3, 4, 6, 8};
+	static const unsigned int div_idx[] = { 2, 3, 4, 6, 8};
 	const char *name = node->name;
 	const char *parent_name;
 
-- 
2.49.0


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

* Re: [PATCH][next] clk: moxart: Make read-only array div_idx static const
  2025-06-19  8:30 [PATCH][next] clk: moxart: Make read-only array div_idx static const Colin Ian King
@ 2025-06-19 17:42 ` Krzysztof Kozlowski
  2025-06-19 19:53 ` Stephen Boyd
  1 sibling, 0 replies; 5+ messages in thread
From: Krzysztof Kozlowski @ 2025-06-19 17:42 UTC (permalink / raw)
  To: Colin Ian King, Michael Turquette, Stephen Boyd, linux-arm-kernel,
	linux-clk
  Cc: kernel-janitors, linux-kernel

On 19/06/2025 10:30, Colin Ian King wrote:
> Don't populate the read-only array div_idx on the stack at run time,
> instead make it static const.
> 
> Signed-off-by: Colin Ian King <colin.i.king@gmail.com>
> ---

Reviewed-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>

Best regards,
Krzysztof

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

* Re: [PATCH][next] clk: moxart: Make read-only array div_idx static const
  2025-06-19  8:30 [PATCH][next] clk: moxart: Make read-only array div_idx static const Colin Ian King
  2025-06-19 17:42 ` Krzysztof Kozlowski
@ 2025-06-19 19:53 ` Stephen Boyd
  2025-06-19 20:18   ` Krzysztof Kozlowski
  1 sibling, 1 reply; 5+ messages in thread
From: Stephen Boyd @ 2025-06-19 19:53 UTC (permalink / raw)
  To: Colin Ian King, Krzysztof Kozlowski, Michael Turquette,
	linux-arm-kernel, linux-clk
  Cc: kernel-janitors, linux-kernel

Quoting Colin Ian King (2025-06-19 01:30:35)
> Don't populate the read-only array div_idx on the stack at run time,
> instead make it static const.

Why? This is in __init code so it can be thrown away if it stays on the
stack.

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

* Re: [PATCH][next] clk: moxart: Make read-only array div_idx static const
  2025-06-19 19:53 ` Stephen Boyd
@ 2025-06-19 20:18   ` Krzysztof Kozlowski
  2025-06-20  5:33     ` Krzysztof Kozlowski
  0 siblings, 1 reply; 5+ messages in thread
From: Krzysztof Kozlowski @ 2025-06-19 20:18 UTC (permalink / raw)
  To: Stephen Boyd, Colin Ian King, Michael Turquette, linux-arm-kernel,
	linux-clk
  Cc: kernel-janitors, linux-kernel

On 19/06/2025 21:53, Stephen Boyd wrote:
> Quoting Colin Ian King (2025-06-19 01:30:35)
>> Don't populate the read-only array div_idx on the stack at run time,
>> instead make it static const.
> 
> Why? This is in __init code so it can be thrown away if it stays on the
> stack.

Indeed previous code could be discarded, now will be in rodata, but we
save several instructions runtime on copying it. Plus the actual binary
will be slower (really less code), so also loading it will be faster.

Best regards,
Krzysztof

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

* Re: [PATCH][next] clk: moxart: Make read-only array div_idx static const
  2025-06-19 20:18   ` Krzysztof Kozlowski
@ 2025-06-20  5:33     ` Krzysztof Kozlowski
  0 siblings, 0 replies; 5+ messages in thread
From: Krzysztof Kozlowski @ 2025-06-20  5:33 UTC (permalink / raw)
  To: Stephen Boyd, Colin Ian King, Michael Turquette, linux-arm-kernel,
	linux-clk
  Cc: kernel-janitors, linux-kernel

On 19/06/2025 22:18, Krzysztof Kozlowski wrote:
> On 19/06/2025 21:53, Stephen Boyd wrote:
>> Quoting Colin Ian King (2025-06-19 01:30:35)
>>> Don't populate the read-only array div_idx on the stack at run time,
>>> instead make it static const.
>>
>> Why? This is in __init code so it can be thrown away if it stays on the
>> stack.
> 
> Indeed previous code could be discarded, now will be in rodata, but we
> save several instructions runtime on copying it. Plus the actual binary
> will be slower (really less code), so also loading it will be faster.


s/slower/smaller/

Best regards,
Krzysztof

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

end of thread, other threads:[~2025-06-20  5:33 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-06-19  8:30 [PATCH][next] clk: moxart: Make read-only array div_idx static const Colin Ian King
2025-06-19 17:42 ` Krzysztof Kozlowski
2025-06-19 19:53 ` Stephen Boyd
2025-06-19 20:18   ` Krzysztof Kozlowski
2025-06-20  5:33     ` 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).