Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

net: ethernet: smsc: smsc911x: use phydev from struct net_device

The private structure contain a pointer to phydev, but the structure
net_device already contain such pointer. So we can remove the pointer
phy in the private structure, and update the driver to use the
one contained in struct net_device.

Signed-off-by: Philippe Reynes <tremyfr@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>

authored by

Philippe Reynes and committed by
David S. Miller
f788e322 5376d95f

+31 -35
+31 -35
drivers/net/ethernet/smsc/smsc911x.c
··· 114 114 /* spinlock to ensure register accesses are serialised */ 115 115 spinlock_t dev_lock; 116 116 117 - struct phy_device *phy_dev; 118 117 struct mii_bus *mii_bus; 119 118 unsigned int using_extphy; 120 119 int last_duplex; ··· 832 833 static int smsc911x_phy_loopbacktest(struct net_device *dev) 833 834 { 834 835 struct smsc911x_data *pdata = netdev_priv(dev); 835 - struct phy_device *phy_dev = pdata->phy_dev; 836 + struct phy_device *phy_dev = dev->phydev; 836 837 int result = -EIO; 837 838 unsigned int i, val; 838 839 unsigned long flags; ··· 902 903 903 904 static void smsc911x_phy_update_flowcontrol(struct smsc911x_data *pdata) 904 905 { 905 - struct phy_device *phy_dev = pdata->phy_dev; 906 + struct net_device *ndev = pdata->dev; 907 + struct phy_device *phy_dev = ndev->phydev; 906 908 u32 afc = smsc911x_reg_read(pdata, AFC_CFG); 907 909 u32 flow; 908 910 unsigned long flags; ··· 944 944 static void smsc911x_phy_adjust_link(struct net_device *dev) 945 945 { 946 946 struct smsc911x_data *pdata = netdev_priv(dev); 947 - struct phy_device *phy_dev = pdata->phy_dev; 947 + struct phy_device *phy_dev = dev->phydev; 948 948 unsigned long flags; 949 949 int carrier; 950 950 ··· 1037 1037 SUPPORTED_Asym_Pause); 1038 1038 phydev->advertising = phydev->supported; 1039 1039 1040 - pdata->phy_dev = phydev; 1041 1040 pdata->last_duplex = -1; 1042 1041 pdata->last_carrier = -1; 1043 1042 ··· 1337 1338 1338 1339 static int smsc911x_phy_general_power_up(struct smsc911x_data *pdata) 1339 1340 { 1341 + struct net_device *ndev = pdata->dev; 1342 + struct phy_device *phy_dev = ndev->phydev; 1340 1343 int rc = 0; 1341 1344 1342 - if (!pdata->phy_dev) 1345 + if (!phy_dev) 1343 1346 return rc; 1344 1347 1345 1348 /* If the internal PHY is in General Power-Down mode, all, except the ··· 1351 1350 * In that case, clear the bit 0.11, so the PHY powers up and we can 1352 1351 * access to the phy registers. 1353 1352 */ 1354 - rc = phy_read(pdata->phy_dev, MII_BMCR); 1353 + rc = phy_read(phy_dev, MII_BMCR); 1355 1354 if (rc < 0) { 1356 1355 SMSC_WARN(pdata, drv, "Failed reading PHY control reg"); 1357 1356 return rc; ··· 1361 1360 * disable the general power down-mode. 1362 1361 */ 1363 1362 if (rc & BMCR_PDOWN) { 1364 - rc = phy_write(pdata->phy_dev, MII_BMCR, rc & ~BMCR_PDOWN); 1363 + rc = phy_write(phy_dev, MII_BMCR, rc & ~BMCR_PDOWN); 1365 1364 if (rc < 0) { 1366 1365 SMSC_WARN(pdata, drv, "Failed writing PHY control reg"); 1367 1366 return rc; ··· 1375 1374 1376 1375 static int smsc911x_phy_disable_energy_detect(struct smsc911x_data *pdata) 1377 1376 { 1377 + struct net_device *ndev = pdata->dev; 1378 + struct phy_device *phy_dev = ndev->phydev; 1378 1379 int rc = 0; 1379 1380 1380 - if (!pdata->phy_dev) 1381 + if (!phy_dev) 1381 1382 return rc; 1382 1383 1383 - rc = phy_read(pdata->phy_dev, MII_LAN83C185_CTRL_STATUS); 1384 + rc = phy_read(phy_dev, MII_LAN83C185_CTRL_STATUS); 1384 1385 1385 1386 if (rc < 0) { 1386 1387 SMSC_WARN(pdata, drv, "Failed reading PHY control reg"); ··· 1392 1389 /* Only disable if energy detect mode is already enabled */ 1393 1390 if (rc & MII_LAN83C185_EDPWRDOWN) { 1394 1391 /* Disable energy detect mode for this SMSC Transceivers */ 1395 - rc = phy_write(pdata->phy_dev, MII_LAN83C185_CTRL_STATUS, 1392 + rc = phy_write(phy_dev, MII_LAN83C185_CTRL_STATUS, 1396 1393 rc & (~MII_LAN83C185_EDPWRDOWN)); 1397 1394 1398 1395 if (rc < 0) { ··· 1408 1405 1409 1406 static int smsc911x_phy_enable_energy_detect(struct smsc911x_data *pdata) 1410 1407 { 1408 + struct net_device *ndev = pdata->dev; 1409 + struct phy_device *phy_dev = ndev->phydev; 1411 1410 int rc = 0; 1412 1411 1413 - if (!pdata->phy_dev) 1412 + if (!phy_dev) 1414 1413 return rc; 1415 1414 1416 - rc = phy_read(pdata->phy_dev, MII_LAN83C185_CTRL_STATUS); 1415 + rc = phy_read(phy_dev, MII_LAN83C185_CTRL_STATUS); 1417 1416 1418 1417 if (rc < 0) { 1419 1418 SMSC_WARN(pdata, drv, "Failed reading PHY control reg"); ··· 1425 1420 /* Only enable if energy detect mode is already disabled */ 1426 1421 if (!(rc & MII_LAN83C185_EDPWRDOWN)) { 1427 1422 /* Enable energy detect mode for this SMSC Transceivers */ 1428 - rc = phy_write(pdata->phy_dev, MII_LAN83C185_CTRL_STATUS, 1423 + rc = phy_write(phy_dev, MII_LAN83C185_CTRL_STATUS, 1429 1424 rc | MII_LAN83C185_EDPWRDOWN); 1430 1425 1431 1426 if (rc < 0) { ··· 1522 1517 unsigned int intcfg; 1523 1518 1524 1519 /* if the phy is not yet registered, retry later*/ 1525 - if (!pdata->phy_dev) { 1520 + if (!dev->phydev) { 1526 1521 SMSC_WARN(pdata, hw, "phy_dev is NULL"); 1527 1522 return -EAGAIN; 1528 1523 } ··· 1613 1608 pdata->last_carrier = -1; 1614 1609 1615 1610 /* Bring the PHY up */ 1616 - phy_start(pdata->phy_dev); 1611 + phy_start(dev->phydev); 1617 1612 1618 1613 temp = smsc911x_reg_read(pdata, HW_CFG); 1619 1614 /* Preserve TX FIFO size and external PHY configuration */ ··· 1668 1663 smsc911x_tx_update_txcounters(dev); 1669 1664 1670 1665 /* Bring the PHY down */ 1671 - if (pdata->phy_dev) 1672 - phy_stop(pdata->phy_dev); 1666 + if (dev->phydev) 1667 + phy_stop(dev->phydev); 1673 1668 1674 1669 SMSC_TRACE(pdata, ifdown, "Interface stopped"); 1675 1670 return 0; ··· 1909 1904 /* Standard ioctls for mii-tool */ 1910 1905 static int smsc911x_do_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd) 1911 1906 { 1912 - struct smsc911x_data *pdata = netdev_priv(dev); 1913 - 1914 - if (!netif_running(dev) || !pdata->phy_dev) 1907 + if (!netif_running(dev) || !dev->phydev) 1915 1908 return -EINVAL; 1916 1909 1917 - return phy_mii_ioctl(pdata->phy_dev, ifr, cmd); 1910 + return phy_mii_ioctl(dev->phydev, ifr, cmd); 1918 1911 } 1919 1912 1920 1913 static int 1921 1914 smsc911x_ethtool_getsettings(struct net_device *dev, struct ethtool_cmd *cmd) 1922 1915 { 1923 - struct smsc911x_data *pdata = netdev_priv(dev); 1924 - 1925 1916 cmd->maxtxpkt = 1; 1926 1917 cmd->maxrxpkt = 1; 1927 - return phy_ethtool_gset(pdata->phy_dev, cmd); 1918 + return phy_ethtool_gset(dev->phydev, cmd); 1928 1919 } 1929 1920 1930 1921 static int 1931 1922 smsc911x_ethtool_setsettings(struct net_device *dev, struct ethtool_cmd *cmd) 1932 1923 { 1933 - struct smsc911x_data *pdata = netdev_priv(dev); 1934 - 1935 - return phy_ethtool_sset(pdata->phy_dev, cmd); 1924 + return phy_ethtool_sset(dev->phydev, cmd); 1936 1925 } 1937 1926 1938 1927 static void smsc911x_ethtool_getdrvinfo(struct net_device *dev, ··· 1940 1941 1941 1942 static int smsc911x_ethtool_nwayreset(struct net_device *dev) 1942 1943 { 1943 - struct smsc911x_data *pdata = netdev_priv(dev); 1944 - 1945 - return phy_start_aneg(pdata->phy_dev); 1944 + return phy_start_aneg(dev->phydev); 1946 1945 } 1947 1946 1948 1947 static u32 smsc911x_ethtool_getmsglevel(struct net_device *dev) ··· 1966 1969 void *buf) 1967 1970 { 1968 1971 struct smsc911x_data *pdata = netdev_priv(dev); 1969 - struct phy_device *phy_dev = pdata->phy_dev; 1972 + struct phy_device *phy_dev = dev->phydev; 1970 1973 unsigned long flags; 1971 1974 unsigned int i; 1972 1975 unsigned int j = 0; ··· 2305 2308 pdata = netdev_priv(dev); 2306 2309 BUG_ON(!pdata); 2307 2310 BUG_ON(!pdata->ioaddr); 2308 - BUG_ON(!pdata->phy_dev); 2311 + BUG_ON(!dev->phydev); 2309 2312 2310 2313 SMSC_TRACE(pdata, ifdown, "Stopping driver"); 2311 2314 2312 - phy_disconnect(pdata->phy_dev); 2313 - pdata->phy_dev = NULL; 2315 + phy_disconnect(dev->phydev); 2314 2316 mdiobus_unregister(pdata->mii_bus); 2315 2317 mdiobus_free(pdata->mii_bus); 2316 2318