From patchwork Tue Jul 9 22:57:47 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Heiko Stuebner X-Patchwork-Id: 2825457 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 8992C9F756 for ; Tue, 9 Jul 2013 22:58:38 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 743E3200FE for ; Tue, 9 Jul 2013 22:58:37 +0000 (UTC) Received: from casper.infradead.org (casper.infradead.org [85.118.1.10]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 3D79F200F0 for ; Tue, 9 Jul 2013 22:58:36 +0000 (UTC) Received: from merlin.infradead.org ([2001:4978:20e::2]) by casper.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1UwgrU-0006JB-Rr; Tue, 09 Jul 2013 22:58:21 +0000 Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1UwgrP-0003yw-0k; Tue, 09 Jul 2013 22:58:15 +0000 Received: from gloria.sntech.de ([95.129.55.99]) by merlin.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1UwgrM-0003yX-Db for linux-arm-kernel@lists.infradead.org; Tue, 09 Jul 2013 22:58:13 +0000 Received: from 146-52-210-25-dynip.superkabel.de ([146.52.210.25] helo=marty.localnet) by gloria.sntech.de with esmtpsa (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.72) (envelope-from ) id 1Uwgqz-0007Lg-VU; Wed, 10 Jul 2013 00:57:50 +0200 From: Heiko =?utf-8?q?St=C3=BCbner?= To: Kukjin Kim Subject: [PATCH v2 1/6] clk: samsung: move common plls registration into separate function Date: Wed, 10 Jul 2013 00:57:47 +0200 User-Agent: KMail/1.13.7 (Linux/3.2.0-3-686-pae; KDE/4.8.4; i686; ; ) References: <201307100057.06061.heiko@sntech.de> In-Reply-To: <201307100057.06061.heiko@sntech.de> MIME-Version: 1.0 Message-Id: <201307100057.48265.heiko@sntech.de> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20130709_185812_572072_2562B0FE X-CRM114-Status: GOOD ( 12.73 ) X-Spam-Score: -2.2 (--) Cc: linux-samsung-soc@vger.kernel.org, mturquette@linaro.org, t.figa@samsung.com, Thomas Abraham , Russell King , linux-arm-kernel@lists.infradead.org X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Spam-Status: No, score=-4.5 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_MED, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP 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 Signed-off-by: Heiko Stuebner --- 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; }