]> err.no Git - linux-2.6/blobdiff - drivers/net/phy/phy.c
Merge branch 'for-linus' of master.kernel.org:/pub/scm/linux/kernel/git/roland/infiniband
[linux-2.6] / drivers / net / phy / phy.c
index e2c6896b92d254e5cca6fb3bc4b0909c901252ac..b8686e47f8996470c780305e15905e434649dda2 100644 (file)
@@ -30,7 +30,6 @@
 #include <linux/spinlock.h>
 #include <linux/mm.h>
 #include <linux/module.h>
-#include <linux/version.h>
 #include <linux/mii.h>
 #include <linux/ethtool.h>
 #include <linux/phy.h>
@@ -39,9 +38,6 @@
 #include <asm/irq.h>
 #include <asm/uaccess.h>
 
-static void phy_change(void *data);
-static void phy_timer(unsigned long data);
-
 /* Convenience function to print out the current phy status
  */
 void phy_print_status(struct phy_device *phydev)
@@ -127,44 +123,6 @@ static inline int phy_aneg_done(struct phy_device *phydev)
        return (retval < 0) ? retval : (retval & BMSR_ANEGCOMPLETE);
 }
 
-/* phy_start_aneg
- *
- * description: Calls the PHY driver's config_aneg, and then
- *   sets the PHY state to PHY_AN if auto-negotiation is enabled,
- *   and to PHY_FORCING if auto-negotiation is disabled. Unless
- *   the PHY is currently HALTED.
- */
-int phy_start_aneg(struct phy_device *phydev)
-{
-       int err;
-
-       spin_lock(&phydev->lock);
-
-       if (AUTONEG_DISABLE == phydev->autoneg)
-               phy_sanitize_settings(phydev);
-
-       err = phydev->drv->config_aneg(phydev);
-
-       if (err < 0)
-               goto out_unlock;
-
-       if (phydev->state != PHY_HALTED) {
-               if (AUTONEG_ENABLE == phydev->autoneg) {
-                       phydev->state = PHY_AN;
-                       phydev->link_timeout = PHY_AN_TIMEOUT;
-               } else {
-                       phydev->state = PHY_FORCING;
-                       phydev->link_timeout = PHY_FORCE_TIMEOUT;
-               }
-       }
-
-out_unlock:
-       spin_unlock(&phydev->lock);
-       return err;
-}
-EXPORT_SYMBOL(phy_start_aneg);
-
-
 /* A structure for mapping a particular speed and duplex
  * combination to a particular SUPPORTED and ADVERTISED value */
 struct phy_setting {
@@ -273,31 +231,6 @@ void phy_sanitize_settings(struct phy_device *phydev)
 }
 EXPORT_SYMBOL(phy_sanitize_settings);
 
-/* phy_force_reduction
- *
- * description: Reduces the speed/duplex settings by
- *   one notch.  The order is so:
- *   1000/FULL, 1000/HALF, 100/FULL, 100/HALF,
- *   10/FULL, 10/HALF.  The function bottoms out at 10/HALF.
- */
-static void phy_force_reduction(struct phy_device *phydev)
-{
-       int idx;
-
-       idx = phy_find_setting(phydev->speed, phydev->duplex);
-       
-       idx++;
-
-       idx = phy_find_valid(idx, phydev->supported);
-
-       phydev->speed = settings[idx].speed;
-       phydev->duplex = settings[idx].duplex;
-
-       pr_info("Trying %d/%s\n", phydev->speed,
-                       DUPLEX_FULL == phydev->duplex ?
-                       "FULL" : "HALF");
-}
-
 /* phy_ethtool_sset:
  * A generic ethtool sset function.  Handles all the details
  *
@@ -307,6 +240,7 @@ static void phy_force_reduction(struct phy_device *phydev)
  * - phy_start_aneg() will make sure forced settings are sane, and
  *   choose the next best ones from the ones selected, so we don't
  *   care if ethtool tries to give us bad values
+ *
  */
 int phy_ethtool_sset(struct phy_device *phydev, struct ethtool_cmd *cmd)
 {
@@ -422,6 +356,48 @@ int phy_mii_ioctl(struct phy_device *phydev,
        return 0;
 }
 
+/* phy_start_aneg
+ *
+ * description: Sanitizes the settings (if we're not
+ *   autonegotiating them), and then calls the driver's
+ *   config_aneg function.  If the PHYCONTROL Layer is operating,
+ *   we change the state to reflect the beginning of
+ *   Auto-negotiation or forcing.
+ */
+int phy_start_aneg(struct phy_device *phydev)
+{
+       int err;
+
+       spin_lock(&phydev->lock);
+
+       if (AUTONEG_DISABLE == phydev->autoneg)
+               phy_sanitize_settings(phydev);
+
+       err = phydev->drv->config_aneg(phydev);
+
+       if (err < 0)
+               goto out_unlock;
+
+       if (phydev->state != PHY_HALTED) {
+               if (AUTONEG_ENABLE == phydev->autoneg) {
+                       phydev->state = PHY_AN;
+                       phydev->link_timeout = PHY_AN_TIMEOUT;
+               } else {
+                       phydev->state = PHY_FORCING;
+                       phydev->link_timeout = PHY_FORCE_TIMEOUT;
+               }
+       }
+
+out_unlock:
+       spin_unlock(&phydev->lock);
+       return err;
+}
+EXPORT_SYMBOL(phy_start_aneg);
+
+
+static void phy_change(void *data);
+static void phy_timer(unsigned long data);
+
 /* phy_start_machine:
  *
  * description: The PHY infrastructure can run a state machine
@@ -464,7 +440,32 @@ void phy_stop_machine(struct phy_device *phydev)
        phydev->adjust_state = NULL;
 }
 
-#ifdef CONFIG_PHYCONTROL
+/* phy_force_reduction
+ *
+ * description: Reduces the speed/duplex settings by
+ *   one notch.  The order is so:
+ *   1000/FULL, 1000/HALF, 100/FULL, 100/HALF,
+ *   10/FULL, 10/HALF.  The function bottoms out at 10/HALF.
+ */
+static void phy_force_reduction(struct phy_device *phydev)
+{
+       int idx;
+
+       idx = phy_find_setting(phydev->speed, phydev->duplex);
+       
+       idx++;
+
+       idx = phy_find_valid(idx, phydev->supported);
+
+       phydev->speed = settings[idx].speed;
+       phydev->duplex = settings[idx].duplex;
+
+       pr_info("Trying %d/%s\n", phydev->speed,
+                       DUPLEX_FULL == phydev->duplex ?
+                       "FULL" : "HALF");
+}
+
+
 /* phy_error:
  *
  * Moves the PHY to the HALTED state in response to a read
@@ -859,4 +860,3 @@ static void phy_timer(unsigned long data)
        mod_timer(&phydev->phy_timer, jiffies + PHY_STATE_TIME * HZ);
 }
 
-#endif /* CONFIG_PHYCONTROL */