net: Rework fs_enet driver to use of_mdio infrastructure
This patch simplifies the driver by making use of more common code. Signed-off-by: Grant Likely <grant.likely@secretlab.ca> Acked-by: Andy Fleming <afleming@freescale.com> Signed-off-by: David S. Miller <davem@davemloft.net>
This commit is contained in:

committed by
David S. Miller

parent
fd84f0ee50
commit
aa73832c5a
@@ -22,6 +22,7 @@
|
||||
#include <linux/mii.h>
|
||||
#include <linux/platform_device.h>
|
||||
#include <linux/mdio-bitbang.h>
|
||||
#include <linux/of_mdio.h>
|
||||
#include <linux/of_platform.h>
|
||||
|
||||
#include "fs_enet.h"
|
||||
@@ -149,31 +150,12 @@ static int __devinit fs_mii_bitbang_init(struct mii_bus *bus,
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void __devinit add_phy(struct mii_bus *bus, struct device_node *np)
|
||||
{
|
||||
const u32 *data;
|
||||
int len, id, irq;
|
||||
|
||||
data = of_get_property(np, "reg", &len);
|
||||
if (!data || len != 4)
|
||||
return;
|
||||
|
||||
id = *data;
|
||||
bus->phy_mask &= ~(1 << id);
|
||||
|
||||
irq = of_irq_to_resource(np, 0, NULL);
|
||||
if (irq != NO_IRQ)
|
||||
bus->irq[id] = irq;
|
||||
}
|
||||
|
||||
static int __devinit fs_enet_mdio_probe(struct of_device *ofdev,
|
||||
const struct of_device_id *match)
|
||||
{
|
||||
struct device_node *np = NULL;
|
||||
struct mii_bus *new_bus;
|
||||
struct bb_info *bitbang;
|
||||
int ret = -ENOMEM;
|
||||
int i;
|
||||
|
||||
bitbang = kzalloc(sizeof(struct bb_info), GFP_KERNEL);
|
||||
if (!bitbang)
|
||||
@@ -196,17 +178,10 @@ static int __devinit fs_enet_mdio_probe(struct of_device *ofdev,
|
||||
if (!new_bus->irq)
|
||||
goto out_unmap_regs;
|
||||
|
||||
for (i = 0; i < PHY_MAX_ADDR; i++)
|
||||
new_bus->irq[i] = -1;
|
||||
|
||||
while ((np = of_get_next_child(ofdev->node, np)))
|
||||
if (!strcmp(np->type, "ethernet-phy"))
|
||||
add_phy(new_bus, np);
|
||||
|
||||
new_bus->parent = &ofdev->dev;
|
||||
dev_set_drvdata(&ofdev->dev, new_bus);
|
||||
|
||||
ret = mdiobus_register(new_bus);
|
||||
ret = of_mdiobus_register(new_bus, ofdev->node);
|
||||
if (ret)
|
||||
goto out_free_irqs;
|
||||
|
||||
|
Reference in New Issue
Block a user