drivers/usb/net/kaweth.c: add device "Allied Telesyn AT-USB10 USB Ethernet Adapter"
[safe/jmp/linux-2.6] / drivers / net / ax88796.c
index a4eb6c4..b718dc6 100644 (file)
@@ -25,6 +25,7 @@
 #include <linux/ethtool.h>
 #include <linux/mii.h>
 #include <linux/eeprom_93cx6.h>
+#include <linux/slab.h>
 
 #include <net/ax88796.h>
 
@@ -93,6 +94,7 @@ struct ax_device {
 
        unsigned char            running;
        unsigned char            resume_open;
+       unsigned int             irqflags;
 
        u32                      reg_offsets[0x20];
 };
@@ -474,7 +476,8 @@ static int ax_open(struct net_device *dev)
 
        dev_dbg(&ax->dev->dev, "%s: open\n", dev->name);
 
-       ret = request_irq(dev->irq, ax_ei_interrupt, 0, dev->name, dev);
+       ret = request_irq(dev->irq, ax_ei_interrupt, ax->irqflags,
+                         dev->name, dev);
        if (ret)
                return ret;
 
@@ -731,12 +734,19 @@ static int ax_init_dev(struct net_device *dev, int first_init)
        /* load the mac-address from the device if this is the
         * first time we've initialised */
 
-       if (first_init && ax->plat->flags & AXFLG_MAC_FROMDEV) {
-               ei_outb(E8390_NODMA + E8390_PAGE1 + E8390_STOP,
-                       ei_local->mem + E8390_CMD); /* 0x61 */
+       if (first_init) {
+               if (ax->plat->flags & AXFLG_MAC_FROMDEV) {
+                       ei_outb(E8390_NODMA + E8390_PAGE1 + E8390_STOP,
+                               ei_local->mem + E8390_CMD); /* 0x61 */
+                       for (i = 0; i < ETHER_ADDR_LEN; i++)
+                               dev->dev_addr[i] =
+                                       ei_inb(ioaddr + EN1_PHYS_SHIFT(i));
+               }
 
-               for (i = 0 ; i < ETHER_ADDR_LEN ; i++)
-                       dev->dev_addr[i] = ei_inb(ioaddr + EN1_PHYS_SHIFT(i));
+               if ((ax->plat->flags & AXFLG_MAC_FROMPLATFORM) &&
+                    ax->plat->mac_addr)
+                       memcpy(dev->dev_addr, ax->plat->mac_addr,
+                               ETHER_ADDR_LEN);
        }
 
        ax_reset_8390(dev);
@@ -829,7 +839,7 @@ static int ax_probe(struct platform_device *pdev)
        struct ax_device  *ax;
        struct resource   *res;
        size_t size;
-       int ret;
+       int ret = 0;
 
        dev = ax__alloc_ei_netdev(sizeof(struct ax_device));
        if (dev == NULL)
@@ -850,12 +860,14 @@ static int ax_probe(struct platform_device *pdev)
 
        /* find the platform resources */
 
-       ret  = platform_get_irq(pdev, 0);
-       if (ret < 0) {
+       res = platform_get_resource(pdev, IORESOURCE_IRQ, 0);
+       if (res == NULL) {
                dev_err(&pdev->dev, "no IRQ specified\n");
                goto exit_mem;
        }
-       dev->irq = ret;
+
+       dev->irq = res->start;
+       ax->irqflags = res->flags & IRQF_TRIGGER_MASK;
 
        res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
        if (res == NULL) {
@@ -910,7 +922,7 @@ static int ax_probe(struct platform_device *pdev)
                size = (res->end - res->start) + 1;
 
                ax->mem2 = request_mem_region(res->start, size, pdev->name);
-               if (ax->mem == NULL) {
+               if (ax->mem2 == NULL) {
                        dev_err(&pdev->dev, "cannot reserve registers\n");
                        ret = -ENXIO;
                        goto exit_mem1;