Commit 703cebab authored by Divy Le Ray's avatar Divy Le Ray Committed by David S. Miller

cxgb: set phy's mdio dev before the phy init sequence

mdio's dev field needs to be set before mdio ops occur.
Signed-off-by: default avatarDivy Le Ray <divy@chelsio.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 86c890ab
...@@ -137,10 +137,11 @@ static inline int simple_mdio_write(struct cphy *cphy, int reg, ...@@ -137,10 +137,11 @@ static inline int simple_mdio_write(struct cphy *cphy, int reg,
} }
/* Convenience initializer */ /* Convenience initializer */
static inline void cphy_init(struct cphy *phy, adapter_t *adapter, static inline void cphy_init(struct cphy *phy, struct net_device *dev,
int phy_addr, struct cphy_ops *phy_ops, int phy_addr, struct cphy_ops *phy_ops,
const struct mdio_ops *mdio_ops) const struct mdio_ops *mdio_ops)
{ {
struct adapter *adapter = netdev_priv(dev);
phy->adapter = adapter; phy->adapter = adapter;
phy->ops = phy_ops; phy->ops = phy_ops;
if (mdio_ops) { if (mdio_ops) {
...@@ -150,12 +151,13 @@ static inline void cphy_init(struct cphy *phy, adapter_t *adapter, ...@@ -150,12 +151,13 @@ static inline void cphy_init(struct cphy *phy, adapter_t *adapter,
phy->mdio.mdio_read = mdio_ops->read; phy->mdio.mdio_read = mdio_ops->read;
phy->mdio.mdio_write = mdio_ops->write; phy->mdio.mdio_write = mdio_ops->write;
} }
phy->mdio.dev = dev;
} }
/* Operations of the PHY-instance factory */ /* Operations of the PHY-instance factory */
struct gphy { struct gphy {
/* Construct a PHY instance with the given PHY address */ /* Construct a PHY instance with the given PHY address */
struct cphy *(*create)(adapter_t *adapter, int phy_addr, struct cphy *(*create)(struct net_device *dev, int phy_addr,
const struct mdio_ops *mdio_ops); const struct mdio_ops *mdio_ops);
/* /*
......
...@@ -353,15 +353,16 @@ static struct cphy_ops mv88e1xxx_ops = { ...@@ -353,15 +353,16 @@ static struct cphy_ops mv88e1xxx_ops = {
.get_link_status = mv88e1xxx_get_link_status, .get_link_status = mv88e1xxx_get_link_status,
}; };
static struct cphy *mv88e1xxx_phy_create(adapter_t *adapter, int phy_addr, static struct cphy *mv88e1xxx_phy_create(struct net_device *dev, int phy_addr,
const struct mdio_ops *mdio_ops) const struct mdio_ops *mdio_ops)
{ {
struct adapter *adapter = netdev_priv(dev);
struct cphy *cphy = kzalloc(sizeof(*cphy), GFP_KERNEL); struct cphy *cphy = kzalloc(sizeof(*cphy), GFP_KERNEL);
if (!cphy) if (!cphy)
return NULL; return NULL;
cphy_init(cphy, adapter, phy_addr, &mv88e1xxx_ops, mdio_ops); cphy_init(cphy, dev, phy_addr, &mv88e1xxx_ops, mdio_ops);
/* Configure particular PHY's to run in a different mode. */ /* Configure particular PHY's to run in a different mode. */
if ((board_info(adapter)->caps & SUPPORTED_TP) && if ((board_info(adapter)->caps & SUPPORTED_TP) &&
......
...@@ -209,7 +209,7 @@ static struct cphy_ops mv88x201x_ops = { ...@@ -209,7 +209,7 @@ static struct cphy_ops mv88x201x_ops = {
MDIO_DEVS_PHYXS | MDIO_DEVS_WIS), MDIO_DEVS_PHYXS | MDIO_DEVS_WIS),
}; };
static struct cphy *mv88x201x_phy_create(adapter_t *adapter, int phy_addr, static struct cphy *mv88x201x_phy_create(struct net_device *dev, int phy_addr,
const struct mdio_ops *mdio_ops) const struct mdio_ops *mdio_ops)
{ {
u32 val; u32 val;
...@@ -218,7 +218,7 @@ static struct cphy *mv88x201x_phy_create(adapter_t *adapter, int phy_addr, ...@@ -218,7 +218,7 @@ static struct cphy *mv88x201x_phy_create(adapter_t *adapter, int phy_addr,
if (!cphy) if (!cphy)
return NULL; return NULL;
cphy_init(cphy, adapter, phy_addr, &mv88x201x_ops, mdio_ops); cphy_init(cphy, dev, phy_addr, &mv88x201x_ops, mdio_ops);
/* Commands the PHY to enable XFP's clock. */ /* Commands the PHY to enable XFP's clock. */
cphy_mdio_read(cphy, MDIO_MMD_PCS, 0x8300, &val); cphy_mdio_read(cphy, MDIO_MMD_PCS, 0x8300, &val);
......
...@@ -167,7 +167,7 @@ static struct cphy_ops my3126_ops = { ...@@ -167,7 +167,7 @@ static struct cphy_ops my3126_ops = {
MDIO_DEVS_PHYXS), MDIO_DEVS_PHYXS),
}; };
static struct cphy *my3126_phy_create(adapter_t *adapter, static struct cphy *my3126_phy_create(struct net_device *dev,
int phy_addr, const struct mdio_ops *mdio_ops) int phy_addr, const struct mdio_ops *mdio_ops)
{ {
struct cphy *cphy = kzalloc(sizeof (*cphy), GFP_KERNEL); struct cphy *cphy = kzalloc(sizeof (*cphy), GFP_KERNEL);
...@@ -175,7 +175,7 @@ static struct cphy *my3126_phy_create(adapter_t *adapter, ...@@ -175,7 +175,7 @@ static struct cphy *my3126_phy_create(adapter_t *adapter,
if (!cphy) if (!cphy)
return NULL; return NULL;
cphy_init(cphy, adapter, phy_addr, &my3126_ops, mdio_ops); cphy_init(cphy, dev, phy_addr, &my3126_ops, mdio_ops);
INIT_DELAYED_WORK(&cphy->phy_update, my3216_poll); INIT_DELAYED_WORK(&cphy->phy_update, my3216_poll);
cphy->bmsr = 0; cphy->bmsr = 0;
......
...@@ -1135,14 +1135,13 @@ int __devinit t1_init_sw_modules(adapter_t *adapter, ...@@ -1135,14 +1135,13 @@ int __devinit t1_init_sw_modules(adapter_t *adapter,
struct cmac *mac; struct cmac *mac;
int phy_addr = bi->mdio_phybaseaddr + i; int phy_addr = bi->mdio_phybaseaddr + i;
adapter->port[i].phy = bi->gphy->create(adapter, phy_addr, adapter->port[i].phy = bi->gphy->create(adapter->port[i].dev,
bi->mdio_ops); phy_addr, bi->mdio_ops);
if (!adapter->port[i].phy) { if (!adapter->port[i].phy) {
CH_ERR("%s: PHY %d initialization failed\n", CH_ERR("%s: PHY %d initialization failed\n",
adapter->name, i); adapter->name, i);
goto error; goto error;
} }
adapter->port[i].phy->mdio.dev = adapter->port[i].dev;
adapter->port[i].mac = mac = bi->gmac->create(adapter, i); adapter->port[i].mac = mac = bi->gmac->create(adapter, i);
if (!mac) { if (!mac) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment