Merge branch 'for-linus2' of git://git.profusion.mobi/users/lucas/linux-2.6
[pandora-kernel.git] / drivers / net / phy / phy_device.c
index ff61293..ff109fe 100644 (file)
@@ -442,11 +442,11 @@ static int phy_attach_direct(struct net_device *dev, struct phy_device *phydev,
                             u32 flags, phy_interface_t interface)
 {
        struct device *d = &phydev->dev;
+       int err;
 
        /* Assume that if there is no driver, that it doesn't
         * exist, and we should use the genphy driver. */
        if (NULL == d->driver) {
-               int err;
                d->driver = &genphy_driver.driver;
 
                err = d->driver->probe(d);
@@ -474,7 +474,11 @@ static int phy_attach_direct(struct net_device *dev, struct phy_device *phydev,
        /* Do initial configuration here, now that
         * we have certain key parameters
         * (dev_flags and interface) */
-       return phy_init_hw(phydev);
+       err = phy_init_hw(phydev);
+       if (err)
+               phy_detach(phydev);
+
+       return err;
 }
 
 /**