diff mbox

[net-next,v2,1/2] net: systemport: only update UMAC_CMD if something changed

Message ID 1399317652-20078-2-git-send-email-f.fainelli@gmail.com
State Changes Requested, archived
Delegated to: David Miller
Headers show

Commit Message

Florian Fainelli May 5, 2014, 7:20 p.m. UTC
The link adjustment callback can be called as frequently as desired by
the PHY library, as such, let's avoid doing a Read/Modify/Write sequence
if nothing changed, which is more than likely since we are interfaced
with a switch device.

Signed-off-by: Florian Fainelli <f.fainelli@gmail.com>
---
Changes in v2:
- rebased against latest net-next/master

 drivers/net/ethernet/broadcom/bcmsysport.c | 15 ++++++++-------
 1 file changed, 8 insertions(+), 7 deletions(-)

Comments

David Miller May 7, 2014, 7:59 p.m. UTC | #1
From: Florian Fainelli <f.fainelli@gmail.com>
Date: Mon,  5 May 2014 12:20:51 -0700

> +		reg &= ~((CMD_SPEED_MASK << CMD_SPEED_SHIFT) |
> +				CMD_HD_EN | CMD_RX_PAUSE_IGNORE |
> +				CMD_TX_PAUSE_IGNORE);

While you're here use indentation more consistent with the rest of the
networking for this kind of expression.

On the second and third line, indent to the first column after the openning
parenthesis on the first line.

Thanks.
--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Florian Fainelli May 7, 2014, 9:38 p.m. UTC | #2
2014-05-07 12:59 GMT-07:00 David Miller <davem@davemloft.net>:
> From: Florian Fainelli <f.fainelli@gmail.com>
> Date: Mon,  5 May 2014 12:20:51 -0700
>
>> +             reg &= ~((CMD_SPEED_MASK << CMD_SPEED_SHIFT) |
>> +                             CMD_HD_EN | CMD_RX_PAUSE_IGNORE |
>> +                             CMD_TX_PAUSE_IGNORE);
>
> While you're here use indentation more consistent with the rest of the
> networking for this kind of expression.
>
> On the second and third line, indent to the first column after the openning
> parenthesis on the first line.

My email client does not render this properly apparently, so I do see
the same problem as you hinted, but the lines do really follow your
recommendation if you take a look at the raw patch in e.g: patchwork.
diff mbox

Patch

diff --git a/drivers/net/ethernet/broadcom/bcmsysport.c b/drivers/net/ethernet/broadcom/bcmsysport.c
index 4dc8d1e9829b..e118e7411ca4 100644
--- a/drivers/net/ethernet/broadcom/bcmsysport.c
+++ b/drivers/net/ethernet/broadcom/bcmsysport.c
@@ -959,15 +959,16 @@  static void bcm_sysport_adj_link(struct net_device *dev)
 	if (!phydev->pause)
 		cmd_bits |= CMD_RX_PAUSE_IGNORE | CMD_TX_PAUSE_IGNORE;
 
-	reg = umac_readl(priv, UMAC_CMD);
-	reg &= ~((CMD_SPEED_MASK << CMD_SPEED_SHIFT) |
-			CMD_HD_EN | CMD_RX_PAUSE_IGNORE |
-			CMD_TX_PAUSE_IGNORE);
-	reg |= cmd_bits;
-	umac_writel(priv, reg, UMAC_CMD);
+	if (changed) {
+		reg = umac_readl(priv, UMAC_CMD);
+		reg &= ~((CMD_SPEED_MASK << CMD_SPEED_SHIFT) |
+				CMD_HD_EN | CMD_RX_PAUSE_IGNORE |
+				CMD_TX_PAUSE_IGNORE);
+		reg |= cmd_bits;
+		umac_writel(priv, reg, UMAC_CMD);
 
-	if (changed)
 		phy_print_status(priv->phydev);
+	}
 }
 
 static int bcm_sysport_init_tx_ring(struct bcm_sysport_priv *priv,