aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/ethernet/marvell/mvmdio.c
diff options
context:
space:
mode:
authorFlorian Fainelli <florian@openwrt.org>2013-03-21 23:39:25 -0400
committerDavid S. Miller <davem@davemloft.net>2013-03-22 10:25:15 -0400
commit7111b717a0e1c3edf492ffad34f030e323ca371c (patch)
treed4571c4baa05a45506d135108e8a793bdda82fe2 /drivers/net/ethernet/marvell/mvmdio.c
parent43d6869037d6fa8f92a7a7e6df3b48147c8a3ef9 (diff)
net: mvmdio: allow platform device style registration
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 <florian@openwrt.org> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers/net/ethernet/marvell/mvmdio.c')
-rw-r--r--drivers/net/ethernet/marvell/mvmdio.c22
1 files changed, 15 insertions, 7 deletions
diff --git a/drivers/net/ethernet/marvell/mvmdio.c b/drivers/net/ethernet/marvell/mvmdio.c
index 77b7c80262f4..bbc5fdedd13b 100644
--- a/drivers/net/ethernet/marvell/mvmdio.c
+++ b/drivers/net/ethernet/marvell/mvmdio.c
@@ -24,10 +24,10 @@
24#include <linux/module.h> 24#include <linux/module.h>
25#include <linux/mutex.h> 25#include <linux/mutex.h>
26#include <linux/phy.h> 26#include <linux/phy.h>
27#include <linux/of_address.h>
28#include <linux/of_mdio.h>
29#include <linux/platform_device.h> 27#include <linux/platform_device.h>
30#include <linux/delay.h> 28#include <linux/delay.h>
29#include <linux/io.h>
30#include <linux/of_mdio.h>
31 31
32#define MVMDIO_SMI_DATA_SHIFT 0 32#define MVMDIO_SMI_DATA_SHIFT 0
33#define MVMDIO_SMI_PHY_ADDR_SHIFT 16 33#define MVMDIO_SMI_PHY_ADDR_SHIFT 16
@@ -143,11 +143,17 @@ static int orion_mdio_reset(struct mii_bus *bus)
143 143
144static int orion_mdio_probe(struct platform_device *pdev) 144static int orion_mdio_probe(struct platform_device *pdev)
145{ 145{
146 struct device_node *np = pdev->dev.of_node; 146 struct resource *r;
147 struct mii_bus *bus; 147 struct mii_bus *bus;
148 struct orion_mdio_dev *dev; 148 struct orion_mdio_dev *dev;
149 int i, ret; 149 int i, ret;
150 150
151 r = platform_get_resource(pdev, IORESOURCE_MEM, 0);
152 if (!r) {
153 dev_err(&pdev->dev, "No SMI register address given\n");
154 return -ENODEV;
155 }
156
151 bus = mdiobus_alloc_size(sizeof(struct orion_mdio_dev)); 157 bus = mdiobus_alloc_size(sizeof(struct orion_mdio_dev));
152 if (!bus) { 158 if (!bus) {
153 dev_err(&pdev->dev, "Cannot allocate MDIO bus\n"); 159 dev_err(&pdev->dev, "Cannot allocate MDIO bus\n");
@@ -172,9 +178,9 @@ static int orion_mdio_probe(struct platform_device *pdev)
172 bus->irq[i] = PHY_POLL; 178 bus->irq[i] = PHY_POLL;
173 179
174 dev = bus->priv; 180 dev = bus->priv;
175 dev->smireg = of_iomap(pdev->dev.of_node, 0); 181 dev->smireg = devm_ioremap(&pdev->dev, r->start, resource_size(r));
176 if (!dev->smireg) { 182 if (!dev->smireg) {
177 dev_err(&pdev->dev, "No SMI register address given in DT\n"); 183 dev_err(&pdev->dev, "Unable to remap SMI register\n");
178 kfree(bus->irq); 184 kfree(bus->irq);
179 mdiobus_free(bus); 185 mdiobus_free(bus);
180 return -ENODEV; 186 return -ENODEV;
@@ -182,10 +188,12 @@ static int orion_mdio_probe(struct platform_device *pdev)
182 188
183 mutex_init(&dev->lock); 189 mutex_init(&dev->lock);
184 190
185 ret = of_mdiobus_register(bus, np); 191 if (pdev->dev.of_node)
192 ret = of_mdiobus_register(bus, pdev->dev.of_node);
193 else
194 ret = mdiobus_register(bus);
186 if (ret < 0) { 195 if (ret < 0) {
187 dev_err(&pdev->dev, "Cannot register MDIO bus (%d)\n", ret); 196 dev_err(&pdev->dev, "Cannot register MDIO bus (%d)\n", ret);
188 iounmap(dev->smireg);
189 kfree(bus->irq); 197 kfree(bus->irq);
190 mdiobus_free(bus); 198 mdiobus_free(bus);
191 return ret; 199 return ret;