PHY: Add the phy_device_release device method.
[cascardo/linux.git] / drivers / net / phy / phy_device.c
index a8b74cd..5b9e175 100644 (file)
@@ -44,6 +44,16 @@ static struct phy_driver genphy_driver;
 extern int mdio_bus_init(void);
 extern void mdio_bus_exit(void);
 
+void phy_device_free(struct phy_device *phydev)
+{
+       kfree(phydev);
+}
+
+static void phy_device_release(struct device *dev)
+{
+       phy_device_free(to_phy_device(dev));
+}
+
 struct phy_device* phy_device_create(struct mii_bus *bus, int addr, int phy_id)
 {
        struct phy_device *dev;
@@ -54,6 +64,8 @@ struct phy_device* phy_device_create(struct mii_bus *bus, int addr, int phy_id)
        if (NULL == dev)
                return (struct phy_device*) PTR_ERR((void*)-ENOMEM);
 
+       dev->dev.release = phy_device_release;
+
        dev->speed = 0;
        dev->duplex = -1;
        dev->pause = dev->asym_pause = 0;
@@ -364,7 +376,7 @@ EXPORT_SYMBOL(genphy_config_advert);
  */
 int genphy_setup_forced(struct phy_device *phydev)
 {
-       int ctl = BMCR_RESET;
+       int ctl = 0;
 
        phydev->pause = phydev->asym_pause = 0;
 
@@ -644,7 +656,7 @@ static int phy_probe(struct device *dev)
        if (!(phydrv->flags & PHY_HAS_INTERRUPT))
                phydev->irq = PHY_POLL;
 
-       spin_lock(&phydev->lock);
+       spin_lock_bh(&phydev->lock);
 
        /* Start out supporting everything. Eventually,
         * a controller will attach, and may modify one
@@ -658,7 +670,7 @@ static int phy_probe(struct device *dev)
        if (phydev->drv->probe)
                err = phydev->drv->probe(phydev);
 
-       spin_unlock(&phydev->lock);
+       spin_unlock_bh(&phydev->lock);
 
        return err;
 
@@ -670,9 +682,9 @@ static int phy_remove(struct device *dev)
 
        phydev = to_phy_device(dev);
 
-       spin_lock(&phydev->lock);
+       spin_lock_bh(&phydev->lock);
        phydev->state = PHY_DOWN;
-       spin_unlock(&phydev->lock);
+       spin_unlock_bh(&phydev->lock);
 
        if (phydev->drv->remove)
                phydev->drv->remove(phydev);
@@ -706,7 +718,7 @@ int phy_driver_register(struct phy_driver *new_driver)
                return retval;
        }
 
-       pr_info("%s: Registered new driver\n", new_driver->name);
+       pr_debug("%s: Registered new driver\n", new_driver->name);
 
        return 0;
 }