clk: samsung: move common plls registration into separate function

A patch from »Convert S3C2416 ad S3C2443 to common clock framework« in state Mainline for linux-kernel

From: Heiko Stuebner <heiko@...> Date: Sat, 6 Jul 2013 14:52:57 +0200

Commit-Message

All Samsung PLLs use similar code to register the clocks and clkdev lookups. Therefore move these into a separate function to reduce code duplication. Suggested-by: Russell King <linux@...> Signed-off-by: Heiko Stuebner <heiko@...>

Patch-Comment

drivers/clk/samsung/clk-pll.c | 68 +++++++++++++++++------------------------ 1 file changed, 28 insertions(+), 40 deletions(-)

Statistics

  • 28 lines added
  • 40 lines removed

Changes

------------------------ drivers/clk/samsung/clk-pll.c -------------------------
index 362f12d..9153e46 100644
@@ -13,6 +13,24 @@
#include "clk.h"
#include "clk-pll.h"
+static inline struct clk *samsung_register_pll(struct clk_hw *hw)
+{
+ struct clk *clk;
+ const char *name = hw->init->name;
+
+ clk = clk_register(NULL, hw);
+ if (IS_ERR(clk)) {
+ pr_err("%s: failed to register pll clock %s\n", __func__,
+ name);
+ return clk;
+ }
+
+ if (clk_register_clkdev(clk, name, NULL))
+ pr_err("%s: failed to register lookup for %s", __func__, name);
+
+ return clk;
+}
+
/*
* PLL35xx Clock Type
*/
@@ -75,15 +93,9 @@ struct clk * __init samsung_clk_register_pll35xx(const char *name,
pll->hw.init = &init;
pll->con_reg = con_reg;
- clk = clk_register(NULL, &pll->hw);
- if (IS_ERR(clk)) {
- pr_err("%s: failed to register pll clock %s\n", __func__,
- name);
+ clk = samsung_register_pll(&pll->hw);
+ if (IS_ERR(clk))
kfree(pll);
- }
-
- if (clk_register_clkdev(clk, name, NULL))
- pr_err("%s: failed to register lookup for %s", __func__, name);
return clk;
}
@@ -155,15 +167,9 @@ struct clk * __init samsung_clk_register_pll36xx(const char *name,
pll->hw.init = &init;
pll->con_reg = con_reg;
- clk = clk_register(NULL, &pll->hw);
- if (IS_ERR(clk)) {
- pr_err("%s: failed to register pll clock %s\n", __func__,
- name);
+ clk = samsung_register_pll(&pll->hw);
+ if (IS_ERR(clk))
kfree(pll);
- }
-
- if (clk_register_clkdev(clk, name, NULL))
- pr_err("%s: failed to register lookup for %s", __func__, name);
return clk;
}
@@ -236,15 +242,9 @@ struct clk * __init samsung_clk_register_pll45xx(const char *name,
pll->con_reg = con_reg;
pll->type = type;
- clk = clk_register(NULL, &pll->hw);
- if (IS_ERR(clk)) {
- pr_err("%s: failed to register pll clock %s\n", __func__,
- name);
+ clk = samsung_register_pll(&pll->hw);
+ if (IS_ERR(clk))
kfree(pll);
- }
-
- if (clk_register_clkdev(clk, name, NULL))
- pr_err("%s: failed to register lookup for %s", __func__, name);
return clk;
}
@@ -323,15 +323,9 @@ struct clk * __init samsung_clk_register_pll46xx(const char *name,
pll->con_reg = con_reg;
pll->type = type;
- clk = clk_register(NULL, &pll->hw);
- if (IS_ERR(clk)) {
- pr_err("%s: failed to register pll clock %s\n", __func__,
- name);
+ clk = samsung_register_pll(&pll->hw);
+ if (IS_ERR(clk))
kfree(pll);
- }
-
- if (clk_register_clkdev(clk, name, NULL))
- pr_err("%s: failed to register lookup for %s", __func__, name);
return clk;
}
@@ -406,15 +400,9 @@ struct clk * __init samsung_clk_register_pll2550x(const char *name,
pll->reg_base = reg_base;
pll->offset = offset;
- clk = clk_register(NULL, &pll->hw);
- if (IS_ERR(clk)) {
- pr_err("%s: failed to register pll clock %s\n", __func__,
- name);
+ clk = samsung_register_pll(&pll->hw);
+ if (IS_ERR(clk))
kfree(pll);
- }
-
- if (clk_register_clkdev(clk, name, NULL))
- pr_err("%s: failed to register lookup for %s", __func__, name);
return clk;
}
 
 

Recent Patches

About Us

Sed lacus. Donec lectus. Nullam pretium nibh ut turpis. Nam bibendum. In nulla tortor, elementum vel, tempor at, varius non, purus. Mauris vitae nisl nec metus placerat consectetuer.

Read More...