1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
|
This patch reflects changes in mdiobus implementation in kernel 2.6.28.
--- a/drivers/net/ar2313/ar2313.c
+++ b/drivers/net/ar2313/ar2313.c
@@ -159,10 +159,10 @@ static void rx_tasklet_func(unsigned lon
static void rx_tasklet_cleanup(struct net_device *dev);
static void ar2313_multicast_list(struct net_device *dev);
-static int mdiobus_read(struct mii_bus *bus, int phy_addr, int regnum);
-static int mdiobus_write(struct mii_bus *bus, int phy_addr, int regnum, u16 value);
-static int mdiobus_reset(struct mii_bus *bus);
-static int mdiobus_probe (struct net_device *dev);
+static int ar2313_mdiobus_read(struct mii_bus *bus, int phy_addr, int regnum);
+static int ar2313_mdiobus_write(struct mii_bus *bus, int phy_addr, int regnum, u16 value);
+static int ar2313_mdiobus_reset(struct mii_bus *bus);
+static int ar2313_mdiobus_probe (struct net_device *dev);
static void ar2313_adjust_link(struct net_device *dev);
#ifndef ERR
@@ -286,18 +286,22 @@ int __init ar2313_probe(struct platform_
dev->dev_addr[0], dev->dev_addr[1], dev->dev_addr[2],
dev->dev_addr[3], dev->dev_addr[4], dev->dev_addr[5], dev->irq);
- sp->mii_bus.priv = dev;
- sp->mii_bus.read = mdiobus_read;
- sp->mii_bus.write = mdiobus_write;
- sp->mii_bus.reset = mdiobus_reset;
- sp->mii_bus.name = "ar2313_eth_mii";
- snprintf(sp->mii_bus.id, MII_BUS_ID_SIZE, "0");
- sp->mii_bus.irq = kmalloc(sizeof(int), GFP_KERNEL);
- *sp->mii_bus.irq = PHY_POLL;
+ sp->mii_bus = mdiobus_alloc();
+ if (sp->mii_bus == NULL)
+ return -1;
+
+ sp->mii_bus->priv = dev;
+ sp->mii_bus->read = ar2313_mdiobus_read;
+ sp->mii_bus->write = ar2313_mdiobus_write;
+ sp->mii_bus->reset = ar2313_mdiobus_reset;
+ sp->mii_bus->name = "ar2313_eth_mii";
+ snprintf(sp->mii_bus->id, MII_BUS_ID_SIZE, "0");
+ sp->mii_bus->irq = kmalloc(sizeof(int), GFP_KERNEL);
+ *sp->mii_bus->irq = PHY_POLL;
- mdiobus_register(&sp->mii_bus);
+ mdiobus_register(sp->mii_bus);
- if (mdiobus_probe(dev) != 0) {
+ if (ar2313_mdiobus_probe(dev) != 0) {
printk(KERN_ERR "ar2313: mdiobus_probe failed");
rx_tasklet_cleanup(dev);
ar2313_init_cleanup(dev);
@@ -432,9 +436,12 @@ static void rx_tasklet_cleanup(struct ne
static int __exit ar2313_remove(struct platform_device *pdev)
{
struct net_device *dev = platform_get_drvdata(pdev);
+ struct ar2313_private *sp = netdev_priv(dev);
rx_tasklet_cleanup(dev);
ar2313_init_cleanup(dev);
unregister_netdev(dev);
+ mdiobus_unregister(sp->mii_bus);
+ mdiobus_free(sp->mii_bus);
kfree(dev);
return 0;
}
@@ -619,7 +626,7 @@ static void ar2313_check_link(struct net
struct ar2313_private *sp = netdev_priv(dev);
u16 phyData;
- phyData = mdiobus_read(&sp->mii_bus, sp->phy, MII_BMSR);
+ phyData = ar2313_mdiobus_read(sp->mii_bus, sp->phy, MII_BMSR);
if (sp->phyData != phyData) {
if (phyData & BMSR_LSTATUS) {
/* link is present, ready link partner ability to deterine
@@ -628,10 +635,10 @@ static void ar2313_check_link(struct net
u16 reg;
sp->link = 1;
- reg = mdiobus_read(&sp->mii_bus, sp->phy, MII_BMCR);
+ reg = ar2313_mdiobus_read(sp->mii_bus, sp->phy, MII_BMCR);
if (reg & BMCR_ANENABLE) {
/* auto neg enabled */
- reg = mdiobus_read(&sp->mii_bus, sp->phy, MII_LPA);
+ reg = ar2313_mdiobus_read(sp->mii_bus, sp->phy, MII_LPA);
duplex = (reg & (LPA_100FULL | LPA_10FULL)) ? 1 : 0;
} else {
/* no auto neg, just read duplex config */
@@ -1320,7 +1327,7 @@ static void ar2313_adjust_link(struct ne
((reg << MII_ADDR_REG_SHIFT) | (phy << MII_ADDR_PHY_SHIFT))
static int
-mdiobus_read(struct mii_bus *bus, int phy_addr, int regnum)
+ar2313_mdiobus_read(struct mii_bus *bus, int phy_addr, int regnum)
{
struct net_device *const dev = bus->priv;
struct ar2313_private *sp = netdev_priv(dev);
@@ -1332,7 +1339,7 @@ mdiobus_read(struct mii_bus *bus, int ph
}
static int
-mdiobus_write(struct mii_bus *bus, int phy_addr, int regnum,
+ar2313_mdiobus_write(struct mii_bus *bus, int phy_addr, int regnum,
u16 value)
{
struct net_device *const dev = bus->priv;
@@ -1346,7 +1353,7 @@ mdiobus_write(struct mii_bus *bus, int p
return 0;
}
-static int mdiobus_reset(struct mii_bus *bus)
+static int ar2313_mdiobus_reset(struct mii_bus *bus)
{
struct net_device *const dev = bus->priv;
@@ -1355,7 +1362,7 @@ static int mdiobus_reset(struct mii_bus
return 0;
}
-static int mdiobus_probe (struct net_device *dev)
+static int ar2313_mdiobus_probe (struct net_device *dev)
{
struct ar2313_private *const sp = netdev_priv(dev);
struct phy_device *phydev = NULL;
@@ -1363,8 +1370,8 @@ static int mdiobus_probe (struct net_dev
/* find the first (lowest address) PHY on the current MAC's MII bus */
for (phy_addr = 0; phy_addr < PHY_MAX_ADDR; phy_addr++)
- if (sp->mii_bus.phy_map[phy_addr]) {
- phydev = sp->mii_bus.phy_map[phy_addr];
+ if (sp->mii_bus->phy_map[phy_addr]) {
+ phydev = sp->mii_bus->phy_map[phy_addr];
break; /* break out with first one found */
}
--- a/drivers/net/ar2313/ar2313.h
+++ b/drivers/net/ar2313/ar2313.h
@@ -162,7 +162,7 @@ struct ar2313_private {
int unloading;
struct phy_device *phy_dev;
- struct mii_bus mii_bus;
+ struct mii_bus *mii_bus;
int oldduplex;
};
|