diff mbox

[20/27] UBUNTU: SAUCE: net/phy: avoid reaching an unsupported speed and duplex combination

Message ID a55194b46411e624ee6b670a1ddad4200d99a67d.1339455422.git.bcollins@ubuntu.com
State New
Headers show

Commit Message

Benjamin Collins Oct. 6, 2011, 10:27 p.m. UTC
- phy_force_reduction() may get the interface into a speed and duplex combination
 that is not supported by the device;
 - wait PHY_FORCE_TIMEOUT before each speed/duplex reduction in forced mode

This patch is being maintained and will eventually be merged upstream by
Freescale directly. The powerpc-e500mc flavour uses this.

Signed-off-by: Madalin Bucur <madalin.bucur@freescale.com>
Signed-off-by: Ben Collins <bcollins@ubuntu.com>
---
 drivers/net/phy/phy.c |    8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)
diff mbox

Patch

diff --git a/drivers/net/phy/phy.c b/drivers/net/phy/phy.c
index 2c16be0..0825a78 100644
--- a/drivers/net/phy/phy.c
+++ b/drivers/net/phy/phy.c
@@ -6,7 +6,7 @@ 
  *
  * Author: Andy Fleming
  *
- * Copyright (c) 2004 Freescale Semiconductor, Inc.
+ * Copyright (c) 2004,2011 Freescale Semiconductor, Inc.
  * Copyright (c) 2006, 2007  Maciej W. Rozycki
  *
  * This program is free software; you can redistribute  it and/or modify it
@@ -479,6 +479,10 @@  static void phy_force_reduction(struct phy_device *phydev)
 
 	idx = phy_find_valid(idx, phydev->supported);
 
+	/* Avoid reaching an invalid speed and duplex combination */
+	if (!(settings[idx].setting & phydev->supported))
+		return;
+
 	phydev->speed = settings[idx].speed;
 	phydev->duplex = settings[idx].duplex;
 
@@ -869,6 +873,8 @@  void phy_state_machine(struct work_struct *work)
 				if (0 == phydev->link_timeout--) {
 					phy_force_reduction(phydev);
 					needs_aneg = 1;
+					phydev->link_timeout =
+						PHY_FORCE_TIMEOUT;
 				}
 			}