From: "Heiko Stübner" <heiko@sntech.de>
To: Kukjin Kim <kgene.kim@samsung.com>
Cc: mturquette@linaro.org, linux-arm-kernel@lists.infradead.org,
linux-samsung-soc@vger.kernel.org,
Thomas Abraham <thomas.abraham@linaro.org>,
t.figa@samsung.com, Russell King <linux@arm.linux.org.uk>
Subject: [PATCH v2 1/6] clk: samsung: move common plls registration into separate function
Date: Wed, 10 Jul 2013 00:57:47 +0200 [thread overview]
Message-ID: <201307100057.48265.heiko@sntech.de> (raw)
In-Reply-To: <201307100057.06061.heiko@sntech.de>
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@arm.linux.org.uk>
Signed-off-by: Heiko Stuebner <heiko@sntech.de>
---
drivers/clk/samsung/clk-pll.c | 68 +++++++++++++++++------------------------
1 file changed, 28 insertions(+), 40 deletions(-)
diff --git a/drivers/clk/samsung/clk-pll.c b/drivers/clk/samsung/clk-pll.c
index 362f12d..9153e46 100644
--- a/drivers/clk/samsung/clk-pll.c
+++ b/drivers/clk/samsung/clk-pll.c
@@ -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;
}
--
1.7.10.4
next prev parent reply other threads:[~2013-07-09 22:57 UTC|newest]
Thread overview: 23+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-07-09 22:57 [PATCH v2 0/6] Convert S3C2416 ad S3C2443 to common clock framework Heiko Stübner
2013-07-09 22:57 ` Heiko Stübner [this message]
2013-07-10 16:59 ` [PATCH v2 1/6] clk: samsung: move common plls registration into separate function Yadwinder Singh Brar
2013-07-11 7:46 ` Tomasz Figa
2013-07-11 8:52 ` Heiko Stübner
2013-08-02 21:35 ` Mike Turquette
2013-07-09 22:58 ` [PATCH v2 2/6] clk: samsung: fix error handling in pll register functions Heiko Stübner
2013-07-11 7:50 ` Tomasz Figa
2013-07-09 22:59 ` [PATCH v2 3/6] clk: samsung: add plls used in s3c2416 and s3c2443 Heiko Stübner
2013-07-11 8:16 ` Tomasz Figa
2013-07-11 8:50 ` Heiko Stübner
2013-07-11 9:25 ` Tomasz Figa
2013-07-09 22:59 ` [PATCH v2 4/6] ARM: S3C24XX: enable legacy clock code only when SAMSUNG_CLOCK selected Heiko Stübner
2013-07-09 23:00 ` [PATCH v2 5/6] clk: samsung: add clock-driver for s3c2416, s3c2443 and s3c2450 Heiko Stübner
2013-07-11 9:13 ` Tomasz Figa
2013-07-09 23:00 ` [PATCH v2 6/6] ARM: S3C24XX: Convert s3c2416 and s3c2443 to common clock framework Heiko Stübner
2013-07-16 7:09 ` Kukjin Kim
2013-07-22 17:07 ` Tomasz Figa
2013-07-24 12:59 ` Kukjin Kim
2013-07-24 14:01 ` Tomasz Figa
2013-08-05 17:03 ` Kukjin Kim
2013-07-10 8:47 ` [PATCH v2 0/6] Convert S3C2416 ad S3C2443 " Thomas Abraham
2013-08-05 17:05 ` Kukjin Kim
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=201307100057.48265.heiko@sntech.de \
--to=heiko@sntech.de \
--cc=kgene.kim@samsung.com \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-samsung-soc@vger.kernel.org \
--cc=linux@arm.linux.org.uk \
--cc=mturquette@linaro.org \
--cc=t.figa@samsung.com \
--cc=thomas.abraham@linaro.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox