Merge branch 'linus' into cont_syslog
[safe/jmp/linux-2.6] / drivers / net / smc91x.c
index 61be6d7..10cf0cb 100644 (file)
@@ -35,7 +35,7 @@
  *
  * contributors:
  *     Daris A Nevil <dnevil@snmc.com>
- *      Nicolas Pitre <nico@cam.org>
+ *      Nicolas Pitre <nico@fluxnic.net>
  *     Russell King <rmk@arm.linux.org.uk>
  *
  * History:
@@ -58,7 +58,7 @@
  *   22/09/04  Nicolas Pitre      big update (see commit log for details)
  */
 static const char version[] =
-       "smc91x.c: v1.1, sep 22 2004 by Nicolas Pitre <nico@cam.org>\n";
+       "smc91x.c: v1.1, sep 22 2004 by Nicolas Pitre <nico@fluxnic.net>\n";
 
 /* Debugging level */
 #ifndef SMC_DEBUG
@@ -70,7 +70,6 @@ static const char version[] =
 #include <linux/module.h>
 #include <linux/kernel.h>
 #include <linux/sched.h>
-#include <linux/slab.h>
 #include <linux/delay.h>
 #include <linux/interrupt.h>
 #include <linux/errno.h>
@@ -534,9 +533,9 @@ static inline void  smc_rcv(struct net_device *dev)
 #define smc_special_lock(lock, flags)          spin_lock_irqsave(lock, flags)
 #define smc_special_unlock(lock, flags)        spin_unlock_irqrestore(lock, flags)
 #else
-#define smc_special_trylock(lock, flags)       (1)
-#define smc_special_lock(lock, flags)          do { } while (0)
-#define smc_special_unlock(lock, flags)        do { } while (0)
+#define smc_special_trylock(lock, flags)       (flags == flags)
+#define smc_special_lock(lock, flags)          do { flags = 0; } while (0)
+#define smc_special_unlock(lock, flags)        do { flags = 0; } while (0)
 #endif
 
 /*
@@ -1286,7 +1285,7 @@ static irqreturn_t smc_interrupt(int irq, void *dev_id)
                        smc_phy_interrupt(dev);
                } else if (status & IM_ERCV_INT) {
                        SMC_ACK_INT(lp, IM_ERCV_INT);
-                       PRINTK("%s: UNSUPPORTED: ERCV INTERRUPT \n", dev->name);
+                       PRINTK("%s: UNSUPPORTED: ERCV INTERRUPT\n", dev->name);
                }
        } while (--timeout);
 
@@ -1361,7 +1360,7 @@ static void smc_timeout(struct net_device *dev)
                schedule_work(&lp->phy_configure);
 
        /* We can accept TX packets again */
-       dev->trans_start = jiffies;
+       dev->trans_start = jiffies; /* prevent tx timeout */
        netif_wake_queue(dev);
 }
 
@@ -1395,7 +1394,7 @@ static void smc_set_multicast_list(struct net_device *dev)
         * I don't need to zero the multicast table, because the flag is
         * checked before the table is
         */
-       else if (dev->flags & IFF_ALLMULTI || dev->mc_count > 16) {
+       else if (dev->flags & IFF_ALLMULTI || netdev_mc_count(dev) > 16) {
                DBG(2, "%s: RCR_ALMUL\n", dev->name);
                lp->rcr_cur_mode |= RCR_ALMUL;
        }
@@ -1412,9 +1411,8 @@ static void smc_set_multicast_list(struct net_device *dev)
         * the number of the 8 bit register, while the low 3 bits are the bit
         * within that register.
         */
-       else if (dev->mc_count)  {
-               int i;
-               struct dev_mc_list *cur_addr;
+       else if (!netdev_mc_empty(dev)) {
+               struct netdev_hw_addr *ha;
 
                /* table for flipping the order of 3 bits */
                static const unsigned char invert3[] = {0, 4, 2, 6, 1, 5, 3, 7};
@@ -1422,20 +1420,16 @@ static void smc_set_multicast_list(struct net_device *dev)
                /* start with a table of all zeros: reject all */
                memset(multicast_table, 0, sizeof(multicast_table));
 
-               cur_addr = dev->mc_list;
-               for (i = 0; i < dev->mc_count; i++, cur_addr = cur_addr->next) {
+               netdev_for_each_mc_addr(ha, dev) {
                        int position;
 
-                       /* do we have a pointer here? */
-                       if (!cur_addr)
-                               break;
                        /* make sure this is a multicast address -
                           shouldn't this be a given if we have it here ? */
-                       if (!(*cur_addr->dmi_addr & 1))
+                       if (!(*ha->addr & 1))
                                continue;
 
                        /* only use the low order bits */
-                       position = crc32_le(~0, cur_addr->dmi_addr, 6) & 0x3f;
+                       position = crc32_le(~0, ha->addr, 6) & 0x3f;
 
                        /* do some messy swapping to put the bit in the right spot */
                        multicast_table[invert3[position&7]] |=
@@ -2031,7 +2025,7 @@ static int __devinit smc_probe(struct net_device *dev, void __iomem *ioaddr,
        }
 
        /* Grab the IRQ */
-       retval = request_irq(dev->irq, &smc_interrupt, irq_flags, dev->name, dev);
+       retval = request_irq(dev->irq, smc_interrupt, irq_flags, dev->name, dev);
        if (retval)
                goto err_out;
 
@@ -2283,7 +2277,7 @@ static int __devinit smc_drv_probe(struct platform_device *pdev)
 
        ndev->irq = ires->start;
 
-       if (ires->flags & IRQF_TRIGGER_MASK)
+       if (irq_flags == -1 || ires->flags & IRQF_TRIGGER_MASK)
                irq_flags = ires->flags & IRQF_TRIGGER_MASK;
 
        ret = smc_request_attrib(pdev, ndev);
@@ -2365,9 +2359,10 @@ static int __devexit smc_drv_remove(struct platform_device *pdev)
        return 0;
 }
 
-static int smc_drv_suspend(struct platform_device *dev, pm_message_t state)
+static int smc_drv_suspend(struct device *dev)
 {
-       struct net_device *ndev = platform_get_drvdata(dev);
+       struct platform_device *pdev = to_platform_device(dev);
+       struct net_device *ndev = platform_get_drvdata(pdev);
 
        if (ndev) {
                if (netif_running(ndev)) {
@@ -2379,13 +2374,14 @@ static int smc_drv_suspend(struct platform_device *dev, pm_message_t state)
        return 0;
 }
 
-static int smc_drv_resume(struct platform_device *dev)
+static int smc_drv_resume(struct device *dev)
 {
-       struct net_device *ndev = platform_get_drvdata(dev);
+       struct platform_device *pdev = to_platform_device(dev);
+       struct net_device *ndev = platform_get_drvdata(pdev);
 
        if (ndev) {
                struct smc_local *lp = netdev_priv(ndev);
-               smc_enable_device(dev);
+               smc_enable_device(pdev);
                if (netif_running(ndev)) {
                        smc_reset(ndev);
                        smc_enable(ndev);
@@ -2397,14 +2393,18 @@ static int smc_drv_resume(struct platform_device *dev)
        return 0;
 }
 
+static struct dev_pm_ops smc_drv_pm_ops = {
+       .suspend        = smc_drv_suspend,
+       .resume         = smc_drv_resume,
+};
+
 static struct platform_driver smc_driver = {
        .probe          = smc_drv_probe,
        .remove         = __devexit_p(smc_drv_remove),
-       .suspend        = smc_drv_suspend,
-       .resume         = smc_drv_resume,
        .driver         = {
                .name   = CARDNAME,
                .owner  = THIS_MODULE,
+               .pm     = &smc_drv_pm_ops,
        },
 };