Merge git://git.kernel.org/pub/scm/linux/kernel/git/brodo/pcmcia-2.6
[safe/jmp/linux-2.6] / drivers / net / pcmcia / 3c574_cs.c
index 1799660..08c4dd8 100644 (file)
@@ -187,14 +187,16 @@ enum Window1 {
 enum Window3 {                 /* Window 3: MAC/config bits. */
        Wn3_Config=0, Wn3_MAC_Ctrl=6, Wn3_Options=8,
 };
-union wn3_config {
-       int i;
-       struct w3_config_fields {
-               unsigned int ram_size:3, ram_width:1, ram_speed:2, rom_size:2;
-               int pad8:8;
-               unsigned int ram_split:2, pad18:2, xcvr:3, pad21:1, autoselect:1;
-               int pad24:7;
-       } u;
+enum wn3_config {
+       Ram_size = 7,
+       Ram_width = 8,
+       Ram_speed = 0x30,
+       Rom_size = 0xc0,
+       Ram_split_shift = 16,
+       Ram_split = 3 << Ram_split_shift,
+       Xcvr_shift = 20,
+       Xcvr = 7 << Xcvr_shift,
+       Autoselect = 0x1000000,
 };
 
 enum Window4 {         /* Window 4: Xcvr/media bits. */
@@ -204,9 +206,8 @@ enum Window4 {              /* Window 4: Xcvr/media bits. */
 #define MEDIA_TP       0x00C0  /* Enable link beat and jabber for 10baseT. */
 
 struct el3_private {
-       dev_link_t link;
+       struct pcmcia_device    *p_dev;
        dev_node_t node;
-       struct net_device_stats stats;
        u16 advertising, partner;               /* NWay media advertisement */
        unsigned char phys;                     /* MII device address */
        unsigned int autoselect:1, default_media:3;     /* Read from the EEPROM/Wn3_Config. */
@@ -225,27 +226,28 @@ static char mii_preamble_required = 0;
 
 /* Index of functions. */
 
-static void tc574_config(dev_link_t *link);
-static void tc574_release(dev_link_t *link);
+static int tc574_config(struct pcmcia_device *link);
+static void tc574_release(struct pcmcia_device *link);
 
-static void mdio_sync(kio_addr_t ioaddr, int bits);
-static int mdio_read(kio_addr_t ioaddr, int phy_id, int location);
-static void mdio_write(kio_addr_t ioaddr, int phy_id, int location, int value);
-static unsigned short read_eeprom(kio_addr_t ioaddr, int index);
+static void mdio_sync(unsigned int ioaddr, int bits);
+static int mdio_read(unsigned int ioaddr, int phy_id, int location);
+static void mdio_write(unsigned int ioaddr, int phy_id, int location,
+                      int value);
+static unsigned short read_eeprom(unsigned int ioaddr, int index);
 static void tc574_wait_for_completion(struct net_device *dev, int cmd);
 
 static void tc574_reset(struct net_device *dev);
 static void media_check(unsigned long arg);
 static int el3_open(struct net_device *dev);
 static int el3_start_xmit(struct sk_buff *skb, struct net_device *dev);
-static irqreturn_t el3_interrupt(int irq, void *dev_id, struct pt_regs *regs);
+static irqreturn_t el3_interrupt(int irq, void *dev_id);
 static void update_stats(struct net_device *dev);
 static struct net_device_stats *el3_get_stats(struct net_device *dev);
 static int el3_rx(struct net_device *dev, int worklimit);
 static int el3_close(struct net_device *dev);
 static void el3_tx_timeout(struct net_device *dev);
 static int el3_ioctl(struct net_device *dev, struct ifreq *rq, int cmd);
-static struct ethtool_ops netdev_ethtool_ops;
+static const struct ethtool_ops netdev_ethtool_ops;
 static void set_rx_mode(struct net_device *dev);
 
 static void tc574_detach(struct pcmcia_device *p_dev);
@@ -256,10 +258,9 @@ static void tc574_detach(struct pcmcia_device *p_dev);
        with Card Services.
 */
 
-static int tc574_attach(struct pcmcia_device *p_dev)
+static int tc574_probe(struct pcmcia_device *link)
 {
        struct el3_private *lp;
-       dev_link_t *link;
        struct net_device *dev;
 
        DEBUG(0, "3c574_attach()\n");
@@ -269,21 +270,19 @@ static int tc574_attach(struct pcmcia_device *p_dev)
        if (!dev)
                return -ENOMEM;
        lp = netdev_priv(dev);
-       link = &lp->link;
        link->priv = dev;
+       lp->p_dev = link;
 
        spin_lock_init(&lp->window_lock);
        link->io.NumPorts1 = 32;
        link->io.Attributes1 = IO_DATA_PATH_WIDTH_16;
-       link->irq.Attributes = IRQ_TYPE_EXCLUSIVE | IRQ_HANDLE_PRESENT;
+       link->irq.Attributes = IRQ_TYPE_DYNAMIC_SHARING|IRQ_HANDLE_PRESENT;
        link->irq.IRQInfo1 = IRQ_LEVEL_ID;
        link->irq.Handler = &el3_interrupt;
        link->irq.Instance = dev;
        link->conf.Attributes = CONF_ENABLE_IRQ;
-       link->conf.Vcc = 50;
        link->conf.IntType = INT_MEMORY_AND_IO;
        link->conf.ConfigIndex = 1;
-       link->conf.Present = PRESENT_OPTION;
 
        /* The EL3-specific entries in the device structure. */
        dev->hard_start_xmit = &el3_start_xmit;
@@ -298,13 +297,7 @@ static int tc574_attach(struct pcmcia_device *p_dev)
        dev->watchdog_timeo = TX_TIMEOUT;
 #endif
 
-       link->handle = p_dev;
-       p_dev->instance = link;
-
-       link->state |= DEV_PRESENT | DEV_CONFIG_PENDING;
-       tc574_config(link);
-
-       return 0;
+       return tc574_config(link);
 } /* tc574_attach */
 
 /*
@@ -316,18 +309,16 @@ static int tc574_attach(struct pcmcia_device *p_dev)
 
 */
 
-static void tc574_detach(struct pcmcia_device *p_dev)
+static void tc574_detach(struct pcmcia_device *link)
 {
-       dev_link_t *link = dev_to_instance(p_dev);
        struct net_device *dev = link->priv;
 
        DEBUG(0, "3c574_detach(0x%p)\n", link);
 
-       if (link->dev)
+       if (link->dev_node)
                unregister_netdev(dev);
 
-       if (link->state & DEV_CONFIG)
-               tc574_release(link);
+       tc574_release(link);
 
        free_netdev(dev);
 } /* tc574_detach */
@@ -343,50 +334,36 @@ static void tc574_detach(struct pcmcia_device *p_dev)
 
 static const char *ram_split[] = {"5:3", "3:1", "1:1", "3:5"};
 
-static void tc574_config(dev_link_t *link)
+static int tc574_config(struct pcmcia_device *link)
 {
-       client_handle_t handle = link->handle;
        struct net_device *dev = link->priv;
        struct el3_private *lp = netdev_priv(dev);
        tuple_t tuple;
-       cisparse_t parse;
-       unsigned short buf[32];
+       __le16 buf[32];
        int last_fn, last_ret, i, j;
-       kio_addr_t ioaddr;
-       u16 *phys_addr;
+       unsigned int ioaddr;
+       __be16 *phys_addr;
        char *cardname;
-       union wn3_config config;
+       __u32 config;
+       DECLARE_MAC_BUF(mac);
 
-       phys_addr = (u16 *)dev->dev_addr;
+       phys_addr = (__be16 *)dev->dev_addr;
 
        DEBUG(0, "3c574_config(0x%p)\n", link);
 
-       tuple.Attributes = 0;
-       tuple.DesiredTuple = CISTPL_CONFIG;
-       CS_CHECK(GetFirstTuple, pcmcia_get_first_tuple(handle, &tuple));
-       tuple.TupleData = (cisdata_t *)buf;
-       tuple.TupleDataMax = 64;
-       tuple.TupleOffset = 0;
-       CS_CHECK(GetTupleData, pcmcia_get_tuple_data(handle, &tuple));
-       CS_CHECK(ParseTuple, pcmcia_parse_tuple(handle, &tuple, &parse));
-       link->conf.ConfigBase = parse.config.base;
-       link->conf.Present = parse.config.rmask[0];
-
-       /* Configure card */
-       link->state |= DEV_CONFIG;
-
        link->io.IOAddrLines = 16;
        for (i = j = 0; j < 0x400; j += 0x20) {
                link->io.BasePort1 = j ^ 0x300;
-               i = pcmcia_request_io(link->handle, &link->io);
-               if (i == CS_SUCCESS) break;
+               i = pcmcia_request_io(link, &link->io);
+               if (i == 0)
+                       break;
        }
-       if (i != CS_SUCCESS) {
-               cs_error(link->handle, RequestIO, i);
+       if (i != 0) {
+               cs_error(link, RequestIO, i);
                goto failed;
        }
-       CS_CHECK(RequestIRQ, pcmcia_request_irq(link->handle, &link->irq));
-       CS_CHECK(RequestConfiguration, pcmcia_request_configuration(link->handle, &link->conf));
+       CS_CHECK(RequestIRQ, pcmcia_request_irq(link, &link->irq));
+       CS_CHECK(RequestConfiguration, pcmcia_request_configuration(link, &link->conf));
 
        dev->irq = link->irq.AssignedIRQ;
        dev->base_addr = link->io.BasePort1;
@@ -396,27 +373,28 @@ static void tc574_config(dev_link_t *link)
        /* The 3c574 normally uses an EEPROM for configuration info, including
           the hardware address.  The future products may include a modem chip
           and put the address in the CIS. */
+       tuple.Attributes = 0;
+       tuple.TupleData = (cisdata_t *)buf;
+       tuple.TupleDataMax = 64;
+       tuple.TupleOffset = 0;
        tuple.DesiredTuple = 0x88;
-       if (pcmcia_get_first_tuple(handle, &tuple) == CS_SUCCESS) {
-               pcmcia_get_tuple_data(handle, &tuple);
+       if (pcmcia_get_first_tuple(link, &tuple) == 0) {
+               pcmcia_get_tuple_data(link, &tuple);
                for (i = 0; i < 3; i++)
-                       phys_addr[i] = htons(buf[i]);
+                       phys_addr[i] = htons(le16_to_cpu(buf[i]));
        } else {
                EL3WINDOW(0);
                for (i = 0; i < 3; i++)
                        phys_addr[i] = htons(read_eeprom(ioaddr, i + 10));
-               if (phys_addr[0] == 0x6060) {
+               if (phys_addr[0] == htons(0x6060)) {
                        printk(KERN_NOTICE "3c574_cs: IO port conflict at 0x%03lx"
                                   "-0x%03lx\n", dev->base_addr, dev->base_addr+15);
                        goto failed;
                }
        }
-       tuple.DesiredTuple = CISTPL_VERS_1;
-       if (pcmcia_get_first_tuple(handle, &tuple) == CS_SUCCESS &&
-               pcmcia_get_tuple_data(handle, &tuple) == CS_SUCCESS &&
-               pcmcia_parse_tuple(handle, &tuple, &parse) == CS_SUCCESS) {
-               cardname = parse.version_1.str + parse.version_1.ofs[1];
-       } else
+       if (link->prod_id[1])
+               cardname = link->prod_id[1];
+       else
                cardname = "3Com 3c574";
 
        {
@@ -426,9 +404,9 @@ static void tc574_config(dev_link_t *link)
                outw(0<<11, ioaddr + RunnerRdCtrl);
                printk(KERN_INFO "  ASIC rev %d,", mcr>>3);
                EL3WINDOW(3);
-               config.i = inl(ioaddr + Wn3_Config);
-               lp->default_media = config.u.xcvr;
-               lp->autoselect = config.u.autoselect;
+               config = inl(ioaddr + Wn3_Config);
+               lp->default_media = (config & Xcvr) >> Xcvr_shift;
+               lp->autoselect = config & Autoselect ? 1 : 0;
        }
 
        init_timer(&lp->media);
@@ -473,33 +451,33 @@ static void tc574_config(dev_link_t *link)
                }
        }
 
-       link->state &= ~DEV_CONFIG_PENDING;
-       link->dev = &lp->node;
-       SET_NETDEV_DEV(dev, &handle_to_dev(handle));
+       link->dev_node = &lp->node;
+       SET_NETDEV_DEV(dev, &handle_to_dev(link));
 
        if (register_netdev(dev) != 0) {
                printk(KERN_NOTICE "3c574_cs: register_netdev() failed\n");
-               link->dev = NULL;
+               link->dev_node = NULL;
                goto failed;
        }
 
        strcpy(lp->node.dev_name, dev->name);
 
-       printk(KERN_INFO "%s: %s at io %#3lx, irq %d, hw_addr ",
-                  dev->name, cardname, dev->base_addr, dev->irq);
-       for (i = 0; i < 6; i++)
-               printk("%02X%s", dev->dev_addr[i], ((i<5) ? ":" : ".\n"));
+       printk(KERN_INFO "%s: %s at io %#3lx, irq %d, "
+              "hw_addr %s.\n",
+              dev->name, cardname, dev->base_addr, dev->irq,
+              print_mac(mac, dev->dev_addr));
        printk(" %dK FIFO split %s Rx:Tx, %sMII interface.\n",
-                  8 << config.u.ram_size, ram_split[config.u.ram_split],
-                  config.u.autoselect ? "autoselect " : "");
+                  8 << config & Ram_size,
+                  ram_split[(config & Ram_split) >> Ram_split_shift],
+                  config & Autoselect ? "autoselect " : "");
 
-       return;
+       return 0;
 
 cs_failed:
-       cs_error(link->handle, last_fn, last_ret);
+       cs_error(link, last_fn, last_ret);
 failed:
        tc574_release(link);
-       return;
+       return -ENODEV;
 
 } /* tc574_config */
 
@@ -509,38 +487,28 @@ failed:
        still open, this will be postponed until it is closed.
 */
 
-static void tc574_release(dev_link_t *link)
+static void tc574_release(struct pcmcia_device *link)
 {
-       pcmcia_disable_device(link->handle);
+       pcmcia_disable_device(link);
 }
 
-static int tc574_suspend(struct pcmcia_device *p_dev)
+static int tc574_suspend(struct pcmcia_device *link)
 {
-       dev_link_t *link = dev_to_instance(p_dev);
        struct net_device *dev = link->priv;
 
-       link->state |= DEV_SUSPEND;
-       if (link->state & DEV_CONFIG) {
-               if (link->open)
-                       netif_device_detach(dev);
-               pcmcia_release_configuration(link->handle);
-       }
+       if (link->open)
+               netif_device_detach(dev);
 
        return 0;
 }
 
-static int tc574_resume(struct pcmcia_device *p_dev)
+static int tc574_resume(struct pcmcia_device *link)
 {
-       dev_link_t *link = dev_to_instance(p_dev);
        struct net_device *dev = link->priv;
 
-       link->state &= ~DEV_SUSPEND;
-       if (link->state & DEV_CONFIG) {
-               pcmcia_request_configuration(link->handle, &link->conf);
-               if (link->open) {
-                       tc574_reset(dev);
-                       netif_device_attach(dev);
-               }
+       if (link->open) {
+               tc574_reset(dev);
+               netif_device_attach(dev);
        }
 
        return 0;
@@ -548,7 +516,7 @@ static int tc574_resume(struct pcmcia_device *p_dev)
 
 static void dump_status(struct net_device *dev)
 {
-       kio_addr_t ioaddr = dev->base_addr;
+       unsigned int ioaddr = dev->base_addr;
        EL3WINDOW(1);
        printk(KERN_INFO "  irq status %04x, rx status %04x, tx status "
                   "%02x, tx free %04x\n", inw(ioaddr+EL3_STATUS),
@@ -577,7 +545,7 @@ static void tc574_wait_for_completion(struct net_device *dev, int cmd)
 /* Read a word from the EEPROM using the regular EEPROM access register.
    Assume that we are in register window zero.
  */
-static unsigned short read_eeprom(kio_addr_t ioaddr, int index)
+static unsigned short read_eeprom(unsigned int ioaddr, int index)
 {
        int timer;
        outw(EEPROM_Read + index, ioaddr + Wn0EepromCmd);
@@ -605,9 +573,9 @@ static unsigned short read_eeprom(kio_addr_t ioaddr, int index)
 
 /* Generate the preamble required for initial synchronization and
    a few older transceivers. */
-static void mdio_sync(kio_addr_t ioaddr, int bits)
+static void mdio_sync(unsigned int ioaddr, int bits)
 {
-       kio_addr_t mdio_addr = ioaddr + Wn4_PhysicalMgmt;
+       unsigned int mdio_addr = ioaddr + Wn4_PhysicalMgmt;
 
        /* Establish sync by sending at least 32 logic ones. */
        while (-- bits >= 0) {
@@ -616,12 +584,12 @@ static void mdio_sync(kio_addr_t ioaddr, int bits)
        }
 }
 
-static int mdio_read(kio_addr_t ioaddr, int phy_id, int location)
+static int mdio_read(unsigned int ioaddr, int phy_id, int location)
 {
        int i;
        int read_cmd = (0xf6 << 10) | (phy_id << 5) | location;
        unsigned int retval = 0;
-       kio_addr_t mdio_addr = ioaddr + Wn4_PhysicalMgmt;
+       unsigned int mdio_addr = ioaddr + Wn4_PhysicalMgmt;
 
        if (mii_preamble_required)
                mdio_sync(ioaddr, 32);
@@ -641,10 +609,10 @@ static int mdio_read(kio_addr_t ioaddr, int phy_id, int location)
        return (retval>>1) & 0xffff;
 }
 
-static void mdio_write(kio_addr_t ioaddr, int phy_id, int location, int value)
+static void mdio_write(unsigned int ioaddr, int phy_id, int location, int value)
 {
        int write_cmd = 0x50020000 | (phy_id << 23) | (location << 18) | value;
-       kio_addr_t mdio_addr = ioaddr + Wn4_PhysicalMgmt;
+       unsigned int mdio_addr = ioaddr + Wn4_PhysicalMgmt;
        int i;
 
        if (mii_preamble_required)
@@ -670,7 +638,7 @@ static void tc574_reset(struct net_device *dev)
 {
        struct el3_private *lp = netdev_priv(dev);
        int i;
-       kio_addr_t ioaddr = dev->base_addr;
+       unsigned int ioaddr = dev->base_addr;
        unsigned long flags;
 
        tc574_wait_for_completion(dev, TotalReset|0x10);
@@ -728,7 +696,7 @@ static void tc574_reset(struct net_device *dev)
        mdio_write(ioaddr, lp->phys, 4, lp->advertising);
        if (!auto_polarity) {
                /* works for TDK 78Q2120 series MII's */
-               int i = mdio_read(ioaddr, lp->phys, 16) | 0x20;
+               i = mdio_read(ioaddr, lp->phys, 16) | 0x20;
                mdio_write(ioaddr, lp->phys, 16, i);
        }
 
@@ -751,9 +719,9 @@ static void tc574_reset(struct net_device *dev)
 static int el3_open(struct net_device *dev)
 {
        struct el3_private *lp = netdev_priv(dev);
-       dev_link_t *link = &lp->link;
+       struct pcmcia_device *link = lp->p_dev;
 
-       if (!DEV_OK(link))
+       if (!pcmcia_dev_present(link))
                return -ENODEV;
        
        link->open++;
@@ -773,12 +741,11 @@ static int el3_open(struct net_device *dev)
 
 static void el3_tx_timeout(struct net_device *dev)
 {
-       struct el3_private *lp = netdev_priv(dev);
-       kio_addr_t ioaddr = dev->base_addr;
+       unsigned int ioaddr = dev->base_addr;
        
        printk(KERN_NOTICE "%s: Transmit timed out!\n", dev->name);
        dump_status(dev);
-       lp->stats.tx_errors++;
+       dev->stats.tx_errors++;
        dev->trans_start = jiffies;
        /* Issue TX_RESET and TX_START commands. */
        tc574_wait_for_completion(dev, TxReset);
@@ -788,8 +755,7 @@ static void el3_tx_timeout(struct net_device *dev)
 
 static void pop_tx_status(struct net_device *dev)
 {
-       struct el3_private *lp = netdev_priv(dev);
-       kio_addr_t ioaddr = dev->base_addr;
+       unsigned int ioaddr = dev->base_addr;
        int i;
     
        /* Clear the Tx status stack. */
@@ -804,7 +770,7 @@ static void pop_tx_status(struct net_device *dev)
                        DEBUG(1, "%s: transmit error: status 0x%02x\n",
                                  dev->name, tx_status);
                        outw(TxEnable, ioaddr + EL3_CMD);
-                       lp->stats.tx_aborted_errors++;
+                       dev->stats.tx_aborted_errors++;
                }
                outb(0x00, ioaddr + TxStatus); /* Pop the status stack. */
        }
@@ -812,7 +778,7 @@ static void pop_tx_status(struct net_device *dev)
 
 static int el3_start_xmit(struct sk_buff *skb, struct net_device *dev)
 {
-       kio_addr_t ioaddr = dev->base_addr;
+       unsigned int ioaddr = dev->base_addr;
        struct el3_private *lp = netdev_priv(dev);
        unsigned long flags;
 
@@ -842,11 +808,11 @@ static int el3_start_xmit(struct sk_buff *skb, struct net_device *dev)
 }
 
 /* The EL3 interrupt handler. */
-static irqreturn_t el3_interrupt(int irq, void *dev_id, struct pt_regs *regs)
+static irqreturn_t el3_interrupt(int irq, void *dev_id)
 {
        struct net_device *dev = (struct net_device *) dev_id;
        struct el3_private *lp = netdev_priv(dev);
-       kio_addr_t ioaddr;
+       unsigned int ioaddr;
        unsigned status;
        int work_budget = max_interrupt_work;
        int handled = 0;
@@ -940,7 +906,7 @@ static void media_check(unsigned long arg)
 {
        struct net_device *dev = (struct net_device *) arg;
        struct el3_private *lp = netdev_priv(dev);
-       kio_addr_t ioaddr = dev->base_addr;
+       unsigned int ioaddr = dev->base_addr;
        unsigned long flags;
        unsigned short /* cable, */ media, partner;
 
@@ -952,7 +918,7 @@ static void media_check(unsigned long arg)
        if ((inw(ioaddr + EL3_STATUS) & IntLatch) && (inb(ioaddr + Timer) == 0xff)) {
                if (!lp->fast_poll)
                        printk(KERN_INFO "%s: interrupt(s) dropped!\n", dev->name);
-               el3_interrupt(dev->irq, lp, NULL);
+               el3_interrupt(dev->irq, dev);
                lp->fast_poll = HZ;
        }
        if (lp->fast_poll) {
@@ -1019,7 +985,7 @@ static struct net_device_stats *el3_get_stats(struct net_device *dev)
                update_stats(dev);
                spin_unlock_irqrestore(&lp->window_lock, flags);
        }
-       return &lp->stats;
+       return &dev->stats;
 }
 
 /*  Update statistics.
@@ -1028,8 +994,7 @@ static struct net_device_stats *el3_get_stats(struct net_device *dev)
  */
 static void update_stats(struct net_device *dev)
 {
-       struct el3_private *lp = netdev_priv(dev);
-       kio_addr_t ioaddr = dev->base_addr;
+       unsigned int ioaddr = dev->base_addr;
        u8 rx, tx, up;
 
        DEBUG(2, "%s: updating the statistics.\n", dev->name);
@@ -1040,15 +1005,15 @@ static void update_stats(struct net_device *dev)
        /* Unlike the 3c509 we need not turn off stats updates while reading. */
        /* Switch to the stats window, and read everything. */
        EL3WINDOW(6);
-       lp->stats.tx_carrier_errors             += inb(ioaddr + 0);
-       lp->stats.tx_heartbeat_errors           += inb(ioaddr + 1);
+       dev->stats.tx_carrier_errors            += inb(ioaddr + 0);
+       dev->stats.tx_heartbeat_errors          += inb(ioaddr + 1);
        /* Multiple collisions. */              inb(ioaddr + 2);
-       lp->stats.collisions                    += inb(ioaddr + 3);
-       lp->stats.tx_window_errors              += inb(ioaddr + 4);
-       lp->stats.rx_fifo_errors                += inb(ioaddr + 5);
-       lp->stats.tx_packets                    += inb(ioaddr + 6);
+       dev->stats.collisions                   += inb(ioaddr + 3);
+       dev->stats.tx_window_errors             += inb(ioaddr + 4);
+       dev->stats.rx_fifo_errors               += inb(ioaddr + 5);
+       dev->stats.tx_packets                   += inb(ioaddr + 6);
        up                                       = inb(ioaddr + 9);
-       lp->stats.tx_packets                    += (up&0x30) << 4;
+       dev->stats.tx_packets                   += (up&0x30) << 4;
        /* Rx packets   */                         inb(ioaddr + 7);
        /* Tx deferrals */                         inb(ioaddr + 8);
        rx                                       = inw(ioaddr + 10);
@@ -1058,15 +1023,14 @@ static void update_stats(struct net_device *dev)
        /* BadSSD */                               inb(ioaddr + 12);
        up                                       = inb(ioaddr + 13);
 
-       lp->stats.tx_bytes                      += tx + ((up & 0xf0) << 12);
+       dev->stats.tx_bytes                     += tx + ((up & 0xf0) << 12);
 
        EL3WINDOW(1);
 }
 
 static int el3_rx(struct net_device *dev, int worklimit)
 {
-       struct el3_private *lp = netdev_priv(dev);
-       kio_addr_t ioaddr = dev->base_addr;
+       unsigned int ioaddr = dev->base_addr;
        short rx_status;
        
        DEBUG(3, "%s: in rx_packet(), status %4.4x, rx_status %4.4x.\n",
@@ -1075,14 +1039,14 @@ static int el3_rx(struct net_device *dev, int worklimit)
                   (--worklimit >= 0)) {
                if (rx_status & 0x4000) { /* Error, update stats. */
                        short error = rx_status & 0x3800;
-                       lp->stats.rx_errors++;
+                       dev->stats.rx_errors++;
                        switch (error) {
-                       case 0x0000:    lp->stats.rx_over_errors++; break;
-                       case 0x0800:    lp->stats.rx_length_errors++; break;
-                       case 0x1000:    lp->stats.rx_frame_errors++; break;
-                       case 0x1800:    lp->stats.rx_length_errors++; break;
-                       case 0x2000:    lp->stats.rx_frame_errors++; break;
-                       case 0x2800:    lp->stats.rx_crc_errors++; break;
+                       case 0x0000:    dev->stats.rx_over_errors++; break;
+                       case 0x0800:    dev->stats.rx_length_errors++; break;
+                       case 0x1000:    dev->stats.rx_frame_errors++; break;
+                       case 0x1800:    dev->stats.rx_length_errors++; break;
+                       case 0x2000:    dev->stats.rx_frame_errors++; break;
+                       case 0x2800:    dev->stats.rx_crc_errors++; break;
                        }
                } else {
                        short pkt_len = rx_status & 0x7ff;
@@ -1093,19 +1057,18 @@ static int el3_rx(struct net_device *dev, int worklimit)
                        DEBUG(3, "  Receiving packet size %d status %4.4x.\n",
                                  pkt_len, rx_status);
                        if (skb != NULL) {
-                               skb->dev = dev;
                                skb_reserve(skb, 2);
                                insl(ioaddr+RX_FIFO, skb_put(skb, pkt_len),
                                                ((pkt_len+3)>>2));
                                skb->protocol = eth_type_trans(skb, dev);
                                netif_rx(skb);
                                dev->last_rx = jiffies;
-                               lp->stats.rx_packets++;
-                               lp->stats.rx_bytes += pkt_len;
+                               dev->stats.rx_packets++;
+                               dev->stats.rx_bytes += pkt_len;
                        } else {
                                DEBUG(1, "%s: couldn't allocate a sk_buff of"
                                          " size %d.\n", dev->name, pkt_len);
-                               lp->stats.rx_dropped++;
+                               dev->stats.rx_dropped++;
                        }
                }
                tc574_wait_for_completion(dev, RxDiscard);
@@ -1120,7 +1083,7 @@ static void netdev_get_drvinfo(struct net_device *dev,
        strcpy(info->driver, "3c574_cs");
 }
 
-static struct ethtool_ops netdev_ethtool_ops = {
+static const struct ethtool_ops netdev_ethtool_ops = {
        .get_drvinfo            = netdev_get_drvinfo,
 };
 
@@ -1128,7 +1091,7 @@ static struct ethtool_ops netdev_ethtool_ops = {
 static int el3_ioctl(struct net_device *dev, struct ifreq *rq, int cmd)
 {
        struct el3_private *lp = netdev_priv(dev);
-       kio_addr_t ioaddr = dev->base_addr;
+       unsigned int ioaddr = dev->base_addr;
        u16 *data = (u16 *)&rq->ifr_ifru;
        int phy = lp->phys & 0x1f;
 
@@ -1182,7 +1145,7 @@ static int el3_ioctl(struct net_device *dev, struct ifreq *rq, int cmd)
 
 static void set_rx_mode(struct net_device *dev)
 {
-       kio_addr_t ioaddr = dev->base_addr;
+       unsigned int ioaddr = dev->base_addr;
 
        if (dev->flags & IFF_PROMISC)
                outw(SetRxFilter | RxStation | RxMulticast | RxBroadcast | RxProm,
@@ -1195,13 +1158,13 @@ static void set_rx_mode(struct net_device *dev)
 
 static int el3_close(struct net_device *dev)
 {
-       kio_addr_t ioaddr = dev->base_addr;
+       unsigned int ioaddr = dev->base_addr;
        struct el3_private *lp = netdev_priv(dev);
-       dev_link_t *link = &lp->link;
+       struct pcmcia_device *link = lp->p_dev;
 
        DEBUG(2, "%s: shutting down ethercard.\n", dev->name);
        
-       if (DEV_OK(link)) {
+       if (pcmcia_dev_present(link)) {
                unsigned long flags;
 
                /* Turn off statistics ASAP.  We update lp->stats below. */
@@ -1240,7 +1203,7 @@ static struct pcmcia_driver tc574_driver = {
        .drv            = {
                .name   = "3c574_cs",
        },
-       .probe          = tc574_attach,
+       .probe          = tc574_probe,
        .remove         = tc574_detach,
        .id_table       = tc574_ids,
        .suspend        = tc574_suspend,