clk: samsung: Initialize clock table with error pointers
authorTomasz Figa <t.figa@samsung.com>
Thu, 6 Feb 2014 18:33:11 +0000 (19:33 +0100)
committerTomasz Figa <t.figa@samsung.com>
Wed, 14 May 2014 17:23:25 +0000 (19:23 +0200)
Before this patch, the driver was simply zeroing the clock table, which
is incorrect, because invalid clock numbers returned NULL instead of
error pointers. This patch fixes this by changing the driver to
initialize the array with PTR_ERR(-ENOENT).

Signed-off-by: Tomasz Figa <t.figa@samsung.com>
Acked-by: Kyungmin Park <kyungmin.park@samsung.com>
drivers/clk/samsung/clk.c

index 41c1461d2f583030c984ef49745cb50c12b1fc07..ce4d8a25dd61bfeacf7d94781c05da700b5c90be 100644 (file)
@@ -54,14 +54,19 @@ struct samsung_clk_provider *__init samsung_clk_init(struct device_node *np,
        struct samsung_clk_provider *ctx;
        struct clk **clk_table;
        int ret;
+       int i;
+
        ctx = kzalloc(sizeof(struct samsung_clk_provider), GFP_KERNEL);
        if (!ctx)
                panic("could not allocate clock provider context.\n");
 
-       clk_table = kzalloc(sizeof(struct clk *) * nr_clks, GFP_KERNEL);
+       clk_table = kcalloc(nr_clks, sizeof(struct clk *), GFP_KERNEL);
        if (!clk_table)
                panic("could not allocate clock lookup table\n");
 
+       for (i = 0; i < nr_clks; ++i)
+               clk_table[i] = ERR_PTR(-ENOENT);
+
        ctx->reg_base = base;
        ctx->clk_data.clks = clk_table;
        ctx->clk_data.clk_num = nr_clks;
This page took 0.02673 seconds and 5 git commands to generate.