diff mbox

[3/6] clk: rockchip: don't return NULL when registering inverter fails

Message ID 1455507213-13037-1-git-send-email-shawn.lin@rock-chips.com (mailing list archive)
State New, archived
Headers show

Commit Message

Shawn Lin Feb. 15, 2016, 3:33 a.m. UTC
Avoid return NULL if rockchip_clk_register_inverter fails, otherwise
rockchip_clk_register_branches print "unknown clock type". The acutal
case is that it's a known clock type but we fail to regiser it, which
may makes user confuse the reason of failure.

Signed-off-by: Shawn Lin <shawn.lin@rock-chips.com>
---

 drivers/clk/rockchip/clk-inverter.c | 8 ++------
 1 file changed, 2 insertions(+), 6 deletions(-)

Comments

Heiko Stuebner Feb. 15, 2016, 10:41 p.m. UTC | #1
Am Montag, 15. Februar 2016, 11:33:33 schrieb Shawn Lin:
> Avoid return NULL if rockchip_clk_register_inverter fails, otherwise
> rockchip_clk_register_branches print "unknown clock type". The acutal
> case is that it's a known clock type but we fail to regiser it, which
> may makes user confuse the reason of failure.
> 
> Signed-off-by: Shawn Lin <shawn.lin@rock-chips.com>

applied to my clk-branch for 4.6
diff mbox

Patch

diff --git a/drivers/clk/rockchip/clk-inverter.c b/drivers/clk/rockchip/clk-inverter.c
index 7cbf43b..dcb6e37 100644
--- a/drivers/clk/rockchip/clk-inverter.c
+++ b/drivers/clk/rockchip/clk-inverter.c
@@ -90,7 +90,7 @@  struct clk *rockchip_clk_register_inverter(const char *name,
 
 	inv_clock = kmalloc(sizeof(*inv_clock), GFP_KERNEL);
 	if (!inv_clock)
-		return NULL;
+		return ERR_PTR(-ENOMEM);
 
 	init.name = name;
 	init.num_parents = num_parents;
@@ -106,11 +106,7 @@  struct clk *rockchip_clk_register_inverter(const char *name,
 
 	clk = clk_register(NULL, &inv_clock->hw);
 	if (IS_ERR(clk))
-		goto err_free;
+		kfree(inv_clock);
 
 	return clk;
-
-err_free:
-	kfree(inv_clock);
-	return NULL;
 }