[ar71xx] switch to 2.6.28
[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,27 +154,33 @@ 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 + err = -ENOMEM;
51 + goto err_iounmap;
52 + }
53 +
54 + am->mii_bus->name = "ag71xx_mdio";
55 + am->mii_bus->read = ag71xx_mdio_read;
56 + am->mii_bus->write = ag71xx_mdio_write;
57 + am->mii_bus->reset = ag71xx_mdio_reset;
58 + am->mii_bus->irq = am->mii_irq;
59 + am->mii_bus->priv = am;
60 + am->mii_bus->parent = &pdev->dev;
61 + snprintf(am->mii_bus->id, MII_BUS_ID_SIZE, "%x", 0);
62
63 pdata = pdev->dev.platform_data;
64 if (pdata)
65 - am->mii_bus.phy_mask = pdata->phy_mask;
66 + am->mii_bus->phy_mask = pdata->phy_mask;
67
68 for (i = 0; i < PHY_MAX_ADDR; i++)
69 am->mii_irq[i] = PHY_POLL;
70
71 ag71xx_mdio_wr(am, AG71XX_REG_MAC_CFG1, 0);
72
73 - err = mdiobus_register(&am->mii_bus);
74 + err = mdiobus_register(am->mii_bus);
75 if (err)
76 - goto err_iounmap;
77 + goto err_free_bus;
78
79 ag71xx_mdio_dump_regs(am);
80
81 @@ -182,6 +188,8 @@ static int __init ag71xx_mdio_probe(stru
82 ag71xx_mdio_bus = am;
83 return 0;
84
85 + err_free_bus:
86 + mdiobus_free(am->mii_bus);
87 err_iounmap:
88 iounmap(am->mdio_base);
89 err_free_mdio:
90 @@ -196,7 +204,8 @@ static int __exit ag71xx_mdio_remove(str
91
92 if (am) {
93 ag71xx_mdio_bus = NULL;
94 - mdiobus_unregister(&am->mii_bus);
95 + mdiobus_unregister(am->mii_bus);
96 + mdiobus_free(am->mii_bus);
97 iounmap(am->mdio_base);
98 kfree(am);
99 platform_set_drvdata(pdev, NULL);
100 --- a/drivers/net/ag71xx/ag71xx.h
101 +++ b/drivers/net/ag71xx/ag71xx.h
102 @@ -102,7 +102,7 @@ struct ag71xx_ring {
103 };
104
105 struct ag71xx_mdio {
106 - struct mii_bus mii_bus;
107 + struct mii_bus *mii_bus;
108 int mii_irq[PHY_MAX_ADDR];
109 void __iomem *mdio_base;
110 };
111 --- a/drivers/net/ag71xx/ag71xx_main.c
112 +++ b/drivers/net/ag71xx/ag71xx_main.c
113 @@ -797,7 +797,7 @@ static int __init ag71xx_probe(struct pl
114 ag = netdev_priv(dev);
115 ag->pdev = pdev;
116 ag->dev = dev;
117 - ag->mii_bus = &ag71xx_mdio_bus->mii_bus;
118 + ag->mii_bus = ag71xx_mdio_bus->mii_bus;
119 ag->msg_enable = netif_msg_init(ag71xx_debug,
120 AG71XX_DEFAULT_MSG_ENABLE);
121 spin_lock_init(&ag->lock);