aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorUwe Kleine-König <uwe@kleine-koenig.org>2016-11-10 09:03:01 -0500
committerDavid S. Miller <davem@davemloft.net>2016-11-13 12:04:50 -0500
commitb5718b5aeff1930ab06efe5683b54f1a3b2795fb (patch)
tree658f90dfe2de003236687f0bf3ee455e2267063f
parent849dcce3fee7f2a68b2c82141e2f3b919bce3c79 (diff)
net: phy: marvell: optimize logic for page changing during init
Instead of remembering if the page was changed, just compare the current page to the saved one. This is easier and has the advantage to save a register write if the page was already restored. Signed-off-by: Uwe Kleine-König <uwe@kleine-koenig.org> Reviewed-by: Florian Fainelli <f.fainelli@gmail.com> Signed-off-by: David S. Miller <davem@davemloft.net>
-rw-r--r--drivers/net/phy/marvell.c6
1 files changed, 2 insertions, 4 deletions
diff --git a/drivers/net/phy/marvell.c b/drivers/net/phy/marvell.c
index c2dcf02df202..fa31f50824d3 100644
--- a/drivers/net/phy/marvell.c
+++ b/drivers/net/phy/marvell.c
@@ -361,7 +361,7 @@ static int m88e1111_config_aneg(struct phy_device *phydev)
361static int marvell_of_reg_init(struct phy_device *phydev) 361static int marvell_of_reg_init(struct phy_device *phydev)
362{ 362{
363 const __be32 *paddr; 363 const __be32 *paddr;
364 int len, i, saved_page, current_page, page_changed, ret; 364 int len, i, saved_page, current_page, ret;
365 365
366 if (!phydev->mdio.dev.of_node) 366 if (!phydev->mdio.dev.of_node)
367 return 0; 367 return 0;
@@ -374,7 +374,6 @@ static int marvell_of_reg_init(struct phy_device *phydev)
374 saved_page = phy_read(phydev, MII_MARVELL_PHY_PAGE); 374 saved_page = phy_read(phydev, MII_MARVELL_PHY_PAGE);
375 if (saved_page < 0) 375 if (saved_page < 0)
376 return saved_page; 376 return saved_page;
377 page_changed = 0;
378 current_page = saved_page; 377 current_page = saved_page;
379 378
380 ret = 0; 379 ret = 0;
@@ -388,7 +387,6 @@ static int marvell_of_reg_init(struct phy_device *phydev)
388 387
389 if (reg_page != current_page) { 388 if (reg_page != current_page) {
390 current_page = reg_page; 389 current_page = reg_page;
391 page_changed = 1;
392 ret = phy_write(phydev, MII_MARVELL_PHY_PAGE, reg_page); 390 ret = phy_write(phydev, MII_MARVELL_PHY_PAGE, reg_page);
393 if (ret < 0) 391 if (ret < 0)
394 goto err; 392 goto err;
@@ -411,7 +409,7 @@ static int marvell_of_reg_init(struct phy_device *phydev)
411 409
412 } 410 }
413err: 411err:
414 if (page_changed) { 412 if (current_page != saved_page) {
415 i = phy_write(phydev, MII_MARVELL_PHY_PAGE, saved_page); 413 i = phy_write(phydev, MII_MARVELL_PHY_PAGE, saved_page);
416 if (ret == 0) 414 if (ret == 0)
417 ret = i; 415 ret = i;