]> git.karo-electronics.de Git - mv-sheeva.git/blobdiff - drivers/net/phy/phy.c
phylib: two dynamic mii_bus allocation fallout fixes
[mv-sheeva.git] / drivers / net / phy / phy.c
index 12fccb1c76dc0c147e3291aaad803c8d5dbc9caf..df4e6257d4a77e3e9bba739db57dec8543315d79 100644 (file)
@@ -57,55 +57,6 @@ void phy_print_status(struct phy_device *phydev)
 EXPORT_SYMBOL(phy_print_status);
 
 
-/**
- * phy_read - Convenience function for reading a given PHY register
- * @phydev: the phy_device struct
- * @regnum: register number to read
- *
- * NOTE: MUST NOT be called from interrupt context,
- * because the bus read/write functions may wait for an interrupt
- * to conclude the operation.
- */
-int phy_read(struct phy_device *phydev, u16 regnum)
-{
-       int retval;
-       struct mii_bus *bus = phydev->bus;
-
-       BUG_ON(in_interrupt());
-
-       mutex_lock(&bus->mdio_lock);
-       retval = bus->read(bus, phydev->addr, regnum);
-       mutex_unlock(&bus->mdio_lock);
-
-       return retval;
-}
-EXPORT_SYMBOL(phy_read);
-
-/**
- * phy_write - Convenience function for writing a given PHY register
- * @phydev: the phy_device struct
- * @regnum: register number to write
- * @val: value to write to @regnum
- *
- * NOTE: MUST NOT be called from interrupt context,
- * because the bus read/write functions may wait for an interrupt
- * to conclude the operation.
- */
-int phy_write(struct phy_device *phydev, u16 regnum, u16 val)
-{
-       int err;
-       struct mii_bus *bus = phydev->bus;
-
-       BUG_ON(in_interrupt());
-
-       mutex_lock(&bus->mdio_lock);
-       err = bus->write(bus, phydev->addr, regnum, val);
-       mutex_unlock(&bus->mdio_lock);
-
-       return err;
-}
-EXPORT_SYMBOL(phy_write);
-
 /**
  * phy_clear_interrupt - Ack the phy device's interrupt
  * @phydev: the phy_device struct
@@ -366,7 +317,8 @@ int phy_mii_ioctl(struct phy_device *phydev,
        switch (cmd) {
        case SIOCGMIIPHY:
                mii_data->phy_id = phydev->addr;
-               break;
+               /* fall through */
+
        case SIOCGMIIREG:
                mii_data->val_out = phy_read(phydev, mii_data->reg_num);
                break;
@@ -406,12 +358,14 @@ int phy_mii_ioctl(struct phy_device *phydev,
                
                if (mii_data->reg_num == MII_BMCR 
                                && val & BMCR_RESET
-                               && phydev->drv->config_init)
+                               && phydev->drv->config_init) {
+                       phy_scan_fixups(phydev);
                        phydev->drv->config_init(phydev);
+               }
                break;
 
        default:
-               return -ENOTTY;
+               return -EOPNOTSUPP;
        }
 
        return 0;
@@ -545,7 +499,7 @@ static void phy_force_reduction(struct phy_device *phydev)
  * Must not be called from interrupt context, or while the
  * phydev->lock is held.
  */
-void phy_error(struct phy_device *phydev)
+static void phy_error(struct phy_device *phydev)
 {
        mutex_lock(&phydev->lock);
        phydev->state = PHY_HALTED;
@@ -726,6 +680,12 @@ static void phy_change(struct work_struct *work)
        if (err)
                goto irq_enable_err;
 
+       /* Stop timer and run the state queue now.  The work function for
+        * state_queue will start the timer up again.
+        */
+       del_timer(&phydev->phy_timer);
+       schedule_work(&phydev->state_queue);
+
        return;
 
 irq_enable_err: