staging: Add framebuffer driver for XGI chipsets
[safe/jmp/linux-2.6] / drivers / net / pcmcia / xirc2ps_cs.c
index f75ac71..b6c3644 100644 (file)
@@ -297,31 +297,9 @@ static void xirc2ps_detach(struct pcmcia_device *p_dev);
 
 static irqreturn_t xirc2ps_interrupt(int irq, void *dev_id);
 
-/****************
- * A linked list of "instances" of the device.  Each actual
- * PCMCIA card corresponds to one device instance, and is described
- * by one struct pcmcia_device structure (defined in ds.h).
- *
- * You may not want to use a linked list for this -- for example, the
- * memory card driver uses an array of struct pcmcia_device pointers, where minor
- * device numbers are used to derive the corresponding array index.
- */
-
-/****************
- * A driver needs to provide a dev_node_t structure for each device
- * on a card.  In some cases, there is only one device per card (for
- * example, ethernet cards, modems).  In other cases, there may be
- * many actual or logical devices (SCSI adapters, memory cards with
- * multiple partitions).  The dev_node_t structures need to be kept
- * in a linked list starting at the 'dev' field of a struct pcmcia_device
- * structure.  We allocate them in the card's private data structure,
- * because they generally can't be allocated dynamically.
- */
-
 typedef struct local_info_t {
        struct net_device       *dev;
        struct pcmcia_device    *p_dev;
-    dev_node_t node;
 
     int card_type;
     int probe_port;
@@ -385,9 +363,9 @@ PrintRegisters(struct net_device *dev)
            printk("\n");
        }
        for (page=0x40 ; page <= 0x5f; page++) {
-           if (page == 0x43 || (page >= 0x46 && page <= 0x4f)
-               || (page >= 0x51 && page <=0x5e))
-               continue;
+               if (page == 0x43 || (page >= 0x46 && page <= 0x4f) ||
+                   (page >= 0x51 && page <=0x5e))
+                       continue;
            printk(KDBG_XIRC "Register page %2x: ", page);
            SelectPage(page);
            for (i = 8; i < 16; i++)
@@ -555,8 +533,6 @@ xirc2ps_probe(struct pcmcia_device *link)
     link->conf.Attributes = CONF_ENABLE_IRQ;
     link->conf.IntType = INT_MEMORY_AND_IO;
     link->conf.ConfigIndex = 1;
-    link->irq.Handler = xirc2ps_interrupt;
-    link->irq.Instance = dev;
 
     /* Fill in card specific entries */
     dev->netdev_ops = &netdev_ops;
@@ -581,8 +557,7 @@ xirc2ps_detach(struct pcmcia_device *link)
 
     dev_dbg(&link->dev, "detach\n");
 
-    if (link->dev_node)
-       unregister_netdev(dev);
+    unregister_netdev(dev);
 
     xirc2ps_release(link);
 
@@ -835,8 +810,6 @@ xirc2ps_config(struct pcmcia_device * link)
 
     link->io.IOAddrLines =10;
     link->io.Attributes1 = IO_DATA_PATH_WIDTH_16;
-    link->irq.Attributes = IRQ_HANDLE_PRESENT;
-    link->irq.IRQInfo1 = IRQ_LEVEL_ID;
     if (local->modem) {
        int pass;
 
@@ -844,7 +817,6 @@ xirc2ps_config(struct pcmcia_device * link)
            link->conf.Attributes |= CONF_ENABLE_SPKR;
            link->conf.Status |= CCSR_AUDIO_ENA;
        }
-       link->irq.Attributes |= IRQ_TYPE_DYNAMIC_SHARING|IRQ_FIRST_SHARED ;
        link->io.NumPorts2 = 8;
        link->io.Attributes2 = IO_DATA_PATH_WIDTH_8;
        if (local->dingo) {
@@ -869,7 +841,6 @@ xirc2ps_config(struct pcmcia_device * link)
        }
        printk(KNOT_XIRC "no ports available\n");
     } else {
-       link->irq.Attributes |= IRQ_TYPE_DYNAMIC_SHARING;
        link->io.NumPorts1 = 16;
        for (ioaddr = 0x300; ioaddr < 0x400; ioaddr += 0x10) {
            link->io.BasePort1 = ioaddr;
@@ -888,7 +859,7 @@ xirc2ps_config(struct pcmcia_device * link)
      * Now allocate an interrupt line. Note that this does not
      * actually assign a handler to the interrupt.
      */
-    if ((err=pcmcia_request_irq(link, &link->irq)))
+    if ((err=pcmcia_request_irq(link, xirc2ps_interrupt)))
        goto config_error;
 
     /****************
@@ -985,23 +956,19 @@ xirc2ps_config(struct pcmcia_device * link)
        printk(KNOT_XIRC "invalid if_port requested\n");
 
     /* we can now register the device with the net subsystem */
-    dev->irq = link->irq.AssignedIRQ;
+    dev->irq = link->irq;
     dev->base_addr = link->io.BasePort1;
 
     if (local->dingo)
        do_reset(dev, 1); /* a kludge to make the cem56 work */
 
-    link->dev_node = &local->node;
     SET_NETDEV_DEV(dev, &link->dev);
 
     if ((err=register_netdev(dev))) {
        printk(KNOT_XIRC "register_netdev() failed\n");
-       link->dev_node = NULL;
        goto config_error;
     }
 
-    strcpy(local->node.dev_name, dev->name);
-
     /* give some infos about the hardware */
     printk(KERN_INFO "%s: %s: port %#3lx, irq %d, hwaddr %pM\n",
           dev->name, local->manf_str,(u_long)dev->base_addr, (int)dev->irq,
@@ -1298,7 +1265,7 @@ xirc2ps_tx_timeout_task(struct work_struct *work)
        struct net_device *dev = local->dev;
     /* reset the card */
     do_reset(dev,1);
-    dev->trans_start = jiffies;
+    dev->trans_start = jiffies; /* prevent tx timeout */
     netif_wake_queue(dev);
 }
 
@@ -1361,53 +1328,68 @@ do_start_xmit(struct sk_buff *skb, struct net_device *dev)
        PutByte(XIRCREG_CR, TransmitPacket|EnableIntr);
 
     dev_kfree_skb (skb);
-    dev->trans_start = jiffies;
     dev->stats.tx_bytes += pktlen;
     netif_start_queue(dev);
     return NETDEV_TX_OK;
 }
 
+struct set_address_info {
+       int reg_nr;
+       int page_nr;
+       int mohawk;
+       unsigned int ioaddr;
+};
+
+static void set_address(struct set_address_info *sa_info, char *addr)
+{
+       unsigned int ioaddr = sa_info->ioaddr;
+       int i;
+
+       for (i = 0; i < 6; i++) {
+               if (sa_info->reg_nr > 15) {
+                       sa_info->reg_nr = 8;
+                       sa_info->page_nr++;
+                       SelectPage(sa_info->page_nr);
+               }
+               if (sa_info->mohawk)
+                       PutByte(sa_info->reg_nr++, addr[5 - i]);
+               else
+                       PutByte(sa_info->reg_nr++, addr[i]);
+       }
+}
+
 /****************
  * Set all addresses: This first one is the individual address,
  * the next 9 addresses are taken from the multicast list and
  * the rest is filled with the individual address.
  */
-static void
-set_addresses(struct net_device *dev)
+static void set_addresses(struct net_device *dev)
 {
-    unsigned int ioaddr = dev->base_addr;
-    local_info_t *lp = netdev_priv(dev);
-    struct dev_mc_list *dmi = dev->mc_list;
-    unsigned char *addr;
-    int i,j,k,n;
-
-    SelectPage(k=0x50);
-    for (i=0,j=8,n=0; ; i++, j++) {
-       if (i > 5) {
-           if (++n > 9)
-               break;
-           i = 0;
-           if (n > 1 && n <= dev->mc_count && dmi) {
-                dmi = dmi->next;
-           }
-       }
-       if (j > 15) {
-           j = 8;
-           k++;
-           SelectPage(k);
-       }
-
-       if (n && n <= dev->mc_count && dmi)
-           addr = dmi->dmi_addr;
-       else
-           addr = dev->dev_addr;
+       unsigned int ioaddr = dev->base_addr;
+       local_info_t *lp = netdev_priv(dev);
+       struct netdev_hw_addr *ha;
+       struct set_address_info sa_info;
+       int i;
 
-       if (lp->mohawk)
-           PutByte(j, addr[5-i]);
-       else
-           PutByte(j, addr[i]);
-    }
-    SelectPage(0);
+       /*
+        * Setup the info structure so that by first set_address call it will do
+        * SelectPage with the right page number. Hence these ones here.
+        */
+       sa_info.reg_nr = 15 + 1;
+       sa_info.page_nr = 0x50 - 1;
+       sa_info.mohawk = lp->mohawk;
+       sa_info.ioaddr = ioaddr;
+
+       set_address(&sa_info, dev->dev_addr);
+       i = 0;
+       netdev_for_each_mc_addr(ha, dev) {
+               if (i++ == 9)
+                       break;
+               set_address(&sa_info, ha->addr);
+       }
+       while (i++ < 9)
+               set_address(&sa_info, dev->dev_addr);
+       SelectPage(0);
 }
 
 /****************
@@ -1427,9 +1409,9 @@ set_multicast_list(struct net_device *dev)
 
     if (dev->flags & IFF_PROMISC) { /* snoop */
        PutByte(XIRCREG42_SWC1, value | 0x06); /* set MPE and PME */
-    } else if (dev->mc_count > 9 || (dev->flags & IFF_ALLMULTI)) {
+    } else if (netdev_mc_count(dev) > 9 || (dev->flags & IFF_ALLMULTI)) {
        PutByte(XIRCREG42_SWC1, value | 0x02); /* set MPE */
-    } else if (dev->mc_count) {
+    } else if (!netdev_mc_empty(dev)) {
        /* the chip can filter 9 addresses perfectly */
        PutByte(XIRCREG42_SWC1, value | 0x01);
        SelectPage(0x40);