From patchwork Fri Mar 22 13:39:25 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Florian Fainelli X-Patchwork-Id: 2320321 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork2.kernel.org Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) by patchwork2.kernel.org (Postfix) with ESMTP id 8F412DFE82 for ; Fri, 22 Mar 2013 13:50:38 +0000 (UTC) Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1UJ2Jl-0002UT-Ly; Fri, 22 Mar 2013 13:47:37 +0000 Received: from zmc.proxad.net ([212.27.53.206]) by merlin.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1UJ2C5-0006JJ-1l for linux-arm-kernel@lists.infradead.org; Fri, 22 Mar 2013 13:39:46 +0000 Received: from localhost (localhost [127.0.0.1]) by zmc.proxad.net (Postfix) with ESMTP id 5EE0BC5C79A; Fri, 22 Mar 2013 14:39:36 +0100 (CET) X-Virus-Scanned: amavisd-new at localhost Received: from zmc.proxad.net ([127.0.0.1]) by localhost (zmc.proxad.net [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id fPgy-LgOtSTA; Fri, 22 Mar 2013 14:39:35 +0100 (CET) Received: from flexo.iliad.local (freebox.vlq16.iliad.fr [213.36.7.13]) by zmc.proxad.net (Postfix) with ESMTPSA id B9579C5C551; Fri, 22 Mar 2013 14:39:35 +0100 (CET) From: Florian Fainelli To: davem@davemloft.net Subject: [PATCH 1/4 v3] net: mvmdio: allow platform device style registration Date: Fri, 22 Mar 2013 14:39:25 +0100 Message-Id: <1363959568-16976-2-git-send-email-florian@openwrt.org> X-Mailer: git-send-email 1.7.10.4 In-Reply-To: <1363959568-16976-1-git-send-email-florian@openwrt.org> References: <1363284515-9865-1-git-send-email-florian@openwrt.org> <1363959568-16976-1-git-send-email-florian@openwrt.org> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20130322_093942_723534_74B1A91B X-CRM114-Status: GOOD ( 15.55 ) X-Spam-Score: -1.9 (-) X-Spam-Report: SpamAssassin version 3.3.2 on merlin.infradead.org summary: Content analysis details: (-1.9 points) pts rule name description ---- ---------------------- -------------------------------------------------- -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] Cc: Thomas Petazzoni , Andrew Lunn , Russell King , Jason Cooper , linux-doc@vger.kernel.org, Benjamin Herrenschmidt , devicetree-discuss@lists.ozlabs.org, linux-kernel@vger.kernel.org, Rob Herring , Grant Likely , netdev@vger.kernel.org, Paul Mackerras , linux-arm-kernel@lists.infradead.org, Rob Landley , Greg Kroah-Hartman , linuxppc-dev@lists.ozlabs.org, Florian Fainelli , Lennert Buytenhek 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 This patch changes the mvmdio driver not to use device tree helper functions such as of_mdiobus_register() and of_iomap() so we can instantiate this driver using a classic platform_device approach. Use the device manager helper to ioremap() the base register cookie so we get automatic freeing upon error and removal. This change is harmless for Device Tree platforms because they will get the driver be registered the same way as it was before. Signed-off-by: Florian Fainelli --- Changes since v2: - use of_mdiobus_register if device tree node is available to ensure that all child PHY nodes get also registered (fixes PHY probing on DT-only) Changes since v1: - use device managed helpers to fix an ioremap leak in remove function - remove the use of Device Tree specific helpers to allow platform-style registration drivers/net/ethernet/marvell/mvmdio.c | 22 +++++++++++++++------- 1 file changed, 15 insertions(+), 7 deletions(-) diff --git a/drivers/net/ethernet/marvell/mvmdio.c b/drivers/net/ethernet/marvell/mvmdio.c index 77b7c80..bbc5fde 100644 --- a/drivers/net/ethernet/marvell/mvmdio.c +++ b/drivers/net/ethernet/marvell/mvmdio.c @@ -24,10 +24,10 @@ #include #include #include -#include -#include #include #include +#include +#include #define MVMDIO_SMI_DATA_SHIFT 0 #define MVMDIO_SMI_PHY_ADDR_SHIFT 16 @@ -143,11 +143,17 @@ static int orion_mdio_reset(struct mii_bus *bus) static int orion_mdio_probe(struct platform_device *pdev) { - struct device_node *np = pdev->dev.of_node; + struct resource *r; struct mii_bus *bus; struct orion_mdio_dev *dev; int i, ret; + r = platform_get_resource(pdev, IORESOURCE_MEM, 0); + if (!r) { + dev_err(&pdev->dev, "No SMI register address given\n"); + return -ENODEV; + } + bus = mdiobus_alloc_size(sizeof(struct orion_mdio_dev)); if (!bus) { dev_err(&pdev->dev, "Cannot allocate MDIO bus\n"); @@ -172,9 +178,9 @@ static int orion_mdio_probe(struct platform_device *pdev) bus->irq[i] = PHY_POLL; dev = bus->priv; - dev->smireg = of_iomap(pdev->dev.of_node, 0); + dev->smireg = devm_ioremap(&pdev->dev, r->start, resource_size(r)); if (!dev->smireg) { - dev_err(&pdev->dev, "No SMI register address given in DT\n"); + dev_err(&pdev->dev, "Unable to remap SMI register\n"); kfree(bus->irq); mdiobus_free(bus); return -ENODEV; @@ -182,10 +188,12 @@ static int orion_mdio_probe(struct platform_device *pdev) mutex_init(&dev->lock); - ret = of_mdiobus_register(bus, np); + if (pdev->dev.of_node) + ret = of_mdiobus_register(bus, pdev->dev.of_node); + else + ret = mdiobus_register(bus); if (ret < 0) { dev_err(&pdev->dev, "Cannot register MDIO bus (%d)\n", ret); - iounmap(dev->smireg); kfree(bus->irq); mdiobus_free(bus); return ret;