clk: sunxi: Store the array sizes in the CCU descriptor
authorSamuel Holland <samuel@sholland.org>
Mon, 9 May 2022 05:29:31 +0000 (00:29 -0500)
committerAndre Przywara <andre.przywara@arm.com>
Mon, 18 Jul 2022 08:37:49 +0000 (09:37 +0100)
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 <samuel@sholland.org>
Reviewed-by: Andre Przywara <andre.przywara@arm.com>
[Andre: add F1C100s support]
Signed-off-by: Andre Przywara <andre.przywara@arm.com>
16 files changed:
drivers/clk/sunxi/clk_a10.c
drivers/clk/sunxi/clk_a10s.c
drivers/clk/sunxi/clk_a23.c
drivers/clk/sunxi/clk_a31.c
drivers/clk/sunxi/clk_a31_r.c
drivers/clk/sunxi/clk_a64.c
drivers/clk/sunxi/clk_a80.c
drivers/clk/sunxi/clk_a83t.c
drivers/clk/sunxi/clk_f1c100s.c
drivers/clk/sunxi/clk_h3.c
drivers/clk/sunxi/clk_h6.c
drivers/clk/sunxi/clk_h616.c
drivers/clk/sunxi/clk_h6_r.c
drivers/clk/sunxi/clk_r40.c
drivers/clk/sunxi/clk_v3s.c
include/clk/sunxi.h

index db92848aafdec578efde2d3f35e0120893a955fd..b3cca2aa3a08fcc04c52bda5a897b0bfad5136ab 100644 (file)
@@ -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)
index 0c6564ef3b62498d57a27a3eb5f884fd9ab7460c..0e75c303d062e1fe657ac3067dff87918db3d0da 100644 (file)
@@ -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)
index 0280fb51e2db558f09a46f00642aa3f4a0dbe595..a9c77bad2084d311061d75634e4cd902b7017d28 100644 (file)
@@ -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)
index 26d25f3240803e0fcc044adc7a6d8f9fc12f1666..69df4e08d0f73dccfa1d982d80c6a351e82554fa 100644 (file)
@@ -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)
index 1f08ea956f90b905a628bdfb383b71c52d51e266..7bf1c4578c5c2efc6189215835750f99d29a949f 100644 (file)
@@ -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)
index cbb9168edb9ca0c24daa0841ad28a3507121d58f..e24d5c5ca321eea6862c0b20da166c0e0b0d0c55 100644 (file)
@@ -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)
index 1ee1f99a8f49defc6209be1d73fae9cd080a79a8..adedcba1665097e09b57b19fdbdcb1bdb3358a2d 100644 (file)
@@ -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)
index 4b57434cfaadac9067b5f8582fbc781567d48a22..4a0659af3e265fca650fb89828471da6a640f9b1 100644 (file)
@@ -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)
index 72cf8a6e5c0d1789c15c17f1a677fd13d79f8d5f..cb0159ecbc7c97d89dae7d7d274b3050c6cb4f68 100644 (file)
@@ -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)
index 08a830bd1889c039d366c36b76d059cd74b4c357..d69cb04b8242d85dec4d991deab7096c230cf24e 100644 (file)
@@ -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)
index b3202342932bd200480e735c089395300c5b3c7b..f8d2379b494a5491abb5868435537b0d2005ef47 100644 (file)
@@ -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)
index 80099727defd38010eea45db55371cc692225697..34cfcffb49d2490676dfb1ffd0215ce8dcac1d7b 100644 (file)
@@ -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)
index c592886a258144113030e2129e67a1936b01eb8c..18913751fb7b1c32f8ec67adcf3e01d4cfd3040f 100644 (file)
@@ -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)
index 45633a2a52494f4fe0b4363b1a3bb8a8406cac48..81e4a0219a9e4405f0d10c18ee23f69bdbc9da3f 100644 (file)
@@ -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)
index 67d215cbba8a48ddcab38f2ca9fd15c833cd11b1..f45e9400419f5f4996e96414e3b4ed638d098221 100644 (file)
@@ -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)
index c4a9dee5ebfac76ee26d8a82e1cf5fae70035fa1..f1717a5e95434ed86cd9c4a482d2a2dc00e3d658 100644 (file)
@@ -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;
 };
 
 /**