From patchwork Tue Jan 19 08:52:30 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andi Shyti X-Patchwork-Id: 8059221 Return-Path: X-Original-To: patchwork-linux-samsung-soc@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id CF21EBEEE5 for ; Tue, 19 Jan 2016 08:53:27 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id C826E203A0 for ; Tue, 19 Jan 2016 08:53:26 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id A227B20386 for ; Tue, 19 Jan 2016 08:53:25 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752310AbcASIwv (ORCPT ); Tue, 19 Jan 2016 03:52:51 -0500 Received: from mailout1.samsung.com ([203.254.224.24]:56800 "EHLO mailout1.samsung.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752357AbcASIwr (ORCPT ); Tue, 19 Jan 2016 03:52:47 -0500 Received: from epcpsbgr2.samsung.com (u142.gpu120.samsung.co.kr [203.254.230.142]) by mailout1.samsung.com (Oracle Communications Messaging Server 7.0.5.31.0 64bit (built May 5 2014)) with ESMTP id <0O160132QZBXSN50@mailout1.samsung.com>; Tue, 19 Jan 2016 17:52:45 +0900 (KST) Received: from epcpsbgm2new.samsung.com ( [172.20.52.114]) by epcpsbgr2.samsung.com (EPCPMTA) with SMTP id F5.94.04972.D59FD965; Tue, 19 Jan 2016 17:52:45 +0900 (KST) X-AuditID: cbfee68e-f793c6d00000136c-f5-569df95d5486 Received: from epmmp1.local.host ( [203.254.227.16]) by epcpsbgm2new.samsung.com (EPCPMTA) with SMTP id 3E.CD.09068.D59FD965; Tue, 19 Jan 2016 17:52:45 +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 1/3] clk: s2mps11: allocate only one structure for clock init Date: Tue, 19 Jan 2016 17:52:30 +0900 Message-id: <1453193552-4761-2-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+NgFnrLLMWRmVeSWpSXmKPExsWyRsSkSDf259wwgy8n9Sy2H3nGarH4x3Mm i9cvDC0+9txjtbi8aw6bxYzz+5gsLp5ytbi44guTxY8z3SwWc383sjpweby/0crucbmvl8nj +pJPzB47Z91l9+jbsorR4/MmuQC2KC6blNSczLLUIn27BK6MqTeWMhe8Vq/YdPwWewPjZoUu Rg4OCQETiZ9nRLoYOYFMMYkL99azdTFycQgJrGCUWLDnEAtEwkRidfc2JojEUkaJr1uWQjkf GSV2n74OVsUmoCnRdPsHG4gtIqAq8bltATtIEbPAHSaJ0+ePMIIkhAUCJPpOd4AVsQAVPX17 iBXE5hVwlXi6dBo7xElyEpMmOICEOQXcJG73vAMrEQIquf3/DNhMCYFd7BKHrvWxQ8wRkPg2 GeRUkF5ZiU0HmCGulpQ4uOIGywRG4QWMDKsYRVMLkguKk9KLjPSKE3OLS/PS9ZLzczcxAmPh 9L9nfTsYbx6wPsQowMGoxMP7wnFumBBrYllxZe4hRlOgDROZpUST84ERl1cSb2hsZm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zx8+Z7zS54ssrU bJbQo/tOE7tbuHZJ5kRPDnCQZp/T0nVrrWZZabsexxJdtuuCz7emam7+EHyvX5p7g3J536vp +wu6lFiKMxINtZiLihMBwXGQCM4CAAA= 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 The driver allocates three structures for three different clock types. They are quite similar and in the clock init data they differ only by the name. Only one of these structures is used, while the others lie unused in the memory. The clock's name, though, is not such a meaningful information and by assigning the same name to the initial data we can avoid over allocation. The common name chosen will be s2mps11, coherently with the device driver name, instead of the clock device. Therefore, remove the structures associated to s2mps13 and s2mps14 and use only the one referred to s2mps11 for all kind of clocks. Signed-off-by: Andi Shyti Suggested-by: Krzysztof Kozlowski --- drivers/clk/clk-s2mps11.c | 56 ++++++----------------------------------------- 1 file changed, 7 insertions(+), 49 deletions(-) diff --git a/drivers/clk/clk-s2mps11.c b/drivers/clk/clk-s2mps11.c index d266299..22d4df2 100644 --- a/drivers/clk/clk-s2mps11.c +++ b/drivers/clk/clk-s2mps11.c @@ -99,6 +99,7 @@ static struct clk_ops s2mps11_clk_ops = { .recalc_rate = s2mps11_clk_recalc_rate, }; +/* This s2mps11_clks_init tructure is common to s2mps11, s2mps13 and s2mps14 */ static struct clk_init_data s2mps11_clks_init[S2MPS11_CLKS_NUM] = { [S2MPS11_CLK_AP] = { .name = "s2mps11_ap", @@ -117,43 +118,11 @@ static struct clk_init_data s2mps11_clks_init[S2MPS11_CLKS_NUM] = { }, }; -static struct clk_init_data s2mps13_clks_init[S2MPS11_CLKS_NUM] = { - [S2MPS11_CLK_AP] = { - .name = "s2mps13_ap", - .ops = &s2mps11_clk_ops, - .flags = CLK_IS_ROOT, - }, - [S2MPS11_CLK_CP] = { - .name = "s2mps13_cp", - .ops = &s2mps11_clk_ops, - .flags = CLK_IS_ROOT, - }, - [S2MPS11_CLK_BT] = { - .name = "s2mps13_bt", - .ops = &s2mps11_clk_ops, - .flags = CLK_IS_ROOT, - }, -}; - -static struct clk_init_data s2mps14_clks_init[S2MPS11_CLKS_NUM] = { - [S2MPS11_CLK_AP] = { - .name = "s2mps14_ap", - .ops = &s2mps11_clk_ops, - .flags = CLK_IS_ROOT, - }, - [S2MPS11_CLK_BT] = { - .name = "s2mps14_bt", - .ops = &s2mps11_clk_ops, - .flags = CLK_IS_ROOT, - }, -}; - static struct device_node *s2mps11_clk_parse_dt(struct platform_device *pdev, struct clk_init_data *clks_init) { struct sec_pmic_dev *iodev = dev_get_drvdata(pdev->dev.parent); struct device_node *clk_np; - int i; if (!iodev->dev->of_node) return ERR_PTR(-EINVAL); @@ -164,13 +133,6 @@ static struct device_node *s2mps11_clk_parse_dt(struct platform_device *pdev, return ERR_PTR(-EINVAL); } - for (i = 0; i < S2MPS11_CLKS_NUM; i++) { - if (!clks_init[i].name) - continue; /* Skip clocks not present in some devices */ - of_property_read_string_index(clk_np, "clock-output-names", i, - &clks_init[i].name); - } - return clk_np; } @@ -179,8 +141,8 @@ 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; unsigned int s2mps11_reg; - struct clk_init_data *clks_init; 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); @@ -194,22 +156,18 @@ static int s2mps11_clk_probe(struct platform_device *pdev) if (!clk_table) return -ENOMEM; - switch(platform_get_device_id(pdev)->driver_data) { + switch (hwid) { case S2MPS11X: s2mps11_reg = S2MPS11_REG_RTC_CTRL; - clks_init = s2mps11_clks_init; break; case S2MPS13X: s2mps11_reg = S2MPS13_REG_RTCCTRL; - clks_init = s2mps13_clks_init; break; case S2MPS14X: s2mps11_reg = S2MPS14_REG_RTCCTRL; - clks_init = s2mps14_clks_init; break; case S5M8767X: s2mps11_reg = S5M8767_REG_CTRL1; - clks_init = s2mps11_clks_init; break; default: dev_err(&pdev->dev, "Invalid device type\n"); @@ -217,15 +175,15 @@ static int s2mps11_clk_probe(struct platform_device *pdev) } /* Store clocks of_node in first element of s2mps11_clks array */ - s2mps11_clks->clk_np = s2mps11_clk_parse_dt(pdev, clks_init); + s2mps11_clks->clk_np = s2mps11_clk_parse_dt(pdev, s2mps11_clks_init); if (IS_ERR(s2mps11_clks->clk_np)) return PTR_ERR(s2mps11_clks->clk_np); for (i = 0; i < S2MPS11_CLKS_NUM; i++, s2mps11_clk++) { - if (!clks_init[i].name) + if (i == S2MPS11_CLK_CP && hwid == S2MPS14X) continue; /* Skip clocks not present in some devices */ s2mps11_clk->iodev = iodev; - s2mps11_clk->hw.init = &clks_init[i]; + s2mps11_clk->hw.init = &s2mps11_clks_init[i]; s2mps11_clk->mask = 1 << i; s2mps11_clk->reg = s2mps11_reg; @@ -248,7 +206,7 @@ static int s2mps11_clk_probe(struct platform_device *pdev) for (i = 0; i < S2MPS11_CLKS_NUM; i++) { /* Skip clocks not present on S2MPS14 */ - if (!clks_init[i].name) + if (i == S2MPS11_CLK_CP && hwid == S2MPS14X) continue; clk_table[i] = s2mps11_clks[i].clk; }