clk: moxart: Make read-only array div_idx static const
Subsystems (3)
PATCH 1/1 clk: moxart: Make read-only array div_idx static const
Don't populate the read-only array div_idx on the stack at run time, instead make it static const.
--- drivers/clk/clk-moxart.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/clk/clk-moxart.c +1 -1
@@ -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;
Signature · 1 line
2.49.0
Quoted 5 lines · Colin Ian King
Don't populate the read-only array
div_idxon the stack at run time, instead make it static const.Signed-off-by Colin Ian King <[email protected]>---
Best regards,
Krzysztof
Stephen Boyd
maintainerQuoting Colin Ian King (2025-06-19 01:30:35)
Quoted 2 lines
Don't populate the read-only array
div_idxon 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.
Krzysztof Kozlowski
maintainerQuoted 6 lines · Stephen Boyd
Quoting Colin Ian King (2025-06-19 01:30:35)
Quoted 2 lines
Don't populate the read-only array
div_idxon the stack at run time, instead make it static const.Why? This is in
__initcode 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
Krzysztof Kozlowski
maintainerQuoted 11 lines · Krzysztof Kozlowski
Quoted 6 lines · Stephen Boyd
Quoting Colin Ian King (2025-06-19 01:30:35)
Quoted 2 lines
Don't populate the read-only array
div_idxon the stack at run time, instead make it static const.Why? This is in
__initcode 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