From patchwork Tue Jan 19 08:52:32 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andi Shyti X-Patchwork-Id: 8059231 Return-Path: X-Original-To: patchwork-linux-samsung-soc@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 2E2FC9F1CC for ; Tue, 19 Jan 2016 08:53:42 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 3E4AA203A9 for ; Tue, 19 Jan 2016 08:53:41 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 3BA3220386 for ; Tue, 19 Jan 2016 08:53:39 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1757569AbcASIxh (ORCPT ); Tue, 19 Jan 2016 03:53:37 -0500 Received: from mailout4.samsung.com ([203.254.224.34]:54862 "EHLO mailout4.samsung.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932449AbcASIws (ORCPT ); Tue, 19 Jan 2016 03:52:48 -0500 Received: from epcpsbgr3.samsung.com (u143.gpu120.samsung.co.kr [203.254.230.143]) by mailout4.samsung.com (Oracle Communications Messaging Server 7.0.5.31.0 64bit (built May 5 2014)) with ESMTP id <0O16014RMZBY3D60@mailout4.samsung.com>; Tue, 19 Jan 2016 17:52:46 +0900 (KST) Received: from epcpsbgm1new.samsung.com ( [172.20.52.113]) by epcpsbgr3.samsung.com (EPCPMTA) with SMTP id D3.B7.04964.E59FD965; Tue, 19 Jan 2016 17:52:46 +0900 (KST) X-AuditID: cbfee68f-f793a6d000001364-85-569df95ee59f Received: from epmmp1.local.host ( [203.254.227.16]) by epcpsbgm1new.samsung.com (EPCPMTA) with SMTP id 30.66.13906.D59FD965; Tue, 19 Jan 2016 17:52:46 +0900 (KST) Received: from samsunx.samsung ([10.113.63.54]) by mmp1.samsung.com (Oracle Communications Messaging Server 7.0.5.31.0 64bit (built May 5 2014)) with ESMTPA id <0O1600GFDZBT0H80@mmp1.samsung.com>; Tue, 19 Jan 2016 17:52:45 +0900 (KST) From: Andi Shyti To: linux-samsung-soc@vger.kernel.org Cc: Sangbeom Kim , Krzysztof Kozlowski , Michael Turquette , Stephen Boyd , linux-kernel@vger.kernel.org, linux-clk@vger.kernel.org, Andi Shyti , Andi Shyti , Yadwinder Singh Brar Subject: [PATCH v2 3/3] clk: s2mps11: remove redundant code Date: Tue, 19 Jan 2016 17:52:32 +0900 Message-id: <1453193552-4761-4-git-send-email-andi.shyti@samsung.com> X-Mailer: git-send-email 2.6.4 In-reply-to: <1453193552-4761-1-git-send-email-andi.shyti@samsung.com> References: <1453193552-4761-1-git-send-email-andi.shyti@samsung.com> X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFnrHLMWRmVeSWpSXmKPExsWyRsSkUDfu59wwg3WNHBbbjzxjtVj84zmT xesXhhYfe+6xWlzeNYfNYsb5fUwWF0+5Wlxc8YXJ4seZbhaLub8bWR24PN7faGX3uNzXy+Rx fcknZo+ds+6ye/RtWcXo8XmTXABbFJdNSmpOZllqkb5dAlfGipXvWAv2ylUc+7WLpYGxS7KL kZNDQsBEYvKDv6wQtpjEhXvr2boYuTiEBFYwShybMIEJpmjhmWNQiaWMEpe7JzNBOB8ZJXaf vs4CUsUmoCnRdPsHG4gtIqAq8bltATtIEbPAHSaJ0+ePMIIkhAWsJbqv9YIVsQAVneprB2vm FXCVePnkMJDNAbROTmLSBAeQMKeAm8Ttnndg5wkBldz+fwZspoTANnaJ/ovXmCDmCEh8m3wI qldWYtMBZoirJSUOrrjBMoFReAEjwypG0dSC5ILipPQiY73ixNzi0rx0veT83E2MwGg4/e9Z /w7GuwesDzEKcDAq8fC+cJwbJsSaWFZcmXuI0RRow0RmKdHkfGDM5ZXEGxqbGVmYm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JguERZqvsj0zOmNAipS7XdPBf62Vhgdw5cnL/dFjcko7cPFix6X9f9q+yvdWx SizFGYmGWsxFxYkAkr3dSc4CAAA= DLP-Filter: Pass X-MTR: 20000000000000000@CPGS X-CFilter-Loop: Reflected Sender: linux-samsung-soc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-samsung-soc@vger.kernel.org X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, 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 This patch performs some code removal as it uses some variables for temporary use. Three changes: * In the probe function the s2mps11_clk pointer is used only to iterate through the s2mps11_clks. The naming itself brings confusion and the readability is not improved. * the s2mps11_name() define resolves the name of the a given device. As it is used only once, we can expand it where it's used and remove the defininition. * The **clk_table variable is declared as a static variable and used to reference some allocated memory, it's then assigned to the clk_data.clks. This cycle can be skipped and the declaration avoided. Signed-off-by: Andi Shyti --- drivers/clk/clk-s2mps11.c | 44 +++++++++++++++++++------------------------- 1 file changed, 19 insertions(+), 25 deletions(-) diff --git a/drivers/clk/clk-s2mps11.c b/drivers/clk/clk-s2mps11.c index cae92fc..09344bb 100644 --- a/drivers/clk/clk-s2mps11.c +++ b/drivers/clk/clk-s2mps11.c @@ -28,9 +28,6 @@ #include #include -#define s2mps11_name(a) (a->hw.init->name) - -static struct clk **clk_table; static struct clk_onecell_data clk_data; enum { @@ -139,21 +136,19 @@ static struct device_node *s2mps11_clk_parse_dt(struct platform_device *pdev, static int s2mps11_clk_probe(struct platform_device *pdev) { struct sec_pmic_dev *iodev = dev_get_drvdata(pdev->dev.parent); - struct s2mps11_clk *s2mps11_clks, *s2mps11_clk; + struct s2mps11_clk *s2mps11_clks; unsigned int s2mps11_reg; int i, ret = 0; enum sec_device_type hwid = platform_get_device_id(pdev)->driver_data; s2mps11_clks = devm_kcalloc(&pdev->dev, S2MPS11_CLKS_NUM, - sizeof(*s2mps11_clk), GFP_KERNEL); + sizeof(*s2mps11_clks), GFP_KERNEL); if (!s2mps11_clks) return -ENOMEM; - s2mps11_clk = s2mps11_clks; - - clk_table = devm_kcalloc(&pdev->dev, S2MPS11_CLKS_NUM, + clk_data.clks = devm_kcalloc(&pdev->dev, S2MPS11_CLKS_NUM, sizeof(struct clk *), GFP_KERNEL); - if (!clk_table) + if (!clk_data.clks) return -ENOMEM; switch (hwid) { @@ -179,33 +174,32 @@ static int s2mps11_clk_probe(struct platform_device *pdev) if (IS_ERR(s2mps11_clks->clk_np)) return PTR_ERR(s2mps11_clks->clk_np); - for (i = 0; i < S2MPS11_CLKS_NUM; i++, s2mps11_clk++) { + for (i = 0; i < S2MPS11_CLKS_NUM; i++) { if (i == S2MPS11_CLK_CP && hwid == S2MPS14X) continue; /* Skip clocks not present in some devices */ - s2mps11_clk->iodev = iodev; - s2mps11_clk->hw.init = &s2mps11_clks_init[i]; - s2mps11_clk->mask = 1 << i; - s2mps11_clk->reg = s2mps11_reg; - - s2mps11_clk->clk = devm_clk_register(&pdev->dev, - &s2mps11_clk->hw); - if (IS_ERR(s2mps11_clk->clk)) { + s2mps11_clks[i].iodev = iodev; + s2mps11_clks[i].hw.init = &s2mps11_clks_init[i]; + s2mps11_clks[i].mask = 1 << i; + s2mps11_clks[i].reg = s2mps11_reg; + + s2mps11_clks[i].clk = devm_clk_register(&pdev->dev, + &s2mps11_clks[i].hw); + if (IS_ERR(s2mps11_clks[i].clk)) { dev_err(&pdev->dev, "Fail to register : %s\n", - s2mps11_name(s2mps11_clk)); - ret = PTR_ERR(s2mps11_clk->clk); + s2mps11_clks_init[i].name); + ret = PTR_ERR(s2mps11_clks[i].clk); goto err_reg; } - s2mps11_clk->lookup = clkdev_create(s2mps11_clk->clk, - s2mps11_name(s2mps11_clk), NULL); - if (!s2mps11_clk->lookup) { + s2mps11_clks[i].lookup = clkdev_create(s2mps11_clks[i].clk, + s2mps11_clks_init[i].name, NULL); + if (!s2mps11_clks[i].lookup) { ret = -ENOMEM; goto err_reg; } - clk_table[i] = s2mps11_clks[i].clk; + clk_data.clks[i] = s2mps11_clks[i].clk; } - clk_data.clks = clk_table; clk_data.clk_num = S2MPS11_CLKS_NUM; of_clk_add_provider(s2mps11_clks->clk_np, of_clk_src_onecell_get, &clk_data);