From: Samuel Holland Date: Mon, 9 May 2022 05:29:31 +0000 (-0500) Subject: clk: sunxi: Store the array sizes in the CCU descriptor X-Git-Url: http://git.dujemihanovic.xyz/img/static/git-favicon.png?a=commitdiff_plain;h=49b2b0a2b6782609a9977095d9c80391de463044;p=u-boot.git clk: sunxi: Store the array sizes in the CCU descriptor The reset array size is currently used for bounds checking in the reset driver. The same bounds check should really be done in the clock driver. Currently, the array size is provided to the reset driver separately from the CCU descriptor, which is a bit strange. Let's do this the usual way, with the array sizes next to the arrays themselves. Signed-off-by: Samuel Holland Reviewed-by: Andre Przywara [Andre: add F1C100s support] Signed-off-by: Andre Przywara --- diff --git a/drivers/clk/sunxi/clk_a10.c b/drivers/clk/sunxi/clk_a10.c index db92848aaf..b3cca2aa3a 100644 --- a/drivers/clk/sunxi/clk_a10.c +++ b/drivers/clk/sunxi/clk_a10.c @@ -67,6 +67,8 @@ static struct ccu_reset a10_resets[] = { static const struct ccu_desc a10_ccu_desc = { .gates = a10_gates, .resets = a10_resets, + .num_gates = ARRAY_SIZE(a10_gates), + .num_resets = ARRAY_SIZE(a10_resets), }; static int a10_clk_bind(struct udevice *dev) diff --git a/drivers/clk/sunxi/clk_a10s.c b/drivers/clk/sunxi/clk_a10s.c index 0c6564ef3b..0e75c303d0 100644 --- a/drivers/clk/sunxi/clk_a10s.c +++ b/drivers/clk/sunxi/clk_a10s.c @@ -52,6 +52,8 @@ static struct ccu_reset a10s_resets[] = { static const struct ccu_desc a10s_ccu_desc = { .gates = a10s_gates, .resets = a10s_resets, + .num_gates = ARRAY_SIZE(a10s_gates), + .num_resets = ARRAY_SIZE(a10s_resets), }; static int a10s_clk_bind(struct udevice *dev) diff --git a/drivers/clk/sunxi/clk_a23.c b/drivers/clk/sunxi/clk_a23.c index 0280fb51e2..a9c77bad20 100644 --- a/drivers/clk/sunxi/clk_a23.c +++ b/drivers/clk/sunxi/clk_a23.c @@ -71,6 +71,8 @@ static struct ccu_reset a23_resets[] = { static const struct ccu_desc a23_ccu_desc = { .gates = a23_gates, .resets = a23_resets, + .num_gates = ARRAY_SIZE(a23_gates), + .num_resets = ARRAY_SIZE(a23_resets), }; static int a23_clk_bind(struct udevice *dev) diff --git a/drivers/clk/sunxi/clk_a31.c b/drivers/clk/sunxi/clk_a31.c index 26d25f3240..69df4e08d0 100644 --- a/drivers/clk/sunxi/clk_a31.c +++ b/drivers/clk/sunxi/clk_a31.c @@ -92,6 +92,8 @@ static struct ccu_reset a31_resets[] = { static const struct ccu_desc a31_ccu_desc = { .gates = a31_gates, .resets = a31_resets, + .num_gates = ARRAY_SIZE(a31_gates), + .num_resets = ARRAY_SIZE(a31_resets), }; static int a31_clk_bind(struct udevice *dev) diff --git a/drivers/clk/sunxi/clk_a31_r.c b/drivers/clk/sunxi/clk_a31_r.c index 1f08ea956f..7bf1c4578c 100644 --- a/drivers/clk/sunxi/clk_a31_r.c +++ b/drivers/clk/sunxi/clk_a31_r.c @@ -31,6 +31,8 @@ static struct ccu_reset a31_r_resets[] = { static const struct ccu_desc a31_r_ccu_desc = { .gates = a31_r_gates, .resets = a31_r_resets, + .num_gates = ARRAY_SIZE(a31_r_gates), + .num_resets = ARRAY_SIZE(a31_r_resets), }; static int a31_r_clk_bind(struct udevice *dev) diff --git a/drivers/clk/sunxi/clk_a64.c b/drivers/clk/sunxi/clk_a64.c index cbb9168edb..e24d5c5ca3 100644 --- a/drivers/clk/sunxi/clk_a64.c +++ b/drivers/clk/sunxi/clk_a64.c @@ -80,6 +80,8 @@ static const struct ccu_reset a64_resets[] = { static const struct ccu_desc a64_ccu_desc = { .gates = a64_gates, .resets = a64_resets, + .num_gates = ARRAY_SIZE(a64_gates), + .num_resets = ARRAY_SIZE(a64_resets), }; static int a64_clk_bind(struct udevice *dev) diff --git a/drivers/clk/sunxi/clk_a80.c b/drivers/clk/sunxi/clk_a80.c index 1ee1f99a8f..adedcba166 100644 --- a/drivers/clk/sunxi/clk_a80.c +++ b/drivers/clk/sunxi/clk_a80.c @@ -77,11 +77,15 @@ static const struct ccu_reset a80_mmc_resets[] = { static const struct ccu_desc a80_ccu_desc = { .gates = a80_gates, .resets = a80_resets, + .num_gates = ARRAY_SIZE(a80_gates), + .num_resets = ARRAY_SIZE(a80_resets), }; static const struct ccu_desc a80_mmc_clk_desc = { .gates = a80_mmc_gates, .resets = a80_mmc_resets, + .num_gates = ARRAY_SIZE(a80_mmc_gates), + .num_resets = ARRAY_SIZE(a80_mmc_resets), }; static int a80_clk_bind(struct udevice *dev) diff --git a/drivers/clk/sunxi/clk_a83t.c b/drivers/clk/sunxi/clk_a83t.c index 4b57434cfa..4a0659af3e 100644 --- a/drivers/clk/sunxi/clk_a83t.c +++ b/drivers/clk/sunxi/clk_a83t.c @@ -75,6 +75,8 @@ static struct ccu_reset a83t_resets[] = { static const struct ccu_desc a83t_ccu_desc = { .gates = a83t_gates, .resets = a83t_resets, + .num_gates = ARRAY_SIZE(a83t_gates), + .num_resets = ARRAY_SIZE(a83t_resets), }; static int a83t_clk_bind(struct udevice *dev) diff --git a/drivers/clk/sunxi/clk_f1c100s.c b/drivers/clk/sunxi/clk_f1c100s.c index 72cf8a6e5c..cb0159ecbc 100644 --- a/drivers/clk/sunxi/clk_f1c100s.c +++ b/drivers/clk/sunxi/clk_f1c100s.c @@ -50,6 +50,8 @@ static struct ccu_reset f1c100s_resets[] = { static const struct ccu_desc f1c100s_ccu_desc = { .gates = f1c100s_gates, .resets = f1c100s_resets, + .num_gates = ARRAY_SIZE(f1c100s_gates), + .num_resets = ARRAY_SIZE(f1c100s_resets), }; static int f1c100s_clk_bind(struct udevice *dev) diff --git a/drivers/clk/sunxi/clk_h3.c b/drivers/clk/sunxi/clk_h3.c index 08a830bd18..d69cb04b82 100644 --- a/drivers/clk/sunxi/clk_h3.c +++ b/drivers/clk/sunxi/clk_h3.c @@ -93,6 +93,8 @@ static struct ccu_reset h3_resets[] = { static const struct ccu_desc h3_ccu_desc = { .gates = h3_gates, .resets = h3_resets, + .num_gates = ARRAY_SIZE(h3_gates), + .num_resets = ARRAY_SIZE(h3_resets), }; static int h3_clk_bind(struct udevice *dev) diff --git a/drivers/clk/sunxi/clk_h6.c b/drivers/clk/sunxi/clk_h6.c index b320234293..f8d2379b49 100644 --- a/drivers/clk/sunxi/clk_h6.c +++ b/drivers/clk/sunxi/clk_h6.c @@ -94,6 +94,8 @@ static struct ccu_reset h6_resets[] = { static const struct ccu_desc h6_ccu_desc = { .gates = h6_gates, .resets = h6_resets, + .num_gates = ARRAY_SIZE(h6_gates), + .num_resets = ARRAY_SIZE(h6_resets), }; static int h6_clk_bind(struct udevice *dev) diff --git a/drivers/clk/sunxi/clk_h616.c b/drivers/clk/sunxi/clk_h616.c index 80099727de..34cfcffb49 100644 --- a/drivers/clk/sunxi/clk_h616.c +++ b/drivers/clk/sunxi/clk_h616.c @@ -112,6 +112,8 @@ static struct ccu_reset h616_resets[] = { static const struct ccu_desc h616_ccu_desc = { .gates = h616_gates, .resets = h616_resets, + .num_gates = ARRAY_SIZE(h616_gates), + .num_resets = ARRAY_SIZE(h616_resets), }; static int h616_clk_bind(struct udevice *dev) diff --git a/drivers/clk/sunxi/clk_h6_r.c b/drivers/clk/sunxi/clk_h6_r.c index c592886a25..18913751fb 100644 --- a/drivers/clk/sunxi/clk_h6_r.c +++ b/drivers/clk/sunxi/clk_h6_r.c @@ -37,6 +37,8 @@ static struct ccu_reset h6_r_resets[] = { static const struct ccu_desc h6_r_ccu_desc = { .gates = h6_r_gates, .resets = h6_r_resets, + .num_gates = ARRAY_SIZE(h6_r_gates), + .num_resets = ARRAY_SIZE(h6_r_resets), }; static int h6_r_clk_bind(struct udevice *dev) diff --git a/drivers/clk/sunxi/clk_r40.c b/drivers/clk/sunxi/clk_r40.c index 45633a2a52..81e4a0219a 100644 --- a/drivers/clk/sunxi/clk_r40.c +++ b/drivers/clk/sunxi/clk_r40.c @@ -102,6 +102,8 @@ static struct ccu_reset r40_resets[] = { static const struct ccu_desc r40_ccu_desc = { .gates = r40_gates, .resets = r40_resets, + .num_gates = ARRAY_SIZE(r40_gates), + .num_resets = ARRAY_SIZE(r40_resets), }; static int r40_clk_bind(struct udevice *dev) diff --git a/drivers/clk/sunxi/clk_v3s.c b/drivers/clk/sunxi/clk_v3s.c index 67d215cbba..f45e940041 100644 --- a/drivers/clk/sunxi/clk_v3s.c +++ b/drivers/clk/sunxi/clk_v3s.c @@ -52,6 +52,8 @@ static struct ccu_reset v3s_resets[] = { static const struct ccu_desc v3s_ccu_desc = { .gates = v3s_gates, .resets = v3s_resets, + .num_gates = ARRAY_SIZE(v3s_gates), + .num_resets = ARRAY_SIZE(v3s_resets), }; static int v3s_clk_bind(struct udevice *dev) diff --git a/include/clk/sunxi.h b/include/clk/sunxi.h index c4a9dee5eb..f1717a5e95 100644 --- a/include/clk/sunxi.h +++ b/include/clk/sunxi.h @@ -70,6 +70,8 @@ struct ccu_reset { struct ccu_desc { const struct ccu_clk_gate *gates; const struct ccu_reset *resets; + u8 num_gates; + u8 num_resets; }; /**