From 0b6eb1e68290243d439ee330ea8d0b239a5aec69 Mon Sep 17 00:00:00 2001
From: John Crispin <blogic@openwrt.org>
Date: Sun, 27 Jul 2014 09:38:50 +0100
Subject: [PATCH 34/53] NET: multi phy support

Signed-off-by: John Crispin <blogic@openwrt.org>
---
 drivers/net/phy/phy.c |    9 ++++++---
 include/linux/phy.h   |    1 +
 2 files changed, 7 insertions(+), 3 deletions(-)

--- a/drivers/net/phy/phy.c
+++ b/drivers/net/phy/phy.c
@@ -980,7 +980,10 @@ void phy_state_machine(struct work_struc
 		/* If the link is down, give up on negotiation for now */
 		if (!phydev->link) {
 			phydev->state = PHY_NOLINK;
-			phy_link_down(phydev, true);
+			if (!phydev->no_auto_carrier_off)
+				phy_link_down(phydev, true);
+			else
+				phy_link_down(phydev, false);
 			break;
 		}
 
@@ -1067,7 +1070,10 @@ void phy_state_machine(struct work_struc
 			phy_link_up(phydev);
 		} else {
 			phydev->state = PHY_NOLINK;
-			phy_link_down(phydev, true);
+			if (!phydev->no_auto_carrier_off)
+				phy_link_down(phydev, true);
+			else
+				phy_link_down(phydev, false);
 		}
 
 		if (phy_interrupt_is_valid(phydev))
@@ -1077,7 +1083,10 @@ void phy_state_machine(struct work_struc
 	case PHY_HALTED:
 		if (phydev->link) {
 			phydev->link = 0;
-			phy_link_down(phydev, true);
+			if (!phydev->no_auto_carrier_off)
+				phy_link_down(phydev, true);
+			else
+				phy_link_down(phydev, false);
 			do_suspend = true;
 		}
 		break;
--- a/include/linux/phy.h
+++ b/include/linux/phy.h
@@ -414,6 +414,7 @@ struct phy_device {
 	bool suspended_by_mdio_bus;
 	bool sysfs_links;
 	bool loopback_enabled;
+	bool no_auto_carrier_off;
 
 	enum phy_state state;
 
