From a848d72aab71e19ea78180f2502ad7d12818723f Mon Sep 17 00:00:00 2001 From: Chuan Liu Date: Sun, 20 Sep 2026 18:25:08 +0800 Subject: [PATCH] soc: amlogic: clk-measure: Optimize CLK_MSR_ID to reduce memory usage The original CLK_MSR_ID macro uses __id as the designated array index. This can waste memory when defining struct meson_msr_id arrays. For example: static const struct meson_msr_id clk_msr_foo[] = { CLK_MSR_ID(255, NULL), }; Although the array contains only one valid entry, it occupies space for 256 elements because the designated initializer forces the array size to match the highest index. The driver does not rely on the array index when accessing measurement IDs. Instead, the measurement ID is obtained from the id field of struct meson_msr_id. Therefore, removing the designated array index from CLK_MSR_ID does not affect the current driver behavior while significantly reducing unnecessary memory usage. Compared with before and after modification, the memory size is reduced by 24.76%: $ scripts/bloat-o-meter pre_meson-clk-measure.o meson-clk-measure.o add/remove: 0/0 grow/shrink: 0/15 up/down: 0/-16224 (-16224) Function old new delta clk_msr_sm1 3072 3048 -24 clk_msr_a1 1488 1272 -216 clk_msr_g12a 2952 2712 -240 clk_msr_gx 1992 1608 -384 clk_msr_m8 1536 1104 -432 clk_msr_a9 6120 5544 -576 clk_msr_t7 5352 4632 -720 clk_msr_axg 2640 1704 -936 clk_msr_s6 5064 3672 -1392 clk_msr_c3 4896 3264 -1632 clk_msr_s7d 4632 2880 -1752 clk_msr_s4 5376 3576 -1800 clk_msr_a4 4488 2544 -1944 clk_msr_s7 4632 2664 -1968 clk_msr_a5 4560 2352 -2208 Total: Before=65527, After=49303, chg -24.76% Signed-off-by: Chuan Liu Reviewed-by: Neil Armstrong Link: https://patch.msgid.link/20260920-more-socs-to-support-clk_measure-v2-6-224382a429e8@amlogic.com Signed-off-by: Neil Armstrong --- drivers/soc/amlogic/meson-clk-measure.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/soc/amlogic/meson-clk-measure.c b/drivers/soc/amlogic/meson-clk-measure.c index 50928ac14f86..33767f0bc67c 100644 --- a/drivers/soc/amlogic/meson-clk-measure.c +++ b/drivers/soc/amlogic/meson-clk-measure.c @@ -55,7 +55,7 @@ struct meson_msr { }; #define CLK_MSR_ID(__id, __name) \ - [__id] = {.id = __id, .name = __name,} + {.id = __id, .name = __name,} static const struct meson_msr_id clk_msr_m8[] = { CLK_MSR_ID(0, "ring_osc_out_ee0"),