From 3e3a4d3d6b4c9d6e34ea887151db8df98d3db001 Mon Sep 17 00:00:00 2001
From: Gabor Juhos <juhosg@openwrt.org>
Date: Sun, 29 Apr 2012 18:29:24 +0000
Subject: ar71xx: allow to disable link polling on unused PHYs

SVN-Revision: 31533
---
 .../drivers/net/ethernet/atheros/ag71xx/ag71xx_ar7240.c   | 15 +++++++++++----
 1 file changed, 11 insertions(+), 4 deletions(-)

(limited to 'target/linux/ar71xx/files/drivers')

diff --git a/target/linux/ar71xx/files/drivers/net/ethernet/atheros/ag71xx/ag71xx_ar7240.c b/target/linux/ar71xx/files/drivers/net/ethernet/atheros/ag71xx/ag71xx_ar7240.c
index fc8b6d5..49f0775 100644
--- a/target/linux/ar71xx/files/drivers/net/ethernet/atheros/ag71xx/ag71xx_ar7240.c
+++ b/target/linux/ar71xx/files/drivers/net/ethernet/atheros/ag71xx/ag71xx_ar7240.c
@@ -1115,19 +1115,26 @@ static void link_function(struct work_struct *work) {
 	struct ag71xx *ag = container_of(work, struct ag71xx, link_work.work);
 	struct ar7240sw *as = ag->phy_priv;
 	unsigned long flags;
+	u8 mask;
 	int i;
 	int status = 0;
 
-	for (i = 0; i < as->swdev.ports; i++) {
-		int link = ar7240sw_phy_read(ag->mii_bus, i, MII_BMSR);
-		if(link & BMSR_LSTATUS) {
+	mask = ~as->swdata->phy_poll_mask;
+	for (i = 0; i < AR7240_NUM_PHYS; i++) {
+		int link;
+
+		if (!(mask & BIT(i)))
+			continue;
+
+		link = ar7240sw_phy_read(ag->mii_bus, i, MII_BMSR);
+		if (link & BMSR_LSTATUS) {
 			status = 1;
 			break;
 		}
 	}
 
 	spin_lock_irqsave(&ag->lock, flags);
-	if(status != ag->link) {
+	if (status != ag->link) {
 		ag->link = status;
 		ag71xx_link_adjust(ag);
 	}
-- 
cgit v1.1