]> pilppa.org Git - linux-2.6-omap-h63xx.git/blobdiff - drivers/net/sun3lance.c
ide: add ide_dev_is_sata() helper (take 2)
[linux-2.6-omap-h63xx.git] / drivers / net / sun3lance.c
index 61a832ce7ccfdc85642cfc0bd1e7f54dd115f1dc..f1548c033327d9a3ae3d9c50438de721d7663906 100644 (file)
@@ -38,6 +38,7 @@ static char *version = "sun3lance.c: v1.2 1/12/2001  Sam Creasey (sammy@sammy.ne
 #include <linux/skbuff.h>
 #include <linux/bitops.h>
 
+#include <asm/cacheflush.h>
 #include <asm/setup.h>
 #include <asm/irq.h>
 #include <asm/io.h>
@@ -237,7 +238,7 @@ static int lance_probe( struct net_device *dev);
 static int lance_open( struct net_device *dev );
 static void lance_init_ring( struct net_device *dev );
 static int lance_start_xmit( struct sk_buff *skb, struct net_device *dev );
-static irqreturn_t lance_interrupt( int irq, void *dev_id, struct pt_regs *fp );
+static irqreturn_t lance_interrupt( int irq, void *dev_id);
 static int lance_rx( struct net_device *dev );
 static int lance_close( struct net_device *dev );
 static struct net_device_stats *lance_get_stats( struct net_device *dev );
@@ -286,7 +287,7 @@ struct net_device * __init sun3lance_probe(int unit)
 
 out1:
 #ifdef CONFIG_SUN3
-       iounmap((void *)dev->base_addr);
+       iounmap((void __iomem *)dev->base_addr);
 #endif
 out:
        free_netdev(dev);
@@ -326,7 +327,7 @@ static int __init lance_probe( struct net_device *dev)
                ioaddr_probe[1] = tmp2;
 
 #ifdef CONFIG_SUN3
-               iounmap((void *)ioaddr);
+               iounmap((void __iomem *)ioaddr);
 #endif
                return 0;
        }
@@ -335,13 +336,27 @@ static int __init lance_probe( struct net_device *dev)
 
        /* XXX - leak? */
        MEM = dvma_malloc_align(sizeof(struct lance_memory), 0x10000);
+       if (MEM == NULL) {
+#ifdef CONFIG_SUN3
+               iounmap((void __iomem *)ioaddr);
+#endif
+               printk(KERN_WARNING "SUN3 Lance couldn't allocate DVMA memory\n");
+               return 0;
+       }
 
        lp->iobase = (volatile unsigned short *)ioaddr;
        dev->base_addr = (unsigned long)ioaddr; /* informational only */
 
        REGA(CSR0) = CSR0_STOP;
 
-       request_irq(LANCE_IRQ, lance_interrupt, IRQF_DISABLED, "SUN3 Lance", dev);
+       if (request_irq(LANCE_IRQ, lance_interrupt, IRQF_DISABLED, "SUN3 Lance", dev) < 0) {
+#ifdef CONFIG_SUN3
+               iounmap((void __iomem *)ioaddr);
+#endif
+               dvma_free((void *)MEM);
+               printk(KERN_WARNING "SUN3 Lance unable to allocate IRQ\n");
+               return 0;
+       }
        dev->irq = (unsigned short)LANCE_IRQ;
 
 
@@ -614,7 +629,7 @@ static int lance_start_xmit( struct sk_buff *skb, struct net_device *dev )
        head->length = (-len) | 0xf000;
        head->misc = 0;
 
-       memcpy( PKTBUF_ADDR(head), (void *)skb->data, skb->len );
+       skb_copy_from_linear_data(skb, PKTBUF_ADDR(head), skb->len);
        if (len != skb->len)
                memset(PKTBUF_ADDR(head) + skb->len, 0, len-skb->len);
 
@@ -642,7 +657,7 @@ static int lance_start_xmit( struct sk_buff *skb, struct net_device *dev )
 
 /* The LANCE interrupt handler. */
 
-static irqreturn_t lance_interrupt( int irq, void *dev_id, struct pt_regs *fp)
+static irqreturn_t lance_interrupt( int irq, void *dev_id)
 {
        struct net_device *dev = dev_id;
        struct lance_private *lp = netdev_priv(dev);
@@ -836,13 +851,11 @@ static int lance_rx( struct net_device *dev )
                                }
 
 
-                               skb->dev = dev;
                                skb_reserve( skb, 2 );  /* 16 byte align */
                                skb_put( skb, pkt_len );        /* Make room */
-//                             memcpy( skb->data, PKTBUF_ADDR(head), pkt_len );
-                               eth_copy_and_sum(skb,
+                               skb_copy_to_linear_data(skb,
                                                 PKTBUF_ADDR(head),
-                                                pkt_len, 0);
+                                                pkt_len);
 
                                skb->protocol = eth_type_trans( skb, dev );
                                netif_rx( skb );
@@ -944,7 +957,7 @@ static void set_multicast_list( struct net_device *dev )
 
 static struct net_device *sun3lance_dev;
 
-int init_module(void)
+int __init init_module(void)
 {
        sun3lance_dev = sun3lance_probe(-1);
        if (IS_ERR(sun3lance_dev))
@@ -952,11 +965,11 @@ int init_module(void)
        return 0;
 }
 
-void cleanup_module(void)
+void __exit cleanup_module(void)
 {
        unregister_netdev(sun3lance_dev);
 #ifdef CONFIG_SUN3
-       iounmap((void *)sun3lance_dev->base_addr);
+       iounmap((void __iomem *)sun3lance_dev->base_addr);
 #endif
        free_netdev(sun3lance_dev);
 }