Skip to content

Commit f788e32

Browse files
Philippe Reynesdavem330
authored andcommitted
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 <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 5376d95 commit f788e32

File tree

1 file changed

+31
-35
lines changed

1 file changed

+31
-35
lines changed

drivers/net/ethernet/smsc/smsc911x.c

Lines changed: 31 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,6 @@ struct smsc911x_data {
114114
/* spinlock to ensure register accesses are serialised */
115115
spinlock_t dev_lock;
116116

117-
struct phy_device *phy_dev;
118117
struct mii_bus *mii_bus;
119118
unsigned int using_extphy;
120119
int last_duplex;
@@ -833,7 +832,7 @@ static int smsc911x_phy_reset(struct smsc911x_data *pdata)
833832
static int smsc911x_phy_loopbacktest(struct net_device *dev)
834833
{
835834
struct smsc911x_data *pdata = netdev_priv(dev);
836-
struct phy_device *phy_dev = pdata->phy_dev;
835+
struct phy_device *phy_dev = dev->phydev;
837836
int result = -EIO;
838837
unsigned int i, val;
839838
unsigned long flags;
@@ -903,7 +902,8 @@ static int smsc911x_phy_loopbacktest(struct net_device *dev)
903902

904903
static void smsc911x_phy_update_flowcontrol(struct smsc911x_data *pdata)
905904
{
906-
struct phy_device *phy_dev = pdata->phy_dev;
905+
struct net_device *ndev = pdata->dev;
906+
struct phy_device *phy_dev = ndev->phydev;
907907
u32 afc = smsc911x_reg_read(pdata, AFC_CFG);
908908
u32 flow;
909909
unsigned long flags;
@@ -944,7 +944,7 @@ static void smsc911x_phy_update_flowcontrol(struct smsc911x_data *pdata)
944944
static void smsc911x_phy_adjust_link(struct net_device *dev)
945945
{
946946
struct smsc911x_data *pdata = netdev_priv(dev);
947-
struct phy_device *phy_dev = pdata->phy_dev;
947+
struct phy_device *phy_dev = dev->phydev;
948948
unsigned long flags;
949949
int carrier;
950950

@@ -1037,7 +1037,6 @@ static int smsc911x_mii_probe(struct net_device *dev)
10371037
SUPPORTED_Asym_Pause);
10381038
phydev->advertising = phydev->supported;
10391039

1040-
pdata->phy_dev = phydev;
10411040
pdata->last_duplex = -1;
10421041
pdata->last_carrier = -1;
10431042

@@ -1338,9 +1337,11 @@ static void smsc911x_rx_multicast_update_workaround(struct smsc911x_data *pdata)
13381337

13391338
static int smsc911x_phy_general_power_up(struct smsc911x_data *pdata)
13401339
{
1340+
struct net_device *ndev = pdata->dev;
1341+
struct phy_device *phy_dev = ndev->phydev;
13411342
int rc = 0;
13421343

1343-
if (!pdata->phy_dev)
1344+
if (!phy_dev)
13441345
return rc;
13451346

13461347
/* If the internal PHY is in General Power-Down mode, all, except the
@@ -1350,7 +1351,7 @@ static int smsc911x_phy_general_power_up(struct smsc911x_data *pdata)
13501351
* In that case, clear the bit 0.11, so the PHY powers up and we can
13511352
* access to the phy registers.
13521353
*/
1353-
rc = phy_read(pdata->phy_dev, MII_BMCR);
1354+
rc = phy_read(phy_dev, MII_BMCR);
13541355
if (rc < 0) {
13551356
SMSC_WARN(pdata, drv, "Failed reading PHY control reg");
13561357
return rc;
@@ -1360,7 +1361,7 @@ static int smsc911x_phy_general_power_up(struct smsc911x_data *pdata)
13601361
* disable the general power down-mode.
13611362
*/
13621363
if (rc & BMCR_PDOWN) {
1363-
rc = phy_write(pdata->phy_dev, MII_BMCR, rc & ~BMCR_PDOWN);
1364+
rc = phy_write(phy_dev, MII_BMCR, rc & ~BMCR_PDOWN);
13641365
if (rc < 0) {
13651366
SMSC_WARN(pdata, drv, "Failed writing PHY control reg");
13661367
return rc;
@@ -1374,12 +1375,14 @@ static int smsc911x_phy_general_power_up(struct smsc911x_data *pdata)
13741375

13751376
static int smsc911x_phy_disable_energy_detect(struct smsc911x_data *pdata)
13761377
{
1378+
struct net_device *ndev = pdata->dev;
1379+
struct phy_device *phy_dev = ndev->phydev;
13771380
int rc = 0;
13781381

1379-
if (!pdata->phy_dev)
1382+
if (!phy_dev)
13801383
return rc;
13811384

1382-
rc = phy_read(pdata->phy_dev, MII_LAN83C185_CTRL_STATUS);
1385+
rc = phy_read(phy_dev, MII_LAN83C185_CTRL_STATUS);
13831386

13841387
if (rc < 0) {
13851388
SMSC_WARN(pdata, drv, "Failed reading PHY control reg");
@@ -1389,7 +1392,7 @@ static int smsc911x_phy_disable_energy_detect(struct smsc911x_data *pdata)
13891392
/* Only disable if energy detect mode is already enabled */
13901393
if (rc & MII_LAN83C185_EDPWRDOWN) {
13911394
/* Disable energy detect mode for this SMSC Transceivers */
1392-
rc = phy_write(pdata->phy_dev, MII_LAN83C185_CTRL_STATUS,
1395+
rc = phy_write(phy_dev, MII_LAN83C185_CTRL_STATUS,
13931396
rc & (~MII_LAN83C185_EDPWRDOWN));
13941397

13951398
if (rc < 0) {
@@ -1405,12 +1408,14 @@ static int smsc911x_phy_disable_energy_detect(struct smsc911x_data *pdata)
14051408

14061409
static int smsc911x_phy_enable_energy_detect(struct smsc911x_data *pdata)
14071410
{
1411+
struct net_device *ndev = pdata->dev;
1412+
struct phy_device *phy_dev = ndev->phydev;
14081413
int rc = 0;
14091414

1410-
if (!pdata->phy_dev)
1415+
if (!phy_dev)
14111416
return rc;
14121417

1413-
rc = phy_read(pdata->phy_dev, MII_LAN83C185_CTRL_STATUS);
1418+
rc = phy_read(phy_dev, MII_LAN83C185_CTRL_STATUS);
14141419

14151420
if (rc < 0) {
14161421
SMSC_WARN(pdata, drv, "Failed reading PHY control reg");
@@ -1420,7 +1425,7 @@ static int smsc911x_phy_enable_energy_detect(struct smsc911x_data *pdata)
14201425
/* Only enable if energy detect mode is already disabled */
14211426
if (!(rc & MII_LAN83C185_EDPWRDOWN)) {
14221427
/* Enable energy detect mode for this SMSC Transceivers */
1423-
rc = phy_write(pdata->phy_dev, MII_LAN83C185_CTRL_STATUS,
1428+
rc = phy_write(phy_dev, MII_LAN83C185_CTRL_STATUS,
14241429
rc | MII_LAN83C185_EDPWRDOWN);
14251430

14261431
if (rc < 0) {
@@ -1517,7 +1522,7 @@ static int smsc911x_open(struct net_device *dev)
15171522
unsigned int intcfg;
15181523

15191524
/* if the phy is not yet registered, retry later*/
1520-
if (!pdata->phy_dev) {
1525+
if (!dev->phydev) {
15211526
SMSC_WARN(pdata, hw, "phy_dev is NULL");
15221527
return -EAGAIN;
15231528
}
@@ -1608,7 +1613,7 @@ static int smsc911x_open(struct net_device *dev)
16081613
pdata->last_carrier = -1;
16091614

16101615
/* Bring the PHY up */
1611-
phy_start(pdata->phy_dev);
1616+
phy_start(dev->phydev);
16121617

16131618
temp = smsc911x_reg_read(pdata, HW_CFG);
16141619
/* Preserve TX FIFO size and external PHY configuration */
@@ -1663,8 +1668,8 @@ static int smsc911x_stop(struct net_device *dev)
16631668
smsc911x_tx_update_txcounters(dev);
16641669

16651670
/* Bring the PHY down */
1666-
if (pdata->phy_dev)
1667-
phy_stop(pdata->phy_dev);
1671+
if (dev->phydev)
1672+
phy_stop(dev->phydev);
16681673

16691674
SMSC_TRACE(pdata, ifdown, "Interface stopped");
16701675
return 0;
@@ -1904,30 +1909,24 @@ static int smsc911x_set_mac_address(struct net_device *dev, void *p)
19041909
/* Standard ioctls for mii-tool */
19051910
static int smsc911x_do_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
19061911
{
1907-
struct smsc911x_data *pdata = netdev_priv(dev);
1908-
1909-
if (!netif_running(dev) || !pdata->phy_dev)
1912+
if (!netif_running(dev) || !dev->phydev)
19101913
return -EINVAL;
19111914

1912-
return phy_mii_ioctl(pdata->phy_dev, ifr, cmd);
1915+
return phy_mii_ioctl(dev->phydev, ifr, cmd);
19131916
}
19141917

19151918
static int
19161919
smsc911x_ethtool_getsettings(struct net_device *dev, struct ethtool_cmd *cmd)
19171920
{
1918-
struct smsc911x_data *pdata = netdev_priv(dev);
1919-
19201921
cmd->maxtxpkt = 1;
19211922
cmd->maxrxpkt = 1;
1922-
return phy_ethtool_gset(pdata->phy_dev, cmd);
1923+
return phy_ethtool_gset(dev->phydev, cmd);
19231924
}
19241925

19251926
static int
19261927
smsc911x_ethtool_setsettings(struct net_device *dev, struct ethtool_cmd *cmd)
19271928
{
1928-
struct smsc911x_data *pdata = netdev_priv(dev);
1929-
1930-
return phy_ethtool_sset(pdata->phy_dev, cmd);
1929+
return phy_ethtool_sset(dev->phydev, cmd);
19311930
}
19321931

19331932
static void smsc911x_ethtool_getdrvinfo(struct net_device *dev,
@@ -1941,9 +1940,7 @@ static void smsc911x_ethtool_getdrvinfo(struct net_device *dev,
19411940

19421941
static int smsc911x_ethtool_nwayreset(struct net_device *dev)
19431942
{
1944-
struct smsc911x_data *pdata = netdev_priv(dev);
1945-
1946-
return phy_start_aneg(pdata->phy_dev);
1943+
return phy_start_aneg(dev->phydev);
19471944
}
19481945

19491946
static u32 smsc911x_ethtool_getmsglevel(struct net_device *dev)
@@ -1969,7 +1966,7 @@ smsc911x_ethtool_getregs(struct net_device *dev, struct ethtool_regs *regs,
19691966
void *buf)
19701967
{
19711968
struct smsc911x_data *pdata = netdev_priv(dev);
1972-
struct phy_device *phy_dev = pdata->phy_dev;
1969+
struct phy_device *phy_dev = dev->phydev;
19731970
unsigned long flags;
19741971
unsigned int i;
19751972
unsigned int j = 0;
@@ -2308,12 +2305,11 @@ static int smsc911x_drv_remove(struct platform_device *pdev)
23082305
pdata = netdev_priv(dev);
23092306
BUG_ON(!pdata);
23102307
BUG_ON(!pdata->ioaddr);
2311-
BUG_ON(!pdata->phy_dev);
2308+
BUG_ON(!dev->phydev);
23122309

23132310
SMSC_TRACE(pdata, ifdown, "Stopping driver");
23142311

2315-
phy_disconnect(pdata->phy_dev);
2316-
pdata->phy_dev = NULL;
2312+
phy_disconnect(dev->phydev);
23172313
mdiobus_unregister(pdata->mii_bus);
23182314
mdiobus_free(pdata->mii_bus);
23192315

0 commit comments

Comments
 (0)