[kernel] generic-2.6/2.6.28: rename spi-gpio patch
[openwrt/svn-archive/archive.git] / target / linux / ar71xx / patches-2.6.28 / 802-ag71xx_mdio_dynamic_mdio_bus.patch
1 --- a/drivers/net/ag71xx/ag71xx_mdio.c
2 +++ b/drivers/net/ag71xx/ag71xx_mdio.c
3 @@ -32,12 +32,12 @@ static inline u32 ag71xx_mdio_rr(struct
4 static void ag71xx_mdio_dump_regs(struct ag71xx_mdio *am)
5 {
6 DBG("%s: mii_cfg=%08x, mii_cmd=%08x, mii_addr=%08x\n",
7 - am->mii_bus.name,
8 + am->mii_bus->name,
9 ag71xx_mdio_rr(am, AG71XX_REG_MII_CFG),
10 ag71xx_mdio_rr(am, AG71XX_REG_MII_CMD),
11 ag71xx_mdio_rr(am, AG71XX_REG_MII_ADDR));
12 DBG("%s: mii_ctrl=%08x, mii_status=%08x, mii_ind=%08x\n",
13 - am->mii_bus.name,
14 + am->mii_bus->name,
15 ag71xx_mdio_rr(am, AG71XX_REG_MII_CTRL),
16 ag71xx_mdio_rr(am, AG71XX_REG_MII_STATUS),
17 ag71xx_mdio_rr(am, AG71XX_REG_MII_IND));
18 @@ -57,7 +57,7 @@ static int ag71xx_mdio_mii_read(struct a
19 while (ag71xx_mdio_rr(am, AG71XX_REG_MII_IND) & MII_IND_BUSY) {
20 if (i-- == 0) {
21 printk(KERN_ERR "%s: mii_read timed out\n",
22 - am->mii_bus.name);
23 + am->mii_bus->name);
24 ret = 0xffff;
25 goto out;
26 }
27 @@ -88,7 +88,7 @@ static void ag71xx_mdio_mii_write(struct
28 while (ag71xx_mdio_rr(am, AG71XX_REG_MII_IND) & MII_IND_BUSY) {
29 if (i-- == 0) {
30 printk(KERN_ERR "%s: mii_write timed out\n",
31 - am->mii_bus.name);
32 + am->mii_bus->name);
33 break;
34 }
35 udelay(AG71XX_MDIO_DELAY);
36 @@ -154,23 +154,27 @@ static int __init ag71xx_mdio_probe(stru
37 goto err_free_mdio;
38 }
39
40 - am->mii_bus.name = "ag71xx_mdio";
41 - am->mii_bus.read = ag71xx_mdio_read;
42 - am->mii_bus.write = ag71xx_mdio_write;
43 - am->mii_bus.reset = ag71xx_mdio_reset;
44 - am->mii_bus.irq = am->mii_irq;
45 - am->mii_bus.priv = am;
46 - am->mii_bus.parent = &pdev->dev;
47 - snprintf(am->mii_bus.id, MII_BUS_ID_SIZE, "%x", 0);
48 + am->mii_bus = mdiobus_alloc();
49 + if (am->mii_bus == NULL)
50 + goto err_iounmap;
51 +
52 + am->mii_bus->name = "ag71xx_mdio";
53 + am->mii_bus->read = ag71xx_mdio_read;
54 + am->mii_bus->write = ag71xx_mdio_write;
55 + am->mii_bus->reset = ag71xx_mdio_reset;
56 + am->mii_bus->irq = am->mii_irq;
57 + am->mii_bus->priv = am;
58 + am->mii_bus->parent = &pdev->dev;
59 + snprintf(am->mii_bus->id, MII_BUS_ID_SIZE, "%x", 0);
60
61 pdata = pdev->dev.platform_data;
62 if (pdata)
63 - am->mii_bus.phy_mask = pdata->phy_mask;
64 + am->mii_bus->phy_mask = pdata->phy_mask;
65
66 for (i = 0; i < PHY_MAX_ADDR; i++)
67 am->mii_irq[i] = PHY_POLL;
68
69 - err = mdiobus_register(&am->mii_bus);
70 + err = mdiobus_register(am->mii_bus);
71 if (err)
72 goto err_iounmap;
73
74 @@ -194,7 +198,8 @@ static int __exit ag71xx_mdio_remove(str
75
76 if (am) {
77 ag71xx_mdio_bus = NULL;
78 - mdiobus_unregister(&am->mii_bus);
79 + mdiobus_unregister(am->mii_bus);
80 + mdiobus_free(am->mii_bus);
81 iounmap(am->mdio_base);
82 kfree(am);
83 platform_set_drvdata(pdev, NULL);
84 --- a/drivers/net/ag71xx/ag71xx.h
85 +++ b/drivers/net/ag71xx/ag71xx.h
86 @@ -102,7 +102,7 @@ struct ag71xx_ring {
87 };
88
89 struct ag71xx_mdio {
90 - struct mii_bus mii_bus;
91 + struct mii_bus *mii_bus;
92 int mii_irq[PHY_MAX_ADDR];
93 void __iomem *mdio_base;
94 };
95 --- a/drivers/net/ag71xx/ag71xx_main.c
96 +++ b/drivers/net/ag71xx/ag71xx_main.c
97 @@ -797,7 +797,7 @@ static int __init ag71xx_probe(struct pl
98 ag = netdev_priv(dev);
99 ag->pdev = pdev;
100 ag->dev = dev;
101 - ag->mii_bus = &ag71xx_mdio_bus->mii_bus;
102 + ag->mii_bus = ag71xx_mdio_bus->mii_bus;
103 ag->msg_enable = netif_msg_init(ag71xx_debug,
104 AG71XX_DEFAULT_MSG_ENABLE);
105 spin_lock_init(&ag->lock);