Commit b5718b5a authored by Uwe Kleine-König's avatar Uwe Kleine-König Committed by David S. Miller

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: default avatarUwe Kleine-König <uwe@kleine-koenig.org>
Reviewed-by: default avatarFlorian Fainelli <f.fainelli@gmail.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 849dcce3
...@@ -361,7 +361,7 @@ static int m88e1111_config_aneg(struct phy_device *phydev) ...@@ -361,7 +361,7 @@ static int m88e1111_config_aneg(struct phy_device *phydev)
static int marvell_of_reg_init(struct phy_device *phydev) static int marvell_of_reg_init(struct phy_device *phydev)
{ {
const __be32 *paddr; const __be32 *paddr;
int len, i, saved_page, current_page, page_changed, ret; int len, i, saved_page, current_page, ret;
if (!phydev->mdio.dev.of_node) if (!phydev->mdio.dev.of_node)
return 0; return 0;
...@@ -374,7 +374,6 @@ static int marvell_of_reg_init(struct phy_device *phydev) ...@@ -374,7 +374,6 @@ static int marvell_of_reg_init(struct phy_device *phydev)
saved_page = phy_read(phydev, MII_MARVELL_PHY_PAGE); saved_page = phy_read(phydev, MII_MARVELL_PHY_PAGE);
if (saved_page < 0) if (saved_page < 0)
return saved_page; return saved_page;
page_changed = 0;
current_page = saved_page; current_page = saved_page;
ret = 0; ret = 0;
...@@ -388,7 +387,6 @@ static int marvell_of_reg_init(struct phy_device *phydev) ...@@ -388,7 +387,6 @@ static int marvell_of_reg_init(struct phy_device *phydev)
if (reg_page != current_page) { if (reg_page != current_page) {
current_page = reg_page; current_page = reg_page;
page_changed = 1;
ret = phy_write(phydev, MII_MARVELL_PHY_PAGE, reg_page); ret = phy_write(phydev, MII_MARVELL_PHY_PAGE, reg_page);
if (ret < 0) if (ret < 0)
goto err; goto err;
...@@ -411,7 +409,7 @@ static int marvell_of_reg_init(struct phy_device *phydev) ...@@ -411,7 +409,7 @@ static int marvell_of_reg_init(struct phy_device *phydev)
} }
err: err:
if (page_changed) { if (current_page != saved_page) {
i = phy_write(phydev, MII_MARVELL_PHY_PAGE, saved_page); i = phy_write(phydev, MII_MARVELL_PHY_PAGE, saved_page);
if (ret == 0) if (ret == 0)
ret = i; ret = i;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment