3c574 and 3c589 endianness fixes (.24?)
[safe/jmp/linux-2.6] / drivers / net / pcmcia / 3c574_cs.c
index 4611469..2881777 100644 (file)
@@ -238,14 +238,14 @@ 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);
@@ -274,14 +274,13 @@ static int tc574_probe(struct pcmcia_device *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.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;
@@ -296,7 +295,6 @@ static int tc574_probe(struct pcmcia_device *link)
        dev->watchdog_timeo = TX_TIMEOUT;
 #endif
 
-       link->state |= DEV_PRESENT | DEV_CONFIG_PENDING;
        return tc574_config(link);
 } /* tc574_attach */
 
@@ -318,8 +316,7 @@ static void tc574_detach(struct pcmcia_device *link)
        if (link->dev_node)
                unregister_netdev(dev);
 
-       if (link->state & DEV_CONFIG)
-               tc574_release(link);
+       tc574_release(link);
 
        free_netdev(dev);
 } /* tc574_detach */
@@ -340,32 +337,18 @@ static int tc574_config(struct pcmcia_device *link)
        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;
+       __be16 *phys_addr;
        char *cardname;
        union wn3_config 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(link, &tuple));
-       tuple.TupleData = (cisdata_t *)buf;
-       tuple.TupleDataMax = 64;
-       tuple.TupleOffset = 0;
-       CS_CHECK(GetTupleData, pcmcia_get_tuple_data(link, &tuple));
-       CS_CHECK(ParseTuple, pcmcia_parse_tuple(link, &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;
@@ -387,27 +370,28 @@ static int tc574_config(struct pcmcia_device *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(link, &tuple) == CS_SUCCESS) {
                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(link, &tuple) == CS_SUCCESS &&
-               pcmcia_get_tuple_data(link, &tuple) == CS_SUCCESS &&
-               pcmcia_parse_tuple(link, &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";
 
        {
@@ -464,7 +448,6 @@ static int tc574_config(struct pcmcia_device *link)
                }
        }
 
-       link->state &= ~DEV_CONFIG_PENDING;
        link->dev_node = &lp->node;
        SET_NETDEV_DEV(dev, &handle_to_dev(link));
 
@@ -476,10 +459,10 @@ static int tc574_config(struct pcmcia_device *link)
 
        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 " : "");
@@ -509,7 +492,7 @@ static int tc574_suspend(struct pcmcia_device *link)
 {
        struct net_device *dev = link->priv;
 
-       if ((link->state & DEV_CONFIG) && (link->open))
+       if (link->open)
                netif_device_detach(dev);
 
        return 0;
@@ -519,7 +502,7 @@ static int tc574_resume(struct pcmcia_device *link)
 {
        struct net_device *dev = link->priv;
 
-       if ((link->state & DEV_CONFIG) && (link->open)) {
+       if (link->open) {
                tc574_reset(dev);
                netif_device_attach(dev);
        }
@@ -734,7 +717,7 @@ static int el3_open(struct net_device *dev)
        struct el3_private *lp = netdev_priv(dev);
        struct pcmcia_device *link = lp->p_dev;
 
-       if (!DEV_OK(link))
+       if (!pcmcia_dev_present(link))
                return -ENODEV;
        
        link->open++;
@@ -823,7 +806,7 @@ 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);
@@ -933,7 +916,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) {
@@ -1074,7 +1057,6 @@ 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));
@@ -1101,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,
 };
 
@@ -1182,7 +1164,7 @@ static int el3_close(struct net_device *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. */