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