From patchwork Tue Aug 23 06:26:49 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marcin Wojtas X-Patchwork-Id: 9295021 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 4C45D60757 for ; Tue, 23 Aug 2016 06:22:40 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 3E3E627F2B for ; Tue, 23 Aug 2016 06:22:40 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 3198728B48; Tue, 23 Aug 2016 06:22:40 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-4.1 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_MED,T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.9]) (using TLSv1.2 with cipher AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id C89E327F2B for ; Tue, 23 Aug 2016 06:22:39 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.85_2 #1 (Red Hat Linux)) id 1bc55R-0007xh-17; Tue, 23 Aug 2016 06:21:25 +0000 Received: from mail-lf0-x22f.google.com ([2a00:1450:4010:c07::22f]) by bombadil.infradead.org with esmtps (Exim 4.85_2 #1 (Red Hat Linux)) id 1bc54k-0007PF-2u for linux-arm-kernel@lists.infradead.org; Tue, 23 Aug 2016 06:20:43 +0000 Received: by mail-lf0-x22f.google.com with SMTP id g62so93410499lfe.3 for ; Mon, 22 Aug 2016 23:20:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=semihalf-com.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=e0G1Ioy2xULIgT7G9GTCwOAVJiz+fIov5/pAm8615tI=; b=d1b/azK69vdN9Qx8mVgHDKI7k6Kf7MbYDUFqHJw8KcTBLQVozU0oxMV1N1QUGsFhie RSOZNkbxXANHip8Q5zGGjXQTtMUKzvRmkvmTsSK0s1IaKth3EzDYzGl8/ncD5+8G+nQ/ WLrbnDJ9Vbn6aAy9kcKi647QURdsbDJ3laXw7fcxqQqFYtUYDDPYUvUR7h/xDPbgEnL/ A+6oy6dh2LQQW4ff4dUTdtFTsarcmNQDdzuHtqaDnnu+IC5PH7T6q71P63UUmMH2wLYr KmjlxHuw031ct9zBqhivh7NcT/GMuI1Hz4Mk6nM2rTHPnx53jTTq9S9JMQyGVSjjXBIS mLiw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=e0G1Ioy2xULIgT7G9GTCwOAVJiz+fIov5/pAm8615tI=; b=LiMCWrZM9kitZxK5s9YCpNIphbU3GFNUwTgHsl8lFLaprQSYfq0DIy+limD0zX6UUs E1u5j1gtfWMmnDExFCKnUx/pRzdhdKQBsNrBZ636bcInglVCOYoS3ME8NAI9qWPO5XCm edkPfzjNpie1ULYneb/NHObVk7q3HUwMVxqQ2t1ex0u7zH2nO3aCQ1SiGh/m00rRiUor f9rvFlkUnVFbFIh58G6kDsCHc4gOLdNixhW0uIWQ7Cj2STwU72MBP45Wf8l3mdROd7L2 0AhdyXDR7U3ZXwYen728n7MnhZfjDPlL3D8n4jundSBLaiEzEsR0/UK3aoAs7wp34tjN ttmQ== X-Gm-Message-State: AEkoouvj5EOFNv0dvOz9Ib3iM6u4HQUQ4rnvATJwayqWDMZ3B2iRjWtsMYBi20GT1CRqng== X-Received: by 10.25.15.98 with SMTP id e95mr7063212lfi.55.1471933219717; Mon, 22 Aug 2016 23:20:19 -0700 (PDT) Received: from enkidu.semihalf.local (31-172-191-173.noc.fibertech.net.pl. [31.172.191.173]) by smtp.gmail.com with ESMTPSA id d15sm419335lfg.0.2016.08.22.23.20.17 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 22 Aug 2016 23:20:19 -0700 (PDT) From: Marcin Wojtas To: linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-clk@vger.kernel.org, sboyd@codeaurora.org, mturquette@baylibre.com Subject: [PATCH 2/2] clk: mvebu: dynamically allocate resources in Armada CP110 system controller Date: Tue, 23 Aug 2016 08:26:49 +0200 Message-Id: <1471933609-8456-3-git-send-email-mw@semihalf.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1471933609-8456-1-git-send-email-mw@semihalf.com> References: <1471933609-8456-1-git-send-email-mw@semihalf.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20160822_232042_461041_A4195733 X-CRM114-Status: GOOD ( 13.98 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: thomas.petazzoni@free-electrons.com, andrew@lunn.ch, jason@lakedaemon.net, tn@semihalf.com, nadavh@marvell.com, alior@marvell.com, jaz@semihalf.com, gregory.clement@free-electrons.com, Marcin Wojtas , sebastian.hesselbarth@gmail.com MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP Original commit, which added support for Armada CP110 system controller used global variables for storing all clock information. It worked fine for Armada 7k SoC, with single CP110 block. After dual-CP110 Armada 8k was introduced, the data got overwritten and corrupted. This patch fixes the issue by allocating resources dynamically in the driver probe and storing it as platform drvdata. Fixes: d3da3eaef7f4 ("clk: mvebu: new driver for Armada CP110 system ...") Signed-off-by: Marcin Wojtas Tested-by: Thomas Petazzoni Reviewed-by: Thomas Petazzoni --- drivers/clk/mvebu/cp110-system-controller.c | 29 ++++++++++++++++++++--------- 1 file changed, 20 insertions(+), 9 deletions(-) diff --git a/drivers/clk/mvebu/cp110-system-controller.c b/drivers/clk/mvebu/cp110-system-controller.c index 0835e1d..2bd87d2 100644 --- a/drivers/clk/mvebu/cp110-system-controller.c +++ b/drivers/clk/mvebu/cp110-system-controller.c @@ -81,13 +81,6 @@ enum { #define CP110_GATE_EIP150 25 #define CP110_GATE_EIP197 26 -static struct clk *cp110_clks[CP110_CLK_NUM]; - -static struct clk_onecell_data cp110_clk_data = { - .clks = cp110_clks, - .clk_num = CP110_CLK_NUM, -}; - struct cp110_gate_clk { struct clk_hw hw; struct regmap *regmap; @@ -195,7 +188,8 @@ static int cp110_syscon_clk_probe(struct platform_device *pdev) struct regmap *regmap; struct device_node *np = pdev->dev.of_node; const char *ppv2_name, *apll_name, *core_name, *eip_name, *nand_name; - struct clk *clk; + struct clk_onecell_data *cp110_clk_data; + struct clk *clk, **cp110_clks; u32 nand_clk_ctrl; int i, ret; @@ -208,6 +202,20 @@ static int cp110_syscon_clk_probe(struct platform_device *pdev) if (ret) return ret; + cp110_clks = devm_kcalloc(&pdev->dev, sizeof(struct clk *), + CP110_CLK_NUM, GFP_KERNEL); + if (IS_ERR(cp110_clks)) + return PTR_ERR(cp110_clks); + + cp110_clk_data = devm_kzalloc(&pdev->dev, + sizeof(struct clk_onecell_data), + GFP_KERNEL); + if (IS_ERR(cp110_clk_data)) + return PTR_ERR(cp110_clk_data); + + cp110_clk_data->clks = cp110_clks; + cp110_clk_data->clk_num = CP110_CLK_NUM; + /* Register the APLL which is the root of the clk tree */ of_property_read_string_index(np, "core-clock-output-names", CP110_CORE_APLL, &apll_name); @@ -335,10 +343,12 @@ static int cp110_syscon_clk_probe(struct platform_device *pdev) cp110_clks[CP110_MAX_CORE_CLOCKS + i] = clk; } - ret = of_clk_add_provider(np, cp110_of_clk_get, &cp110_clk_data); + ret = of_clk_add_provider(np, cp110_of_clk_get, cp110_clk_data); if (ret) goto fail_clk_add; + platform_set_drvdata(pdev, cp110_clks); + return 0; fail_clk_add: @@ -365,6 +375,7 @@ fail0: static int cp110_syscon_clk_remove(struct platform_device *pdev) { + struct clk **cp110_clks = platform_get_drvdata(pdev); int i; of_clk_del_provider(pdev->dev.of_node);