Merge branch 'urgent' of git://git.kernel.org/pub/scm/linux/kernel/git/brodo/pcmcia-2.6
[sfrench/cifs-2.6.git] / drivers / isdn / hisax / hfc4s8s_l1.c
index d852c9d998b2bd51ae022bf870b5062298b3615c..051b44e2556cbf7dc420a83bf93ca884de52ee37 100644 (file)
@@ -25,6 +25,7 @@
 #include <linux/pci.h>
 #include <linux/interrupt.h>
 #include <linux/delay.h>
+#include <linux/slab.h>
 #include <linux/timer.h>
 #include <linux/skbuff.h>
 #include <linux/wait.h>
@@ -199,7 +200,7 @@ typedef struct _hfc4s8s_hw {
 /***************************/
 /* inline function defines */
 /***************************/
-#ifdef CONFIG_HISAX_HFC4S8S_PCIMEM     /* inline functions mempry mapped */
+#ifdef HISAX_HFC4S8S_PCIMEM    /* inline functions memory mapped */
 
 /* memory write and dummy IO read to avoid PCI byte merge problems */
 #define Write_hfc8(a,b,c) {(*((volatile u_char *)(a->membase+b)) = c); inb(a->iobase+4);}
@@ -305,7 +306,7 @@ wait_busy(hfc4s8s_hw * a)
 
 #define PCI_ENA_REGIO  0x01
 
-#endif                         /* CONFIG_HISAX_HFC4S8S_PCIMEM */
+#endif                         /* HISAX_HFC4S8S_PCIMEM */
 
 /******************************************************/
 /* function to read critical counter registers that   */
@@ -724,12 +725,12 @@ rx_d_frame(struct hfc4s8s_l1 *l1p, int ech)
                        } else {
                                /* read errornous D frame */
 
-#ifndef CONFIG_HISAX_HFC4S8S_PCIMEM
+#ifndef HISAX_HFC4S8S_PCIMEM
                                SetRegAddr(l1p->hw, A_FIFO_DATA0);
 #endif
 
                                while (z1 >= 4) {
-#ifdef CONFIG_HISAX_HFC4S8S_PCIMEM
+#ifdef HISAX_HFC4S8S_PCIMEM
                                        Read_hfc32(l1p->hw, A_FIFO_DATA0);
 #else
                                        fRead_hfc32(l1p->hw);
@@ -738,7 +739,7 @@ rx_d_frame(struct hfc4s8s_l1 *l1p, int ech)
                                }
 
                                while (z1--)
-#ifdef CONFIG_HISAX_HFC4S8S_PCIMEM
+#ifdef HISAX_HFC4S8S_PCIMEM
                                        Read_hfc8(l1p->hw, A_FIFO_DATA0);
 #else
                                        fRead_hfc8(l1p->hw);
@@ -752,12 +753,12 @@ rx_d_frame(struct hfc4s8s_l1 *l1p, int ech)
 
                cp = skb->data;
 
-#ifndef CONFIG_HISAX_HFC4S8S_PCIMEM
+#ifndef HISAX_HFC4S8S_PCIMEM
                SetRegAddr(l1p->hw, A_FIFO_DATA0);
 #endif
 
                while (z1 >= 4) {
-#ifdef CONFIG_HISAX_HFC4S8S_PCIMEM
+#ifdef HISAX_HFC4S8S_PCIMEM
                        *((unsigned long *) cp) =
                            Read_hfc32(l1p->hw, A_FIFO_DATA0);
 #else
@@ -768,7 +769,7 @@ rx_d_frame(struct hfc4s8s_l1 *l1p, int ech)
                }
 
                while (z1--)
-#ifdef CONFIG_HISAX_HFC4S8S_PCIMEM
+#ifdef HISAX_HFC4S8S_PCIMEM
                        *cp++ = Read_hfc8(l1p->hw, A_FIFO_DATA0);
 #else
                        *cp++ = fRead_hfc8(l1p->hw);
@@ -858,12 +859,12 @@ rx_b_frame(struct hfc4s8s_btype *bch)
                        wait_busy(l1->hw);
                        return;
                }
-#ifndef CONFIG_HISAX_HFC4S8S_PCIMEM
+#ifndef HISAX_HFC4S8S_PCIMEM
                SetRegAddr(l1->hw, A_FIFO_DATA0);
 #endif
 
                while (z1 >= 4) {
-#ifdef CONFIG_HISAX_HFC4S8S_PCIMEM
+#ifdef HISAX_HFC4S8S_PCIMEM
                        *((unsigned long *) bch->rx_ptr) =
                            Read_hfc32(l1->hw, A_FIFO_DATA0);
 #else
@@ -875,7 +876,7 @@ rx_b_frame(struct hfc4s8s_btype *bch)
                }
 
                while (z1--)
-#ifdef CONFIG_HISAX_HFC4S8S_PCIMEM
+#ifdef HISAX_HFC4S8S_PCIMEM
                        *(bch->rx_ptr++) = Read_hfc8(l1->hw, A_FIFO_DATA0);
 #else
                        *(bch->rx_ptr++) = fRead_hfc8(l1->hw);
@@ -939,12 +940,12 @@ tx_d_frame(struct hfc4s8s_l1 *l1p)
        if ((skb = skb_dequeue(&l1p->d_tx_queue))) {
                cp = skb->data;
                cnt = skb->len;
-#ifndef CONFIG_HISAX_HFC4S8S_PCIMEM
+#ifndef HISAX_HFC4S8S_PCIMEM
                SetRegAddr(l1p->hw, A_FIFO_DATA0);
 #endif
 
                while (cnt >= 4) {
-#ifdef CONFIG_HISAX_HFC4S8S_PCIMEM
+#ifdef HISAX_HFC4S8S_PCIMEM
                        fWrite_hfc32(l1p->hw, A_FIFO_DATA0,
                                     *(unsigned long *) cp);
 #else
@@ -955,7 +956,7 @@ tx_d_frame(struct hfc4s8s_l1 *l1p)
                        cnt -= 4;
                }
 
-#ifdef CONFIG_HISAX_HFC4S8S_PCIMEM
+#ifdef HISAX_HFC4S8S_PCIMEM
                while (cnt--)
                        fWrite_hfc8(l1p->hw, A_FIFO_DATA0, *cp++);
 #else
@@ -1036,11 +1037,11 @@ tx_b_frame(struct hfc4s8s_btype *bch)
                cp = skb->data + bch->tx_cnt;
                bch->tx_cnt += cnt;
 
-#ifndef CONFIG_HISAX_HFC4S8S_PCIMEM
+#ifndef HISAX_HFC4S8S_PCIMEM
                SetRegAddr(l1->hw, A_FIFO_DATA0);
 #endif
                while (cnt >= 4) {
-#ifdef CONFIG_HISAX_HFC4S8S_PCIMEM
+#ifdef HISAX_HFC4S8S_PCIMEM
                        fWrite_hfc32(l1->hw, A_FIFO_DATA0,
                                     *(unsigned long *) cp);
 #else
@@ -1051,7 +1052,7 @@ tx_b_frame(struct hfc4s8s_btype *bch)
                }
 
                while (cnt--)
-#ifdef CONFIG_HISAX_HFC4S8S_PCIMEM
+#ifdef HISAX_HFC4S8S_PCIMEM
                        fWrite_hfc8(l1->hw, A_FIFO_DATA0, *cp++);
 #else
                        fWrite_hfc8(l1->hw, *cp++);
@@ -1083,8 +1084,9 @@ tx_b_frame(struct hfc4s8s_btype *bch)
 /* bottom half handler for interrupt */
 /*************************************/
 static void
-hfc4s8s_bh(hfc4s8s_hw * hw)
+hfc4s8s_bh(struct work_struct *work)
 {
+       hfc4s8s_hw *hw = container_of(work, hfc4s8s_hw, tqueue);
        u_char b;
        struct hfc4s8s_l1 *l1p;
        volatile u_char *fifo_stat;
@@ -1279,7 +1281,7 @@ hfc4s8s_interrupt(int intno, void *dev_id)
        if (!hw || !(hw->mr.r_irq_ctrl & M_GLOB_IRQ_EN))
                return IRQ_NONE;
 
-#ifndef        CONFIG_HISAX_HFC4S8S_PCIMEM
+#ifndef        HISAX_HFC4S8S_PCIMEM
        /* read current selected regsister */
        old_ioreg = GetRegAddr(hw);
 #endif
@@ -1290,7 +1292,7 @@ hfc4s8s_interrupt(int intno, void *dev_id)
        if (!
            (b = (Read_hfc8(hw, R_STATUS) & (M_MISC_IRQSTA | M_FR_IRQSTA)))
 && !hw->mr.r_irq_statech) {
-#ifndef        CONFIG_HISAX_HFC4S8S_PCIMEM
+#ifndef        HISAX_HFC4S8S_PCIMEM
                SetRegAddr(hw, old_ioreg);
 #endif
                return IRQ_NONE;
@@ -1320,7 +1322,7 @@ hfc4s8s_interrupt(int intno, void *dev_id)
        /* queue the request to allow other cards to interrupt */
        schedule_work(&hw->tqueue);
 
-#ifndef        CONFIG_HISAX_HFC4S8S_PCIMEM
+#ifndef        HISAX_HFC4S8S_PCIMEM
        SetRegAddr(hw, old_ioreg);
 #endif
        return IRQ_HANDLED;
@@ -1469,7 +1471,7 @@ static void
 release_pci_ports(hfc4s8s_hw * hw)
 {
        pci_write_config_word(hw->pdev, PCI_COMMAND, 0);
-#ifdef CONFIG_HISAX_HFC4S8S_PCIMEM
+#ifdef HISAX_HFC4S8S_PCIMEM
        if (hw->membase)
                iounmap((void *) hw->membase);
 #else
@@ -1484,7 +1486,7 @@ release_pci_ports(hfc4s8s_hw * hw)
 static void
 enable_pci_ports(hfc4s8s_hw * hw)
 {
-#ifdef CONFIG_HISAX_HFC4S8S_PCIMEM
+#ifdef HISAX_HFC4S8S_PCIMEM
        pci_write_config_word(hw->pdev, PCI_COMMAND, PCI_ENA_MEMIO);
 #else
        pci_write_config_word(hw->pdev, PCI_COMMAND, PCI_ENA_REGIO);
@@ -1550,7 +1552,7 @@ setup_instance(hfc4s8s_hw * hw)
                goto out;
        }
 
-       INIT_WORK(&hw->tqueue, (void *) (void *) hfc4s8s_bh, hw);
+       INIT_WORK(&hw->tqueue, hfc4s8s_bh);
 
        if (request_irq
            (hw->irq, hfc4s8s_interrupt, IRQF_SHARED, hw->card_name, hw)) {
@@ -1559,7 +1561,7 @@ setup_instance(hfc4s8s_hw * hw)
                       hw->irq);
                goto out;
        }
-#ifdef CONFIG_HISAX_HFC4S8S_PCIMEM
+#ifdef HISAX_HFC4S8S_PCIMEM
        printk(KERN_INFO
               "HFC-4S/8S: found PCI card at membase 0x%p, irq %d\n",
               hw->hw_membase, hw->irq);
@@ -1590,11 +1592,10 @@ hfc4s8s_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
        hfc4s8s_param *driver_data = (hfc4s8s_param *) ent->driver_data;
        hfc4s8s_hw *hw;
 
-       if (!(hw = kmalloc(sizeof(hfc4s8s_hw), GFP_ATOMIC))) {
+       if (!(hw = kzalloc(sizeof(hfc4s8s_hw), GFP_ATOMIC))) {
                printk(KERN_ERR "No kmem for HFC-4S/8S card\n");
                return (err);
        }
-       memset(hw, 0, sizeof(hfc4s8s_hw));
 
        hw->pdev = pdev;
        err = pci_enable_device(pdev);
@@ -1613,7 +1614,7 @@ hfc4s8s_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
        hw->irq = pdev->irq;
        hw->iobase = pci_resource_start(pdev, 0);
 
-#ifdef CONFIG_HISAX_HFC4S8S_PCIMEM
+#ifdef HISAX_HFC4S8S_PCIMEM
        hw->hw_membase = (u_char *) pci_resource_start(pdev, 1);
        hw->membase = ioremap((ulong) hw->hw_membase, 256);
 #else