فهرست منبع

net: phy: allow driver to implement their own aneg_done

Some PHYs out there can be very quirky with respect to how they would
report the auto-negotiation is completed. Allow drivers to override the
generic aneg_done() implementation by providing their own.

Since not all drivers have been updated yet to use genphy_aneg_done() as
aneg_done() callback, we explicitely check that this callback is valid
before calling into it.

Signed-off-by: Florian Fainelli <f.fainelli@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Florian Fainelli 11 سال پیش
والد
کامیت
76a423a3f8
3فایلهای تغییر یافته به همراه10 افزوده شده و 3 حذف شده
  1. 6 3
      drivers/net/phy/phy.c
  2. 1 0
      drivers/net/phy/phy_device.c
  3. 3 0
      include/linux/phy.h

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

@@ -114,12 +114,15 @@ static int phy_config_interrupt(struct phy_device *phydev, u32 interrupts)
  * phy_aneg_done - return auto-negotiation status
  * phy_aneg_done - return auto-negotiation status
  * @phydev: target phy_device struct
  * @phydev: target phy_device struct
  *
  *
- * Description: Reads the status register and returns 0 either if
- *   auto-negotiation is incomplete, or if there was an error.
- *   Returns BMSR_ANEGCOMPLETE if auto-negotiation is done.
+ * Description: Return the auto-negotiation status from this @phydev
+ * Returns > 0 on success or < 0 on error. 0 means that auto-negotiation
+ * is still pending.
  */
  */
 static inline int phy_aneg_done(struct phy_device *phydev)
 static inline int phy_aneg_done(struct phy_device *phydev)
 {
 {
+	if (phydev->drv->aneg_done)
+		return phydev->drv->aneg_done(phydev);
+
 	return genphy_aneg_done(phydev);
 	return genphy_aneg_done(phydev);
 }
 }
 
 

+ 1 - 0
drivers/net/phy/phy_device.c

@@ -1267,6 +1267,7 @@ static struct phy_driver genphy_driver[] = {
 	.config_init	= genphy_config_init,
 	.config_init	= genphy_config_init,
 	.features	= 0,
 	.features	= 0,
 	.config_aneg	= genphy_config_aneg,
 	.config_aneg	= genphy_config_aneg,
+	.aneg_done	= genphy_aneg_done,
 	.read_status	= genphy_read_status,
 	.read_status	= genphy_read_status,
 	.suspend	= genphy_suspend,
 	.suspend	= genphy_suspend,
 	.resume		= genphy_resume,
 	.resume		= genphy_resume,

+ 3 - 0
include/linux/phy.h

@@ -417,6 +417,9 @@ struct phy_driver {
 	 */
 	 */
 	int (*config_aneg)(struct phy_device *phydev);
 	int (*config_aneg)(struct phy_device *phydev);
 
 
+	/* Determines the auto negotiation result */
+	int (*aneg_done)(struct phy_device *phydev);
+
 	/* Determines the negotiated speed and duplex */
 	/* Determines the negotiated speed and duplex */
 	int (*read_status)(struct phy_device *phydev);
 	int (*read_status)(struct phy_device *phydev);