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>

authored by Shawn Guo and committed by David S. Miller 43af940c b835c0f4

+7 -4
+7 -4
drivers/net/ethernet/freescale/fec.c
··· 232 232 struct platform_device *pdev; 233 233 234 234 int opened; 235 + int dev_id; 235 236 236 237 /* Phylib and MDIO interface */ 237 238 struct mii_bus *mii_bus; ··· 838 837 839 838 /* Adjust MAC if using macaddr */ 840 839 if (iap == macaddr) 841 - ndev->dev_addr[ETH_ALEN-1] = macaddr[ETH_ALEN-1] + fep->pdev->id; 840 + ndev->dev_addr[ETH_ALEN-1] = macaddr[ETH_ALEN-1] + fep->dev_id; 842 841 } 843 842 844 843 /* ------------------------------------------------------------------------- */ ··· 954 953 char mdio_bus_id[MII_BUS_ID_SIZE]; 955 954 char phy_name[MII_BUS_ID_SIZE + 3]; 956 955 int phy_id; 957 - int dev_id = fep->pdev->id; 956 + int dev_id = fep->dev_id; 958 957 959 958 fep->phy_dev = NULL; 960 959 ··· 1032 1031 * mdio interface in board design, and need to be configured by 1033 1032 * fec0 mii_bus. 1034 1033 */ 1035 - if ((id_entry->driver_data & FEC_QUIRK_ENET_MAC) && pdev->id > 0) { 1034 + if ((id_entry->driver_data & FEC_QUIRK_ENET_MAC) && fep->dev_id > 0) { 1036 1035 /* fec1 uses fec0 mii_bus */ 1037 1036 fep->mii_bus = fec0_mii_bus; 1038 1037 return 0; ··· 1064 1063 fep->mii_bus->read = fec_enet_mdio_read; 1065 1064 fep->mii_bus->write = fec_enet_mdio_write; 1066 1065 fep->mii_bus->reset = fec_enet_mdio_reset; 1067 - snprintf(fep->mii_bus->id, MII_BUS_ID_SIZE, "%x", pdev->id + 1); 1066 + snprintf(fep->mii_bus->id, MII_BUS_ID_SIZE, "%x", fep->dev_id + 1); 1068 1067 fep->mii_bus->priv = fep; 1069 1068 fep->mii_bus->parent = &pdev->dev; 1070 1069 ··· 1522 1521 int i, irq, ret = 0; 1523 1522 struct resource *r; 1524 1523 const struct of_device_id *of_id; 1524 + static int dev_id; 1525 1525 1526 1526 of_id = of_match_device(fec_dt_ids, &pdev->dev); 1527 1527 if (of_id) ··· 1550 1548 1551 1549 fep->hwp = ioremap(r->start, resource_size(r)); 1552 1550 fep->pdev = pdev; 1551 + fep->dev_id = dev_id++; 1553 1552 1554 1553 if (!fep->hwp) { 1555 1554 ret = -ENOMEM;