ibm_newemac: Fix ZMII refcounting bug
authorBenjamin Herrenschmidt <benh@kernel.crashing.org>
Wed, 5 Dec 2007 00:14:27 +0000 (11:14 +1100)
committerJeff Garzik <jeff@garzik.org>
Fri, 7 Dec 2007 20:09:05 +0000 (15:09 -0500)
When using ZMII for MDIO only (such as 440GX with RGMII for data and ZMII for
MDIO), the ZMII code would fail to properly refcount, thus triggering a
BUG_ON().

Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Acked-by: Stefan Roese <sr@denx.de>
Signed-off-by: Jeff Garzik <jeff@garzik.org>
drivers/net/ibm_newemac/zmii.c

index 2219ec2740e056f37f12619613c94f49c4e6fcd0..0f8cfbc0c618f5574a532458549cc0e7992d94fe 100644 (file)
@@ -83,12 +83,14 @@ int __devinit zmii_attach(struct of_device *ofdev, int input, int *mode)
 
        ZMII_DBG(dev, "init(%d, %d)" NL, input, *mode);
 
-       if (!zmii_valid_mode(*mode))
+       if (!zmii_valid_mode(*mode)) {
                /* Probably an EMAC connected to RGMII,
                 * but it still may need ZMII for MDIO so
                 * we don't fail here.
                 */
+               dev->users++;
                return 0;
+       }
 
        mutex_lock(&dev->lock);