netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] net: phy: marvell: optimize logic for page changing during init
@ 2016-11-10 14:03 Uwe Kleine-König
  2016-11-11  2:34 ` Florian Fainelli
  2016-11-13 17:05 ` David Miller
  0 siblings, 2 replies; 3+ messages in thread
From: Uwe Kleine-König @ 2016-11-10 14:03 UTC (permalink / raw)
  To: Florian Fainelli; +Cc: netdev

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>
---
 drivers/net/phy/marvell.c | 6 ++----
 1 file 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)
 static int marvell_of_reg_init(struct phy_device *phydev)
 {
 	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)
 		return 0;
@@ -374,7 +374,6 @@ static int marvell_of_reg_init(struct phy_device *phydev)
 	saved_page = phy_read(phydev, MII_MARVELL_PHY_PAGE);
 	if (saved_page < 0)
 		return saved_page;
-	page_changed = 0;
 	current_page = saved_page;
 
 	ret = 0;
@@ -388,7 +387,6 @@ static int marvell_of_reg_init(struct phy_device *phydev)
 
 		if (reg_page != current_page) {
 			current_page = reg_page;
-			page_changed = 1;
 			ret = phy_write(phydev, MII_MARVELL_PHY_PAGE, reg_page);
 			if (ret < 0)
 				goto err;
@@ -411,7 +409,7 @@ static int marvell_of_reg_init(struct phy_device *phydev)
 
 	}
 err:
-	if (page_changed) {
+	if (current_page != saved_page) {
 		i = phy_write(phydev, MII_MARVELL_PHY_PAGE, saved_page);
 		if (ret == 0)
 			ret = i;
-- 
2.10.2

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] net: phy: marvell: optimize logic for page changing during init
  2016-11-10 14:03 [PATCH] net: phy: marvell: optimize logic for page changing during init Uwe Kleine-König
@ 2016-11-11  2:34 ` Florian Fainelli
  2016-11-13 17:05 ` David Miller
  1 sibling, 0 replies; 3+ messages in thread
From: Florian Fainelli @ 2016-11-11  2:34 UTC (permalink / raw)
  To: Uwe Kleine-König; +Cc: netdev, Andrew Lunn

Le 10/11/2016 à 06:03, Uwe Kleine-König a écrit :
> 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.

Seems reasonable to me:

Reviewed-by: Florian Fainelli <f.fainelli@gmail.com>

> 
> Signed-off-by: Uwe Kleine-König <uwe@kleine-koenig.org>
> ---
>  drivers/net/phy/marvell.c | 6 ++----
>  1 file 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)
>  static int marvell_of_reg_init(struct phy_device *phydev)
>  {
>  	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)
>  		return 0;
> @@ -374,7 +374,6 @@ static int marvell_of_reg_init(struct phy_device *phydev)
>  	saved_page = phy_read(phydev, MII_MARVELL_PHY_PAGE);
>  	if (saved_page < 0)
>  		return saved_page;
> -	page_changed = 0;
>  	current_page = saved_page;
>  
>  	ret = 0;
> @@ -388,7 +387,6 @@ static int marvell_of_reg_init(struct phy_device *phydev)
>  
>  		if (reg_page != current_page) {
>  			current_page = reg_page;
> -			page_changed = 1;
>  			ret = phy_write(phydev, MII_MARVELL_PHY_PAGE, reg_page);
>  			if (ret < 0)
>  				goto err;
> @@ -411,7 +409,7 @@ static int marvell_of_reg_init(struct phy_device *phydev)
>  
>  	}
>  err:
> -	if (page_changed) {
> +	if (current_page != saved_page) {
>  		i = phy_write(phydev, MII_MARVELL_PHY_PAGE, saved_page);
>  		if (ret == 0)
>  			ret = i;
> 


-- 
Florian

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] net: phy: marvell: optimize logic for page changing during init
  2016-11-10 14:03 [PATCH] net: phy: marvell: optimize logic for page changing during init Uwe Kleine-König
  2016-11-11  2:34 ` Florian Fainelli
@ 2016-11-13 17:05 ` David Miller
  1 sibling, 0 replies; 3+ messages in thread
From: David Miller @ 2016-11-13 17:05 UTC (permalink / raw)
  To: uwe; +Cc: f.fainelli, netdev

From: Uwe Kleine-König <uwe@kleine-koenig.org>
Date: Thu, 10 Nov 2016 15:03:01 +0100

> 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>

Applied to net-next, thanks.

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2016-11-13 17:05 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-11-10 14:03 [PATCH] net: phy: marvell: optimize logic for page changing during init Uwe Kleine-König
2016-11-11  2:34 ` Florian Fainelli
2016-11-13 17:05 ` David Miller

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).