Skip to contentSkip to conversation

clk: samsung: Changed return behavior of samsung_clk_init

PATCH In review Humberto Silva Naves 2 participants 2 messages Jul 31, 2014

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 clk: samsung: Changed return behavior of samsung_clk_init

Instead of invoking panic, the samsung_clk_init returns a NULL pointer to indicate that an error has occurred. All the drivers using this function were changed appropriately (in this case just the clk-exynos5410).

This patch was suggested by Tomasz Figa in
http://www.mail-archive.com/linux-samsung-soc at vger.kernel.org/msg34982.html

---
 drivers/clk/samsung/clk-exynos5410.c |    2 ++
 drivers/clk/samsung/clk.c            |    8 +++++---
 2 files changed, 7 insertions(+), 3 deletions(-)
drivers/clk/samsung/clk-exynos5410.c +2 -0
index 231475b..19657b4 100644
@@ -193,6 +193,8 @@ static void __init exynos5410_clk_init(struct device_node *np)
 		panic("%s: failed to map registers\n", __func__);
 
 	ctx = samsung_clk_init(np, reg_base, CLK_NR_CLKS);
+	if (!ctx)
+		panic("%s: unable to allocate context.\n", __func__);
 
 	samsung_clk_register_pll(ctx, exynos5410_plls,
 			ARRAY_SIZE(exynos5410_plls), reg_base);
drivers/clk/samsung/clk.c +5 -3
index deab84d..0cf0ec6 100644
@@ -57,11 +57,13 @@ struct samsung_clk_provider *__init samsung_clk_init(struct device_node *np,
 
 	ctx = kzalloc(sizeof(struct samsung_clk_provider), GFP_KERNEL);
 	if (!ctx)
-		panic("could not allocate clock provider context.\n");
+		return NULL;
 
 	clk_table = kcalloc(nr_clks, sizeof(struct clk *), GFP_KERNEL);
-	if (!clk_table)
-		panic("could not allocate clock lookup table\n");
+	if (!clk_table) {
+		kfree(ctx);
+		return NULL;
+	}
 
 	for (i = 0; i < nr_clks; ++i)
 		clk_table[i] = ERR_PTR(-ENOENT);
Signature · 1 line
1.7.10.4
#1 lore raw

Humberto,

Quoted 7 lines · Humberto Silva Naves

Instead of invoking panic, the samsung_clk_init returns a NULL pointer to indicate that an error has occurred. All the drivers using this function were changed appropriately (in this case just the clk-exynos5410).

This patch was suggested by Tomasz Figa in
http://www.mail-archive.com/linux-samsung-soc at vger.kernel.org/msg34982.html

There is a Suggested-by tag that can be added before your sign-off. Similarly there are few other useful tags which are good to know.

Quoted 7 lines
---
 drivers/clk/samsung/clk-exynos5410.c |    2 ++
 drivers/clk/samsung/clk.c            |    8 +++++---
 2 files changed, 7 insertions(+), 3 deletions(-)

In general the patch looks good, thanks for you work. Will wait some time to let people review it and then apply.

As a side note, it is always good to say why the patch is good in commit message, so that maintainers know that author knows what he does, they indeed want this patch and people that would stumble upon this patch in future could know the rationale behind this change. This patch is pretty trivial, though, so I'll let it go this time.

Best regards,
Tomasz