From patchwork Sat Jan 25 18:34:10 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sebastian Hesselbarth X-Patchwork-Id: 3538751 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 207F39F377 for ; Sat, 25 Jan 2014 18:49:38 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 495BD2013D for ; Sat, 25 Jan 2014 18:49:33 +0000 (UTC) Received: from casper.infradead.org (casper.infradead.org [85.118.1.10]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 0A1FA2012F for ; Sat, 25 Jan 2014 18:49:32 +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 1W786M-0005wQ-Ac; Sat, 25 Jan 2014 18:37:09 +0000 Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1W785b-00067w-0f; Sat, 25 Jan 2014 18:36:19 +0000 Received: from mail-ee0-x235.google.com ([2a00:1450:4013:c00::235]) by merlin.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1W784C-0005yB-Qi for linux-arm-kernel@lists.infradead.org; Sat, 25 Jan 2014 18:35:08 +0000 Received: by mail-ee0-f53.google.com with SMTP id t10so1502254eei.26 for ; Sat, 25 Jan 2014 10:34:30 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=r46WfNfTcUNtLZS8Y+6oSNVxHx3vKiJvr8zNKVnjgNg=; b=n7vuCiubq8OVk/tiG2IcSdyFnqW8WY8iTDb1BtgeKLODwwH/8PYMLw3Y8G+kKAg/jm UmJG4mK+BHhGgHTaTQgYGGmPOSYeFCR5iCtMsm4iZP98HCGxqvRlSWnb/w1/4BW3Y0Cb q2LdH/vhxi32Pjbep6aPhx8+tkS2RjAVHzVcu4dN8W/+mwmBMCu0PWujeAI/H4/2kNxO +7utdxQBE4pQdqK+Uusnvuk2akDK7EZxzBFeoSaC5dZQJUtAt7g+P0Zl7BaO4EHz2yxY hDTwlrc1jNdnsbFFNWbi0rfoS4oleP3MAv3p0aqiwayjKx5VeANOpk6Tmlymi5ZaeXbY JF6A== X-Received: by 10.14.94.130 with SMTP id n2mr36966eef.112.1390674870788; Sat, 25 Jan 2014 10:34:30 -0800 (PST) Received: from topkick.lan (dslc-082-083-251-183.pools.arcor-ip.net. [82.83.251.183]) by mx.google.com with ESMTPSA id k41sm18941968eey.0.2014.01.25.10.34.29 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sat, 25 Jan 2014 10:34:30 -0800 (PST) From: Sebastian Hesselbarth To: Sebastian Hesselbarth Subject: [PATCH 05/11] pinctrl: mvebu: fix misdesigned resource allocation Date: Sat, 25 Jan 2014 19:34:10 +0100 Message-Id: <1390674856-4993-6-git-send-email-sebastian.hesselbarth@gmail.com> In-Reply-To: <1390674856-4993-1-git-send-email-sebastian.hesselbarth@gmail.com> References: <1390674856-4993-1-git-send-email-sebastian.hesselbarth@gmail.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20140125_133453_193112_A057D7F2 X-CRM114-Status: GOOD ( 15.89 ) X-Spam-Score: -2.0 (--) Cc: Andrew Lunn , Jason Cooper , Linus Walleij , linux-kernel@vger.kernel.org, Gregory Clement , 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: , MIME-Version: 1.0 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.6 required=5.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_MED, RP_MATCHES_RCVD, T_DKIM_INVALID, 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 Allocating the pinctrl resource in common pinctrl-mvebu was a misdesign, as it does not allow SoC specific parts to access the allocated resource. This moves resource allocation from mvebu_pinctrl_probe to SoC specific _probe functions and passes the base address to common pinctrl driver instead. Signed-off-by: Sebastian Hesselbarth --- Cc: Jason Cooper Cc: Andrew Lunn Cc: Gregory Clement Cc: Linus Walleij Cc: linux-arm-kernel@lists.infradead.org Cc: linux-kernel@vger.kernel.org --- drivers/pinctrl/mvebu/pinctrl-armada-370.c | 9 ++++++++- drivers/pinctrl/mvebu/pinctrl-armada-xp.c | 9 ++++++++- drivers/pinctrl/mvebu/pinctrl-dove.c | 10 +++++++++- drivers/pinctrl/mvebu/pinctrl-kirkwood.c | 10 +++++++++- drivers/pinctrl/mvebu/pinctrl-mvebu.c | 14 ++++++-------- drivers/pinctrl/mvebu/pinctrl-mvebu.h | 2 +- 6 files changed, 41 insertions(+), 13 deletions(-) diff --git a/drivers/pinctrl/mvebu/pinctrl-armada-370.c b/drivers/pinctrl/mvebu/pinctrl-armada-370.c index ae1f760cbdd2..4f6a65b32f06 100644 --- a/drivers/pinctrl/mvebu/pinctrl-armada-370.c +++ b/drivers/pinctrl/mvebu/pinctrl-armada-370.c @@ -385,6 +385,13 @@ static struct pinctrl_gpio_range mv88f6710_mpp_gpio_ranges[] = { static int armada_370_pinctrl_probe(struct platform_device *pdev) { struct mvebu_pinctrl_soc_info *soc = &armada_370_pinctrl_info; + struct resource *res; + void __iomem *base; + + res = platform_get_resource(pdev, IORESOURCE_MEM, 0); + base = devm_ioremap_resource(&pdev->dev, res); + if (IS_ERR(base)) + return PTR_ERR(base); soc->variant = 0; /* no variants for Armada 370 */ soc->controls = mv88f6710_mpp_controls; @@ -396,7 +403,7 @@ static int armada_370_pinctrl_probe(struct platform_device *pdev) pdev->dev.platform_data = soc; - return mvebu_pinctrl_probe(pdev); + return mvebu_pinctrl_probe(pdev, base); } static int armada_370_pinctrl_remove(struct platform_device *pdev) diff --git a/drivers/pinctrl/mvebu/pinctrl-armada-xp.c b/drivers/pinctrl/mvebu/pinctrl-armada-xp.c index 843a51f9d129..e4be7ab4c948 100644 --- a/drivers/pinctrl/mvebu/pinctrl-armada-xp.c +++ b/drivers/pinctrl/mvebu/pinctrl-armada-xp.c @@ -399,10 +399,17 @@ static int armada_xp_pinctrl_probe(struct platform_device *pdev) struct mvebu_pinctrl_soc_info *soc = &armada_xp_pinctrl_info; const struct of_device_id *match = of_match_device(armada_xp_pinctrl_of_match, &pdev->dev); + struct resource *res; + void __iomem *base; if (!match) return -ENODEV; + res = platform_get_resource(pdev, IORESOURCE_MEM, 0); + base = devm_ioremap_resource(&pdev->dev, res); + if (IS_ERR(base)) + return PTR_ERR(base); + soc->variant = (unsigned) match->data & 0xff; switch (soc->variant) { @@ -443,7 +450,7 @@ static int armada_xp_pinctrl_probe(struct platform_device *pdev) pdev->dev.platform_data = soc; - return mvebu_pinctrl_probe(pdev); + return mvebu_pinctrl_probe(pdev, base); } static int armada_xp_pinctrl_remove(struct platform_device *pdev) diff --git a/drivers/pinctrl/mvebu/pinctrl-dove.c b/drivers/pinctrl/mvebu/pinctrl-dove.c index 47268393af34..f4141e60a52b 100644 --- a/drivers/pinctrl/mvebu/pinctrl-dove.c +++ b/drivers/pinctrl/mvebu/pinctrl-dove.c @@ -776,6 +776,14 @@ static int dove_pinctrl_probe(struct platform_device *pdev) { const struct of_device_id *match = of_match_device(dove_pinctrl_of_match, &pdev->dev); + struct resource *res; + void __iomem *base; + + res = platform_get_resource(pdev, IORESOURCE_MEM, 0); + base = devm_ioremap_resource(&pdev->dev, res); + if (IS_ERR(base)) + return PTR_ERR(base); + pdev->dev.platform_data = (void *)match->data; /* @@ -789,7 +797,7 @@ static int dove_pinctrl_probe(struct platform_device *pdev) } clk_prepare_enable(clk); - return mvebu_pinctrl_probe(pdev); + return mvebu_pinctrl_probe(pdev, base); } static int dove_pinctrl_remove(struct platform_device *pdev) diff --git a/drivers/pinctrl/mvebu/pinctrl-kirkwood.c b/drivers/pinctrl/mvebu/pinctrl-kirkwood.c index 6b504b5935a5..e515288bde35 100644 --- a/drivers/pinctrl/mvebu/pinctrl-kirkwood.c +++ b/drivers/pinctrl/mvebu/pinctrl-kirkwood.c @@ -458,8 +458,16 @@ static int kirkwood_pinctrl_probe(struct platform_device *pdev) { const struct of_device_id *match = of_match_device(kirkwood_pinctrl_of_match, &pdev->dev); + struct resource *res; + void __iomem *base; + + res = platform_get_resource(pdev, IORESOURCE_MEM, 0); + base = devm_ioremap_resource(&pdev->dev, res); + if (IS_ERR(base)) + return PTR_ERR(base); + pdev->dev.platform_data = (void *)match->data; - return mvebu_pinctrl_probe(pdev); + return mvebu_pinctrl_probe(pdev, base); } static int kirkwood_pinctrl_remove(struct platform_device *pdev) diff --git a/drivers/pinctrl/mvebu/pinctrl-mvebu.c b/drivers/pinctrl/mvebu/pinctrl-mvebu.c index 0fd1ad31fbf9..90c35b20a7af 100644 --- a/drivers/pinctrl/mvebu/pinctrl-mvebu.c +++ b/drivers/pinctrl/mvebu/pinctrl-mvebu.c @@ -590,26 +590,24 @@ static int mvebu_pinctrl_build_functions(struct platform_device *pdev, return 0; } -int mvebu_pinctrl_probe(struct platform_device *pdev) +int mvebu_pinctrl_probe(struct platform_device *pdev, void __iomem *base) { struct mvebu_pinctrl_soc_info *soc = dev_get_platdata(&pdev->dev); - struct resource *res; struct mvebu_pinctrl *pctl; - void __iomem *base; struct pinctrl_pin_desc *pdesc; unsigned gid, n, k; int ret; + if (!base) { + dev_err(&pdev->dev, "missing base address\n"); + return -EINVAL; + } + if (!soc || !soc->controls || !soc->modes) { dev_err(&pdev->dev, "wrong pinctrl soc info\n"); return -EINVAL; } - res = platform_get_resource(pdev, IORESOURCE_MEM, 0); - base = devm_ioremap_resource(&pdev->dev, res); - if (IS_ERR(base)) - return PTR_ERR(base); - pctl = devm_kzalloc(&pdev->dev, sizeof(struct mvebu_pinctrl), GFP_KERNEL); if (!pctl) { diff --git a/drivers/pinctrl/mvebu/pinctrl-mvebu.h b/drivers/pinctrl/mvebu/pinctrl-mvebu.h index 90bd3beee860..b66949040e0a 100644 --- a/drivers/pinctrl/mvebu/pinctrl-mvebu.h +++ b/drivers/pinctrl/mvebu/pinctrl-mvebu.h @@ -186,7 +186,7 @@ struct mvebu_pinctrl_soc_info { .npins = _npins, \ } -int mvebu_pinctrl_probe(struct platform_device *pdev); +int mvebu_pinctrl_probe(struct platform_device *pdev, void __iomem *base); int mvebu_pinctrl_remove(struct platform_device *pdev); #endif