[BNX2X]: fix slowpath races and locking
[linux-2.6-block.git] / drivers / net / ibm_newemac / zmii.c
index d06312901848f75b8dcb0b00303e70fcfc9bf2a7..2ea472aeab06ac8c03deb714853024b8cce265f1 100644 (file)
@@ -3,6 +3,11 @@
  *
  * Driver for PowerPC 4xx on-chip ethernet controller, ZMII bridge support.
  *
+ * Copyright 2007 Benjamin Herrenschmidt, IBM Corp.
+ *                <benh@kernel.crashing.org>
+ *
+ * Based on the arch/ppc version of the driver:
+ *
  * Copyright (c) 2004, 2005 Zultys Technologies.
  * Eugene Surovegin <eugene.surovegin@zultys.com> or <ebs@ebshome.net>
  *
@@ -79,16 +84,18 @@ static inline u32 zmii_mode_mask(int mode, int input)
 int __devinit zmii_attach(struct of_device *ofdev, int input, int *mode)
 {
        struct zmii_instance *dev = dev_get_drvdata(&ofdev->dev);
-       struct zmii_regs *p = dev->base;
+       struct zmii_regs __iomem *p = dev->base;
 
        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);
 
@@ -250,7 +257,7 @@ static int __devinit zmii_probe(struct of_device *ofdev,
        }
 
        rc = -ENOMEM;
-       dev->base = (struct zmii_regs *)ioremap(regs.start,
+       dev->base = (struct zmii_regs __iomem *)ioremap(regs.start,
                                                sizeof(struct zmii_regs));
        if (dev->base == NULL) {
                printk(KERN_ERR "%s: Can't map device registers!\n",