From patchwork Tue Jan 29 15:24:07 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Florian Fainelli X-Patchwork-Id: 2062461 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 5869BE00D9 for ; Tue, 29 Jan 2013 15:30:16 +0000 (UTC) Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.76 #1 (Red Hat Linux)) id 1U0D69-0000Kt-Un; Tue, 29 Jan 2013 15:27:45 +0000 Received: from zmc.proxad.net ([212.27.53.206]) by merlin.infradead.org with esmtp (Exim 4.76 #1 (Red Hat Linux)) id 1U0D5Z-00007I-CF for linux-arm-kernel@lists.infradead.org; Tue, 29 Jan 2013 15:27:13 +0000 Received: from localhost (localhost [127.0.0.1]) by zmc.proxad.net (Postfix) with ESMTP id F33B9BF7B53; Tue, 29 Jan 2013 16:27:07 +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 PshpxfCUF7MC; Tue, 29 Jan 2013 16:27:06 +0100 (CET) Received: from flexo.localdomain (freebox.vlq16.iliad.fr [213.36.7.13]) by zmc.proxad.net (Postfix) with ESMTPSA id 92253BF7CA5; Tue, 29 Jan 2013 16:27:06 +0100 (CET) From: Florian Fainelli To: davem@davemloft.net Subject: [PATCH 4/5] net: mvmdio: allow Device Tree and platform device to coexist Date: Tue, 29 Jan 2013 16:24:07 +0100 Message-Id: <1359473048-26551-5-git-send-email-florian@openwrt.org> X-Mailer: git-send-email 1.7.10.4 In-Reply-To: <1359473048-26551-1-git-send-email-florian@openwrt.org> References: <1359473048-26551-1-git-send-email-florian@openwrt.org> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20130129_102709_697611_240DD260 X-CRM114-Status: GOOD ( 15.39 ) X-Spam-Score: 1.1 (+) X-Spam-Report: SpamAssassin version 3.3.2 on merlin.infradead.org summary: Content analysis details: (1.1 points) pts rule name description ---- ---------------------- -------------------------------------------------- 3.0 KHOP_BIG_TO_CC Sent to 10+ recipients instaed of Bcc or a list -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.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: linux-arm-kernel-bounces@lists.infradead.org Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org This patch changes the Marvell MDIO driver to be registered by using both Device Tree and platform device methods. The driver voluntarily does not use devm_ioremap() to share the same error path for Device Tree and non-Device Tree cases. Signed-off-by: Florian Fainelli --- drivers/net/ethernet/marvell/mvmdio.c | 46 +++++++++++++++++++++++---------- 1 file changed, 33 insertions(+), 13 deletions(-) diff --git a/drivers/net/ethernet/marvell/mvmdio.c b/drivers/net/ethernet/marvell/mvmdio.c index cada794..10c593c 100644 --- a/drivers/net/ethernet/marvell/mvmdio.c +++ b/drivers/net/ethernet/marvell/mvmdio.c @@ -190,6 +190,7 @@ static irqreturn_t orion_mdio_err_irq(int irq, void *dev_id) static int orion_mdio_probe(struct platform_device *pdev) { struct device_node *np = pdev->dev.of_node; + struct resource *r = NULL; struct mii_bus *bus; struct orion_mdio_dev *dev; int i, ret; @@ -219,18 +220,31 @@ static int orion_mdio_probe(struct platform_device *pdev) bus->irq[i] = PHY_POLL; dev = bus->priv; - dev->regs = of_iomap(pdev->dev.of_node, 0); - if (!dev->regs) { - dev_err(&pdev->dev, "No SMI register address given in DT\n"); - kfree(bus->irq); - mdiobus_free(bus); - return -ENODEV; - } - dev->err_interrupt = NO_IRQ; init_waitqueue_head(&dev->smi_busy_wait); - dev->err_interrupt = irq_of_parse_and_map(pdev->dev.of_node, 0); + if (pdev->dev.of_node) { + dev->regs = of_iomap(pdev->dev.of_node, 0); + if (!dev->regs) { + dev_err(&pdev->dev, "No SMI register address given in DT\n"); + ret = -ENODEV; + goto out_free; + } + + dev->err_interrupt = irq_of_parse_and_map(pdev->dev.of_node, 0); + } else { + r = platform_get_resource(pdev, IORESOURCE_MEM, 0); + + dev->regs = ioremap(r->start, resource_size(r)); + if (!dev->regs) { + dev_err(&pdev->dev, "No SMI register address given\n"); + ret = -ENODEV; + goto out_free; + } + + dev->err_interrupt = platform_get_irq(pdev, 0); + } + if (dev->err_interrupt != NO_IRQ) { ret = devm_request_irq(&pdev->dev, dev->err_interrupt, orion_mdio_err_irq, @@ -242,18 +256,24 @@ static int orion_mdio_probe(struct platform_device *pdev) mutex_init(&dev->lock); - ret = of_mdiobus_register(bus, np); + if (np) + ret = of_mdiobus_register(bus, np); + else + ret = mdiobus_register(bus); if (ret < 0) { dev_err(&pdev->dev, "Cannot register MDIO bus (%d)\n", ret); iounmap(dev->regs); - kfree(bus->irq); - mdiobus_free(bus); - return ret; + goto out_free; } platform_set_drvdata(pdev, bus); return 0; + +out_free: + kfree(bus->irq); + mdiobus_free(bus); + return ret; } static int orion_mdio_remove(struct platform_device *pdev)