瀏覽代碼

network: add the missing phy_device speed information to phy_mii_ioctl

Function `phy_mii_ioctl' returns physical device's information based on
user requests.  When requested to return the basic mode control register
information (BMCR), the original implementation only returns the physical
device's duplex information and forgets to return speed information, which
should not be because BMCR register is used to hold both duplex and speed
information.

The patch checks the BMCR value against speed-related flags and fills the
return structure's speed field accordingly.

Signed-off-by: Shan <shanlu@cs.uiuc.edu>
Cc: Jeff Garzik <jeff@garzik.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Jeff Garzik <jeff@garzik.org>
Shan Lu 18 年之前
父節點
當前提交
024a0a3cfb
共有 1 個文件被更改,包括 6 次插入0 次删除
  1. 6 0
      drivers/net/phy/phy.c

+ 6 - 0
drivers/net/phy/phy.c

@@ -382,6 +382,12 @@ int phy_mii_ioctl(struct phy_device *phydev,
 					phydev->duplex = DUPLEX_FULL;
 					phydev->duplex = DUPLEX_FULL;
 				else
 				else
 					phydev->duplex = DUPLEX_HALF;
 					phydev->duplex = DUPLEX_HALF;
+				if ((!phydev->autoneg) &&
+						(val & BMCR_SPEED1000))
+					phydev->speed = SPEED_1000;
+				else if ((!phydev->autoneg) &&
+						(val & BMCR_SPEED100))
+					phydev->speed = SPEED_100;
 				break;
 				break;
 			case MII_ADVERTISE:
 			case MII_ADVERTISE:
 				phydev->advertising = val;
 				phydev->advertising = val;