rtc: sh-rtc: Handle rtc_device_register() failure properly.
[safe/jmp/linux-2.6] / drivers / net / e2100.c
index 51c9fa2..6390f51 100644 (file)
@@ -110,7 +110,7 @@ static void e21_get_8390_hdr(struct net_device *dev, struct e8390_pkt_hdr *hdr,
 
 static int e21_close(struct net_device *dev);
 
-\f
+
 /*  Probe for the E2100 series ethercards.  These cards have an 8390 at the
        base address and the station address at both offset 0x10 and 0x18.  I read
        the station address from offset 0x18 to avoid the dataport of NE2000
@@ -124,8 +124,6 @@ static int  __init do_e2100_probe(struct net_device *dev)
        int base_addr = dev->base_addr;
        int irq = dev->irq;
 
-       SET_MODULE_OWNER(dev);
-
        if (base_addr > 0x1ff)          /* Check a single specified location. */
                return e21_probe1(dev, base_addr);
        else if (base_addr != 0)        /* Don't probe at all. */
@@ -140,13 +138,6 @@ static int  __init do_e2100_probe(struct net_device *dev)
        return -ENODEV;
 }
 
-static void cleanup_card(struct net_device *dev)
-{
-       /* NB: e21_close() handles free_irq */
-       iounmap(ei_status.mem);
-       release_region(dev->base_addr, E21_IO_EXTENT);
-}
-
 #ifndef MODULE
 struct net_device * __init e2100_probe(int unit)
 {
@@ -162,12 +153,7 @@ struct net_device * __init e2100_probe(int unit)
        err = do_e2100_probe(dev);
        if (err)
                goto out;
-       err = register_netdev(dev);
-       if (err)
-               goto out1;
        return dev;
-out1:
-       cleanup_card(dev);
 out:
        free_netdev(dev);
        return ERR_PTR(err);
@@ -286,6 +272,9 @@ static int __init e21_probe1(struct net_device *dev, int ioaddr)
 #endif
        NS8390_init(dev, 0);
 
+       retval = register_netdev(dev);
+       if (retval)
+               goto out;
        return 0;
 out:
        release_region(ioaddr, E21_IO_EXTENT);
@@ -364,8 +353,7 @@ e21_block_input(struct net_device *dev, int count, struct sk_buff *skb, int ring
 
        mem_on(ioaddr, shared_mem, (ring_offset>>8));
 
-       /* Packet is always in one chunk -- we can copy + cksum. */
-       eth_io_copy_and_sum(skb, ei_status.mem + (ring_offset & 0xff), count, 0);
+       memcpy_fromio(skb->data, ei_status.mem + (ring_offset & 0xff), count);
 
        mem_off(ioaddr);
 }
@@ -412,7 +400,7 @@ e21_close(struct net_device *dev)
        return 0;
 }
 
-\f
+
 #ifdef MODULE
 #define MAX_E21_CARDS  4       /* Max number of E21 cards per module */
 static struct net_device *dev_e21[MAX_E21_CARDS];
@@ -434,8 +422,8 @@ MODULE_LICENSE("GPL");
 
 /* This is set up so that only a single autoprobe takes place per call.
 ISA device autoprobes on a running machine are not recommended. */
-int
-init_module(void)
+
+int __init init_module(void)
 {
        struct net_device *dev;
        int this_dev, found = 0;
@@ -453,11 +441,8 @@ init_module(void)
                dev->mem_start = mem[this_dev];
                dev->mem_end = xcvr[this_dev];  /* low 4bits = xcvr sel. */
                if (do_e2100_probe(dev) == 0) {
-                       if (register_netdev(dev) == 0) {
-                               dev_e21[found++] = dev;
-                               continue;
-                       }
-                       cleanup_card(dev);
+                       dev_e21[found++] = dev;
+                       continue;
                }
                free_netdev(dev);
                printk(KERN_WARNING "e2100.c: No E2100 card found (i/o = 0x%x).\n", io[this_dev]);
@@ -468,7 +453,14 @@ init_module(void)
        return -ENXIO;
 }
 
-void
+static void cleanup_card(struct net_device *dev)
+{
+       /* NB: e21_close() handles free_irq */
+       iounmap(ei_status.mem);
+       release_region(dev->base_addr, E21_IO_EXTENT);
+}
+
+void __exit
 cleanup_module(void)
 {
        int this_dev;