aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net
diff options
context:
space:
mode:
authorShawn Guo <shawn.guo@linaro.org>2011-12-05 00:01:15 -0500
committerDavid S. Miller <davem@davemloft.net>2011-12-07 13:29:04 -0500
commit43af940c54d712ab5e6d6798a82498b25c2af299 (patch)
treea19f037882fe96e789d3ddfa6e7c8beb8b70dc4d /drivers/net
parentb835c0f47f725d864bf2545f10c733b754bb6d51 (diff)
net/fec: fix the use of pdev->id
The pdev->id is used in several places for different purpose. All these uses assume it's always the id of fec device which is >= 0. However this is only true for non-DT case. When DT plays, pdev->id is always -1, which will break these pdev->id users. Instead of fixing all these users one by one, this patch introduces a new member 'dev_id' to 'struct fec_enet_private' for holding the correct fec device id, and replaces all the existing uses of pdev->id with this dev_id. Signed-off-by: Shawn Guo <shawn.guo@linaro.org> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers/net')
-rw-r--r--drivers/net/ethernet/freescale/fec.c11
1 files changed, 7 insertions, 4 deletions
diff --git a/drivers/net/ethernet/freescale/fec.c b/drivers/net/ethernet/freescale/fec.c
index 1124ce0a159..c136230d50b 100644
--- a/drivers/net/ethernet/freescale/fec.c
+++ b/drivers/net/ethernet/freescale/fec.c
@@ -232,6 +232,7 @@ struct fec_enet_private {
232 struct platform_device *pdev; 232 struct platform_device *pdev;
233 233
234 int opened; 234 int opened;
235 int dev_id;
235 236
236 /* Phylib and MDIO interface */ 237 /* Phylib and MDIO interface */
237 struct mii_bus *mii_bus; 238 struct mii_bus *mii_bus;
@@ -837,7 +838,7 @@ static void __inline__ fec_get_mac(struct net_device *ndev)
837 838
838 /* Adjust MAC if using macaddr */ 839 /* Adjust MAC if using macaddr */
839 if (iap == macaddr) 840 if (iap == macaddr)
840 ndev->dev_addr[ETH_ALEN-1] = macaddr[ETH_ALEN-1] + fep->pdev->id; 841 ndev->dev_addr[ETH_ALEN-1] = macaddr[ETH_ALEN-1] + fep->dev_id;
841} 842}
842 843
843/* ------------------------------------------------------------------------- */ 844/* ------------------------------------------------------------------------- */
@@ -953,7 +954,7 @@ static int fec_enet_mii_probe(struct net_device *ndev)
953 char mdio_bus_id[MII_BUS_ID_SIZE]; 954 char mdio_bus_id[MII_BUS_ID_SIZE];
954 char phy_name[MII_BUS_ID_SIZE + 3]; 955 char phy_name[MII_BUS_ID_SIZE + 3];
955 int phy_id; 956 int phy_id;
956 int dev_id = fep->pdev->id; 957 int dev_id = fep->dev_id;
957 958
958 fep->phy_dev = NULL; 959 fep->phy_dev = NULL;
959 960
@@ -1031,7 +1032,7 @@ static int fec_enet_mii_init(struct platform_device *pdev)
1031 * mdio interface in board design, and need to be configured by 1032 * mdio interface in board design, and need to be configured by
1032 * fec0 mii_bus. 1033 * fec0 mii_bus.
1033 */ 1034 */
1034 if ((id_entry->driver_data & FEC_QUIRK_ENET_MAC) && pdev->id > 0) { 1035 if ((id_entry->driver_data & FEC_QUIRK_ENET_MAC) && fep->dev_id > 0) {
1035 /* fec1 uses fec0 mii_bus */ 1036 /* fec1 uses fec0 mii_bus */
1036 fep->mii_bus = fec0_mii_bus; 1037 fep->mii_bus = fec0_mii_bus;
1037 return 0; 1038 return 0;
@@ -1063,7 +1064,7 @@ static int fec_enet_mii_init(struct platform_device *pdev)
1063 fep->mii_bus->read = fec_enet_mdio_read; 1064 fep->mii_bus->read = fec_enet_mdio_read;
1064 fep->mii_bus->write = fec_enet_mdio_write; 1065 fep->mii_bus->write = fec_enet_mdio_write;
1065 fep->mii_bus->reset = fec_enet_mdio_reset; 1066 fep->mii_bus->reset = fec_enet_mdio_reset;
1066 snprintf(fep->mii_bus->id, MII_BUS_ID_SIZE, "%x", pdev->id + 1); 1067 snprintf(fep->mii_bus->id, MII_BUS_ID_SIZE, "%x", fep->dev_id + 1);
1067 fep->mii_bus->priv = fep; 1068 fep->mii_bus->priv = fep;
1068 fep->mii_bus->parent = &pdev->dev; 1069 fep->mii_bus->parent = &pdev->dev;
1069 1070
@@ -1521,6 +1522,7 @@ fec_probe(struct platform_device *pdev)
1521 int i, irq, ret = 0; 1522 int i, irq, ret = 0;
1522 struct resource *r; 1523 struct resource *r;
1523 const struct of_device_id *of_id; 1524 const struct of_device_id *of_id;
1525 static int dev_id;
1524 1526
1525 of_id = of_match_device(fec_dt_ids, &pdev->dev); 1527 of_id = of_match_device(fec_dt_ids, &pdev->dev);
1526 if (of_id) 1528 if (of_id)
@@ -1548,6 +1550,7 @@ fec_probe(struct platform_device *pdev)
1548 1550
1549 fep->hwp = ioremap(r->start, resource_size(r)); 1551 fep->hwp = ioremap(r->start, resource_size(r));
1550 fep->pdev = pdev; 1552 fep->pdev = pdev;
1553 fep->dev_id = dev_id++;
1551 1554
1552 if (!fep->hwp) { 1555 if (!fep->hwp) {
1553 ret = -ENOMEM; 1556 ret = -ENOMEM;