net: check for underlength tap writes
[linux-2.6-block.git] / drivers / net / smc91x.c
index 24e610e711e8302c6f61e7bf09acc38814aabb34..63a54e29d56331c24a160d644ba6b57626c8c219 100644 (file)
@@ -173,49 +173,6 @@ MODULE_LICENSE("GPL");
  */
 #define MII_DELAY              1
 
-/* store this information for the driver.. */
-struct smc_local {
-       /*
-        * If I have to wait until memory is available to send a
-        * packet, I will store the skbuff here, until I get the
-        * desired memory.  Then, I'll send it out and free it.
-        */
-       struct sk_buff *pending_tx_skb;
-       struct tasklet_struct tx_task;
-
-       /* version/revision of the SMC91x chip */
-       int     version;
-
-       /* Contains the current active transmission mode */
-       int     tcr_cur_mode;
-
-       /* Contains the current active receive mode */
-       int     rcr_cur_mode;
-
-       /* Contains the current active receive/phy mode */
-       int     rpc_cur_mode;
-       int     ctl_rfduplx;
-       int     ctl_rspeed;
-
-       u32     msg_enable;
-       u32     phy_type;
-       struct mii_if_info mii;
-
-       /* work queue */
-       struct work_struct phy_configure;
-       struct net_device *dev;
-       int     work_pending;
-
-       spinlock_t lock;
-
-#ifdef SMC_USE_PXA_DMA
-       /* DMA needs the physical address of the chip */
-       u_long physaddr;
-#endif
-       void __iomem *base;
-       void __iomem *datacs;
-};
-
 #if SMC_DEBUG > 0
 #define DBG(n, args...)                                        \
        do {                                            \
@@ -1369,9 +1326,11 @@ static irqreturn_t smc_interrupt(int irq, void *dev_id)
        SMC_SET_INT_MASK(mask);
        spin_unlock(&lp->lock);
 
+#ifndef CONFIG_NET_POLL_CONTROLLER
        if (timeout == MAX_IRQ_LOOPS)
                PRINTK("%s: spurious interrupt (mask = 0x%02x)\n",
                       dev->name, mask);
+#endif
        DBG(3, "%s: Interrupt done (%d loops)\n",
               dev->name, MAX_IRQ_LOOPS - timeout);
 
@@ -1818,7 +1777,8 @@ static int __init smc_findirq(void __iomem *ioaddr)
  * o  actually GRAB the irq.
  * o  GRAB the region
  */
-static int __init smc_probe(struct net_device *dev, void __iomem *ioaddr)
+static int __init smc_probe(struct net_device *dev, void __iomem *ioaddr,
+                           unsigned long irq_flags)
 {
        struct smc_local *lp = netdev_priv(dev);
        static int version_printed = 0;
@@ -1984,7 +1944,7 @@ static int __init smc_probe(struct net_device *dev, void __iomem *ioaddr)
        }
 
        /* Grab the IRQ */
-       retval = request_irq(dev->irq, &smc_interrupt, SMC_IRQ_FLAGS, dev->name, dev);
+       retval = request_irq(dev->irq, &smc_interrupt, irq_flags, dev->name, dev);
        if (retval)
                goto err_out;
 
@@ -2166,8 +2126,9 @@ static void smc_release_datacs(struct platform_device *pdev, struct net_device *
 static int smc_drv_probe(struct platform_device *pdev)
 {
        struct net_device *ndev;
-       struct resource *res;
+       struct resource *res, *ires;
        unsigned int __iomem *addr;
+       unsigned long irq_flags = SMC_IRQ_FLAGS;
        int ret;
 
        res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "smc91x-regs");
@@ -2193,12 +2154,17 @@ static int smc_drv_probe(struct platform_device *pdev)
        SET_NETDEV_DEV(ndev, &pdev->dev);
 
        ndev->dma = (unsigned char)-1;
-       ndev->irq = platform_get_irq(pdev, 0);
-       if (ndev->irq < 0) {
+
+       ires = platform_get_resource(pdev, IORESOURCE_IRQ, 0);
+       if (!ires) {
                ret = -ENODEV;
                goto out_free_netdev;
        }
 
+       ndev->irq = ires->start;
+       if (SMC_IRQ_FLAGS == -1)
+               irq_flags = ires->flags & IRQF_TRIGGER_MASK;
+
        ret = smc_request_attrib(pdev);
        if (ret)
                goto out_free_netdev;
@@ -2215,17 +2181,19 @@ static int smc_drv_probe(struct platform_device *pdev)
                goto out_release_attrib;
        }
 
-       platform_set_drvdata(pdev, ndev);
-       ret = smc_probe(ndev, addr);
-       if (ret != 0)
-               goto out_iounmap;
 #ifdef SMC_USE_PXA_DMA
-       else {
+       {
                struct smc_local *lp = netdev_priv(ndev);
+               lp->device = &pdev->dev;
                lp->physaddr = res->start;
        }
 #endif
 
+       platform_set_drvdata(pdev, ndev);
+       ret = smc_probe(ndev, addr, irq_flags);
+       if (ret != 0)
+               goto out_iounmap;
+
        smc_request_datacs(pdev, ndev);
 
        return 0;