clk: at91: Fix initializing arrays
authorFrancois Berder <fberder@outlook.fr>
Sun, 24 Sep 2023 09:58:54 +0000 (11:58 +0200)
committerEugen Hristev <eugen.hristev@collabora.com>
Fri, 29 Sep 2023 13:45:40 +0000 (16:45 +0300)
Arrays are not cleared entirely because ARRAY_SIZE
returns the number of elements in an array, not the size
in bytes.
This commit fixes the calls to memset by providing the
array size in bytes instead of the number of elements
in the array.

Signed-off-by: Francois Berder <fberder@outlook.fr>
drivers/clk/at91/sam9x60.c
drivers/clk/at91/sama7g5.c

index e2f7244..d858c86 100644 (file)
@@ -429,8 +429,8 @@ static int sam9x60_clk_probe(struct udevice *dev)
        if (!base)
                return -EINVAL;
 
-       memset(muxallocs,    0, ARRAY_SIZE(muxallocs));
-       memset(clkmuxallocs, 0, ARRAY_SIZE(clkmuxallocs));
+       memset(muxallocs,    0, sizeof(muxallocs));
+       memset(clkmuxallocs, 0, sizeof(clkmuxallocs));
 
        ret = clk_get_by_index(dev, 0, &clk);
        if (ret)
index 3abd220..3e62fb1 100644 (file)
@@ -1115,8 +1115,8 @@ static int sama7g5_clk_probe(struct udevice *dev)
        if (IS_ERR(base))
                return PTR_ERR(base);
 
-       memset(muxallocs,    0, ARRAY_SIZE(muxallocs));
-       memset(clkmuxallocs, 0, ARRAY_SIZE(clkmuxallocs));
+       memset(muxallocs,    0, sizeof(muxallocs));
+       memset(clkmuxallocs, 0, sizeof(clkmuxallocs));
 
        ret = clk_get_by_index(dev, 0, &clk);
        if (ret)