[PATCH 1/7] 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 --- drivers/clk/sunxi/clk_a10.c | 2 ++ drivers/clk/sunxi/clk_a10s.c | 2 ++ drivers/clk/sunxi/clk_a23.c | 2 ++ drivers/clk/sunxi/clk_a31.c | 2 ++ drivers/clk/sunxi/clk_a31_r.c | 2 ++ drivers/clk/sunxi/clk_a64.c | 2 ++ drivers/clk/sunxi/clk_a80.c | 4 drivers/clk/sunxi/clk_a83t.c | 2 ++ drivers/clk/sunxi/clk_h3.c| 2 ++ drivers/clk/sunxi/clk_h6.c| 2 ++ drivers/clk/sunxi/clk_h616.c | 2 ++ drivers/clk/sunxi/clk_h6_r.c | 2 ++ drivers/clk/sunxi/clk_r40.c | 2 ++ drivers/clk/sunxi/clk_v3s.c | 2 ++ include/clk/sunxi.h | 2 ++ 15 files changed, 32 insertions(+) diff --git a/drivers/clk/sunxi/clk_a10.c b/drivers/clk/sunxi/clk_a10.c index 90b929d3d3..6b58cffc8a 100644 --- a/drivers/clk/sunxi/clk_a10.c +++ b/drivers/clk/sunxi/clk_a10.c @@ -65,6 +65,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 addf4f4d5c..81b146ce1e 100644 --- a/drivers/clk/sunxi/clk_a10s.c +++ b/drivers/clk/sunxi/clk_a10s.c @@ -50,6 +50,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 c45d2c3529..c7c78bc7d8 100644 --- a/drivers/clk/sunxi/clk_a23.c +++ b/drivers/clk/sunxi/clk_a23.c @@ -69,6 +69,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 251fc3b705..c8c7f4ecf5 100644 --- a/drivers/clk/sunxi/clk_a31.c +++ b/drivers/clk/sunxi/clk_a31.c @@ -90,6 +90,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 1004a79503..6da861ddc1 100644 --- a/drivers/clk/sunxi/clk_a64.c +++ b/drivers/clk/sunxi/clk_a64.c @@ -76,6 +76,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 8a0834d83a..7025d3cbe6 100644 --- a/drivers/clk/sunxi/clk_a80.c +++ b/drivers/clk/sunxi/clk_a80.c @@ -75,11 +75,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 8c6043f51e..c50d253f84 100644 --- a/drivers/clk/sunxi/clk_a83t.c +++ b/drivers/clk/sunxi/clk_a83t.c @@ -73,6 +73,8 @@ static struct ccu_reset a83t_resets[] = { static const struct ccu_desc a83t_ccu_desc = { .gates = a83t_gates, .resets = a83t_resets, + .num_gates = A
Re: [PATCH 1/7] clk: sunxi: Store the array sizes in the CCU descriptor
On Mon, 9 May 2022 00:29:31 -0500 Samuel Holland wrote: > 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. Checked for typos, all fine. Added the F1C100s on the way. > > Signed-off-by: Samuel Holland Reviewed-by: Andre Przywara Thanks, Andre > --- > > drivers/clk/sunxi/clk_a10.c | 2 ++ > drivers/clk/sunxi/clk_a10s.c | 2 ++ > drivers/clk/sunxi/clk_a23.c | 2 ++ > drivers/clk/sunxi/clk_a31.c | 2 ++ > drivers/clk/sunxi/clk_a31_r.c | 2 ++ > drivers/clk/sunxi/clk_a64.c | 2 ++ > drivers/clk/sunxi/clk_a80.c | 4 > drivers/clk/sunxi/clk_a83t.c | 2 ++ > drivers/clk/sunxi/clk_h3.c| 2 ++ > drivers/clk/sunxi/clk_h6.c| 2 ++ > drivers/clk/sunxi/clk_h616.c | 2 ++ > drivers/clk/sunxi/clk_h6_r.c | 2 ++ > drivers/clk/sunxi/clk_r40.c | 2 ++ > drivers/clk/sunxi/clk_v3s.c | 2 ++ > include/clk/sunxi.h | 2 ++ > 15 files changed, 32 insertions(+) > > diff --git a/drivers/clk/sunxi/clk_a10.c b/drivers/clk/sunxi/clk_a10.c > index 90b929d3d3..6b58cffc8a 100644 > --- a/drivers/clk/sunxi/clk_a10.c > +++ b/drivers/clk/sunxi/clk_a10.c > @@ -65,6 +65,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 addf4f4d5c..81b146ce1e 100644 > --- a/drivers/clk/sunxi/clk_a10s.c > +++ b/drivers/clk/sunxi/clk_a10s.c > @@ -50,6 +50,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 c45d2c3529..c7c78bc7d8 100644 > --- a/drivers/clk/sunxi/clk_a23.c > +++ b/drivers/clk/sunxi/clk_a23.c > @@ -69,6 +69,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 251fc3b705..c8c7f4ecf5 100644 > --- a/drivers/clk/sunxi/clk_a31.c > +++ b/drivers/clk/sunxi/clk_a31.c > @@ -90,6 +90,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 1004a79503..6da861ddc1 100644 > --- a/drivers/clk/sunxi/clk_a64.c > +++ b/drivers/clk/sunxi/clk_a64.c > @@ -76,6 +76,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 8a0834d83a..7025d3cbe6 100644 > --- a/drivers/clk/sunxi/clk_a80.c > +++ b/drivers/clk/sunxi/clk_a80.c > @@ -75,11 +75,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/dr