[PATCH] devfs: Remove devfs_mk_dir() function from the kernel tree
[safe/jmp/linux-2.6] / drivers / net / sungem.c
index 2608e7a..5248670 100644 (file)
@@ -55,6 +55,7 @@
 #include <linux/workqueue.h>
 #include <linux/if_vlan.h>
 #include <linux/bitops.h>
+#include <linux/mutex.h>
 
 #include <asm/system.h>
 #include <asm/io.h>
@@ -128,6 +129,8 @@ static struct pci_device_id gem_pci_tbl[] = {
          PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0UL },
        { PCI_VENDOR_ID_APPLE, PCI_DEVICE_ID_APPLE_SH_SUNGEM,
          PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0UL },
+       { PCI_VENDOR_ID_APPLE, PCI_DEVICE_ID_APPLE_IPID2_GMAC,
+         PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0UL },
        {0, }
 };
 
@@ -948,6 +951,7 @@ static irqreturn_t gem_interrupt(int irq, void *dev_id, struct pt_regs *regs)
                u32 gem_status = readl(gp->regs + GREG_STAT);
 
                if (gem_status == 0) {
+                       netif_poll_enable(dev);
                        spin_unlock_irqrestore(&gp->lock, flags);
                        return IRQ_NONE;
                }
@@ -2281,7 +2285,7 @@ static void gem_reset_task(void *data)
 {
        struct gem *gp = (struct gem *) data;
 
-       down(&gp->pm_sem);
+       mutex_lock(&gp->pm_mutex);
 
        netif_poll_disable(gp->dev);
 
@@ -2308,7 +2312,7 @@ static void gem_reset_task(void *data)
 
        netif_poll_enable(gp->dev);
 
-       up(&gp->pm_sem);
+       mutex_unlock(&gp->pm_mutex);
 }
 
 
@@ -2317,14 +2321,14 @@ static int gem_open(struct net_device *dev)
        struct gem *gp = dev->priv;
        int rc = 0;
 
-       down(&gp->pm_sem);
+       mutex_lock(&gp->pm_mutex);
 
        /* We need the cell enabled */
        if (!gp->asleep)
                rc = gem_do_start(dev);
        gp->opened = (rc == 0);
 
-       up(&gp->pm_sem);
+       mutex_unlock(&gp->pm_mutex);
 
        return rc;
 }
@@ -2337,13 +2341,13 @@ static int gem_close(struct net_device *dev)
         * our caller (dev_close) already did it for us
         */
 
-       down(&gp->pm_sem);
+       mutex_lock(&gp->pm_mutex);
 
        gp->opened = 0; 
        if (!gp->asleep)
                gem_do_stop(dev, 0);
 
-       up(&gp->pm_sem);
+       mutex_unlock(&gp->pm_mutex);
        
        return 0;
 }
@@ -2355,7 +2359,7 @@ static int gem_suspend(struct pci_dev *pdev, pm_message_t state)
        struct gem *gp = dev->priv;
        unsigned long flags;
 
-       down(&gp->pm_sem);
+       mutex_lock(&gp->pm_mutex);
 
        netif_poll_disable(dev);
 
@@ -2388,11 +2392,11 @@ static int gem_suspend(struct pci_dev *pdev, pm_message_t state)
        /* Stop the link timer */
        del_timer_sync(&gp->link_timer);
 
-       /* Now we release the semaphore to not block the reset task who
+       /* Now we release the mutex to not block the reset task who
         * can take it too. We are marked asleep, so there will be no
         * conflict here
         */
-       up(&gp->pm_sem);
+       mutex_unlock(&gp->pm_mutex);
 
        /* Wait for a pending reset task to complete */
        while (gp->reset_task_pending)
@@ -2421,7 +2425,7 @@ static int gem_resume(struct pci_dev *pdev)
 
        printk(KERN_INFO "%s: resuming\n", dev->name);
 
-       down(&gp->pm_sem);
+       mutex_lock(&gp->pm_mutex);
 
        /* Keep the cell enabled during the entire operation, no need to
         * take a lock here tho since nothing else can happen while we are
@@ -2437,7 +2441,7 @@ static int gem_resume(struct pci_dev *pdev)
                 * still asleep, a new sleep cycle may bring it back
                 */
                gem_put_cell(gp);
-               up(&gp->pm_sem);
+               mutex_unlock(&gp->pm_mutex);
                return 0;
        }
        pci_set_master(gp->pdev);
@@ -2483,7 +2487,7 @@ static int gem_resume(struct pci_dev *pdev)
 
        netif_poll_enable(dev);
        
-       up(&gp->pm_sem);
+       mutex_unlock(&gp->pm_mutex);
 
        return 0;
 }
@@ -2588,7 +2592,7 @@ static int gem_change_mtu(struct net_device *dev, int new_mtu)
                return 0;
        }
 
-       down(&gp->pm_sem);
+       mutex_lock(&gp->pm_mutex);
        spin_lock_irq(&gp->lock);
        spin_lock(&gp->tx_lock);
        dev->mtu = new_mtu;
@@ -2599,7 +2603,7 @@ static int gem_change_mtu(struct net_device *dev, int new_mtu)
        }
        spin_unlock(&gp->tx_lock);
        spin_unlock_irq(&gp->lock);
-       up(&gp->pm_sem);
+       mutex_unlock(&gp->pm_mutex);
 
        return 0;
 }
@@ -2768,10 +2772,10 @@ static int gem_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
        int rc = -EOPNOTSUPP;
        unsigned long flags;
 
-       /* Hold the PM semaphore while doing ioctl's or we may collide
+       /* Hold the PM mutex while doing ioctl's or we may collide
         * with power management.
         */
-       down(&gp->pm_sem);
+       mutex_lock(&gp->pm_mutex);
                
        spin_lock_irqsave(&gp->lock, flags);
        gem_get_cell(gp);
@@ -2809,14 +2813,14 @@ static int gem_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
        gem_put_cell(gp);
        spin_unlock_irqrestore(&gp->lock, flags);
 
-       up(&gp->pm_sem);
+       mutex_unlock(&gp->pm_mutex);
        
        return rc;
 }
 
 #if (!defined(__sparc__) && !defined(CONFIG_PPC_PMAC))
 /* Fetch MAC address from vital product data of PCI ROM. */
-static void find_eth_addr_in_vpd(void __iomem *rom_base, int len, unsigned char *dev_addr)
+static int find_eth_addr_in_vpd(void __iomem *rom_base, int len, unsigned char *dev_addr)
 {
        int this_offset;
 
@@ -2837,35 +2841,27 @@ static void find_eth_addr_in_vpd(void __iomem *rom_base, int len, unsigned char
 
                for (i = 0; i < 6; i++)
                        dev_addr[i] = readb(p + i);
-               break;
+               return 1;
        }
+       return 0;
 }
 
 static void get_gem_mac_nonobp(struct pci_dev *pdev, unsigned char *dev_addr)
 {
-       u32 rom_reg_orig;
-       void __iomem *p;
-
-       if (pdev->resource[PCI_ROM_RESOURCE].parent == NULL) {
-               if (pci_assign_resource(pdev, PCI_ROM_RESOURCE) < 0)
-                       goto use_random;
-       }
-
-       pci_read_config_dword(pdev, pdev->rom_base_reg, &rom_reg_orig);
-       pci_write_config_dword(pdev, pdev->rom_base_reg,
-                              rom_reg_orig | PCI_ROM_ADDRESS_ENABLE);
+       size_t size;
+       void __iomem *p = pci_map_rom(pdev, &size);
 
-       p = ioremap(pci_resource_start(pdev, PCI_ROM_RESOURCE), (64 * 1024));
-       if (p != NULL && readb(p) == 0x55 && readb(p + 1) == 0xaa)
-               find_eth_addr_in_vpd(p, (64 * 1024), dev_addr);
+       if (p) {
+                       int found;
 
-       if (p != NULL)
-               iounmap(p);
-
-       pci_write_config_dword(pdev, pdev->rom_base_reg, rom_reg_orig);
-       return;
+               found = readb(p) == 0x55 &&
+                       readb(p + 1) == 0xaa &&
+                       find_eth_addr_in_vpd(p, (64 * 1024), dev_addr);
+               pci_unmap_rom(pdev, p);
+               if (found)
+                       return;
+       }
 
-use_random:
        /* Sun MAC prefix then 3 random bytes. */
        dev_addr[0] = 0x08;
        dev_addr[1] = 0x00;
@@ -2884,17 +2880,20 @@ static int __devinit gem_get_device_address(struct gem *gp)
 #if defined(__sparc__)
        struct pci_dev *pdev = gp->pdev;
        struct pcidev_cookie *pcp = pdev->sysdata;
-       int node = -1;
+       int use_idprom = 1;
 
        if (pcp != NULL) {
-               node = pcp->prom_node;
-               if (prom_getproplen(node, "local-mac-address") == 6)
-                       prom_getproperty(node, "local-mac-address",
-                                        dev->dev_addr, 6);
-               else
-                       node = -1;
+               unsigned char *addr;
+               int len;
+
+               addr = of_get_property(pcp->prom_node, "local-mac-address",
+                                      &len);
+               if (addr && len == 6) {
+                       use_idprom = 0;
+                       memcpy(dev->dev_addr, addr, 6);
+               }
        }
-       if (node == -1)
+       if (use_idprom)
                memcpy(dev->dev_addr, idprom->id_ethaddr, 6);
 #elif defined(CONFIG_PPC_PMAC)
        unsigned char *addr;
@@ -2912,7 +2911,7 @@ static int __devinit gem_get_device_address(struct gem *gp)
        return 0;
 }
 
-static void __devexit gem_remove_one(struct pci_dev *pdev)
+static void gem_remove_one(struct pci_dev *pdev)
 {
        struct net_device *dev = pci_get_drvdata(pdev);
 
@@ -3038,7 +3037,7 @@ static int __devinit gem_init_one(struct pci_dev *pdev,
 
        spin_lock_init(&gp->lock);
        spin_lock_init(&gp->tx_lock);
-       init_MUTEX(&gp->pm_sem);
+       mutex_init(&gp->pm_mutex);
 
        init_timer(&gp->link_timer);
        gp->link_timer.function = gem_link_timer;
@@ -3186,7 +3185,7 @@ static struct pci_driver gem_driver = {
        .name           = GEM_MODULE_NAME,
        .id_table       = gem_pci_tbl,
        .probe          = gem_init_one,
-       .remove         = __devexit_p(gem_remove_one),
+       .remove         = gem_remove_one,
 #ifdef CONFIG_PM
        .suspend        = gem_suspend,
        .resume         = gem_resume,