]> www.infradead.org Git - users/jedix/linux-maple.git/commitdiff
drivers/clk: convert VL struct to struct_size
authorStephen Kitt <steve@sk2.org>
Fri, 27 Sep 2019 18:51:10 +0000 (20:51 +0200)
committerStephen Boyd <sboyd@kernel.org>
Fri, 8 Nov 2019 16:36:12 +0000 (08:36 -0800)
There are a few manually-calculated variable-length struct allocations
left, this converts them to use struct_size. Found with the following
git grep command

git grep -A1 'kzalloc.*sizeof[^_].*+'

Signed-off-by: Stephen Kitt <steve@sk2.org>
Link: https://lkml.kernel.org/r/20190927185110.29897-1-steve@sk2.org
Acked-by: Gustavo A. R. Silva <gustavo@embeddedor.com>
[sboyd@kernel.org: Add grep command]
Signed-off-by: Stephen Boyd <sboyd@kernel.org>
drivers/clk/at91/sckc.c
drivers/clk/imgtec/clk-boston.c
drivers/clk/ingenic/tcu.c
drivers/clk/mvebu/ap-cpu-clk.c
drivers/clk/mvebu/cp110-system-controller.c
drivers/clk/samsung/clk.c
drivers/clk/uniphier/clk-uniphier-core.c

index 9bfe9a28294a7ec7f5acbb38f7e21f477355839e..5ad6180449cb767a842bdef4dedaba58fa6897a7 100644 (file)
@@ -478,8 +478,7 @@ static void __init of_sam9x60_sckc_setup(struct device_node *np)
        if (IS_ERR(slow_osc))
                goto unregister_slow_rc;
 
-       clk_data = kzalloc(sizeof(*clk_data) + (2 * sizeof(struct clk_hw *)),
-                          GFP_KERNEL);
+       clk_data = kzalloc(struct_size(clk_data, hws, 2), GFP_KERNEL);
        if (!clk_data)
                goto unregister_slow_osc;
 
index 33ab4ff61165267dcd8a3784a4cf9bdead123da7..b00cbd045af5eea6fa8b1e6c3266735f9210b00e 100644 (file)
@@ -58,8 +58,7 @@ static void __init clk_boston_setup(struct device_node *np)
        cpu_div = ext_field(mmcmdiv, BOSTON_PLAT_MMCMDIV_CLK1DIV);
        cpu_freq = mult_frac(in_freq, mul, cpu_div);
 
-       onecell = kzalloc(sizeof(*onecell) +
-                         (BOSTON_CLK_COUNT * sizeof(struct clk_hw *)),
+       onecell = kzalloc(struct_size(onecell, hws, BOSTON_CLK_COUNT),
                          GFP_KERNEL);
        if (!onecell)
                return;
index a1a5f9cb439e9306fece29c350da1ade1307904f..ad7daa494fd4a6c5acc0c6542a739b75442eab94 100644 (file)
@@ -358,8 +358,7 @@ static int __init ingenic_tcu_probe(struct device_node *np)
                }
        }
 
-       tcu->clocks = kzalloc(sizeof(*tcu->clocks) +
-                             sizeof(*tcu->clocks->hws) * TCU_CLK_COUNT,
+       tcu->clocks = kzalloc(struct_size(tcu->clocks, hws, TCU_CLK_COUNT),
                              GFP_KERNEL);
        if (!tcu->clocks) {
                ret = -ENOMEM;
index af5e5acad3706a4cedd99822dc3227b5a6fe5297..6b394302c76a30bb0ec61ffd0456e66d30b2d510 100644 (file)
@@ -274,8 +274,8 @@ static int ap_cpu_clock_probe(struct platform_device *pdev)
        if (!ap_cpu_clk)
                return -ENOMEM;
 
-       ap_cpu_data = devm_kzalloc(dev, sizeof(*ap_cpu_data) +
-                               sizeof(struct clk_hw *) * nclusters,
+       ap_cpu_data = devm_kzalloc(dev, struct_size(ap_cpu_data, hws,
+                                                   nclusters),
                                GFP_KERNEL);
        if (!ap_cpu_data)
                return -ENOMEM;
index 808463276145b009305d3390e0ce1a366a922fb5..84c8900542e4478e60398d674fada7094968d870 100644 (file)
@@ -235,8 +235,8 @@ static int cp110_syscon_common_probe(struct platform_device *pdev,
        if (ret)
                return ret;
 
-       cp110_clk_data = devm_kzalloc(dev, sizeof(*cp110_clk_data) +
-                                     sizeof(struct clk_hw *) * CP110_CLK_NUM,
+       cp110_clk_data = devm_kzalloc(dev, struct_size(cp110_clk_data, hws,
+                                                      CP110_CLK_NUM),
                                      GFP_KERNEL);
        if (!cp110_clk_data)
                return -ENOMEM;
index e544a38106ddaf4a1068b8346c9770519008e2fe..dad31308c0711334dde706aab412f4cb890b02f1 100644 (file)
@@ -60,8 +60,7 @@ struct samsung_clk_provider *__init samsung_clk_init(struct device_node *np,
        struct samsung_clk_provider *ctx;
        int i;
 
-       ctx = kzalloc(sizeof(struct samsung_clk_provider) +
-                     sizeof(*ctx->clk_data.hws) * nr_clks, GFP_KERNEL);
+       ctx = kzalloc(struct_size(ctx, clk_data.hws, nr_clks), GFP_KERNEL);
        if (!ctx)
                panic("could not allocate clock provider context.\n");
 
index c6aaca73cf863049b855fd6d762a4b73ce6faf2e..12380236d7ab6cd005e8676c78f085b5aa4a7840 100644 (file)
@@ -64,8 +64,7 @@ static int uniphier_clk_probe(struct platform_device *pdev)
        for (p = data; p->name; p++)
                clk_num = max(clk_num, p->idx + 1);
 
-       hw_data = devm_kzalloc(dev,
-                       sizeof(*hw_data) + clk_num * sizeof(struct clk_hw *),
+       hw_data = devm_kzalloc(dev, struct_size(hw_data, hws, clk_num),
                        GFP_KERNEL);
        if (!hw_data)
                return -ENOMEM;