fedora core 6 1.2949 + vserver 2.2.0
[linux-2.6.git] / drivers / net / wan / pc300_drv.c
index 29b8268..62184de 100644 (file)
@@ -284,13 +284,14 @@ static void rx_dma_buf_pt_init(pc300_t *, int);
 static void rx_dma_buf_init(pc300_t *, int);
 static void tx_dma_buf_check(pc300_t *, int);
 static void rx_dma_buf_check(pc300_t *, int);
-static irqreturn_t cpc_intr(int, void *, struct pt_regs *);
+static irqreturn_t cpc_intr(int, void *);
 static struct net_device_stats *cpc_get_stats(struct net_device *);
 static int clock_rate_calc(uclong, uclong, int *);
 static uclong detect_ram(pc300_t *);
 static void plx_init(pc300_t *);
 static void cpc_trace(struct net_device *, struct sk_buff *, char);
 static int cpc_attach(struct net_device *, unsigned short, unsigned short);
+static int cpc_close(struct net_device *dev);
 
 #ifdef CONFIG_PC300_MLPPP
 void cpc_tty_init(pc300dev_t * dev);
@@ -307,7 +308,7 @@ static void tx_dma_buf_pt_init(pc300_t * card, int ch)
 {
        int i;
        int ch_factor = ch * N_DMA_TX_BUF;
-       volatile pcsca_bd_t *ptdescr = (pcsca_bd_t *) (card->hw.rambase
+       volatile pcsca_bd_t __iomem *ptdescr = (card->hw.rambase
                                       + DMA_TX_BD_BASE + ch_factor * sizeof(pcsca_bd_t));
 
        for (i = 0; i < N_DMA_TX_BUF; i++, ptdescr++) {
@@ -322,7 +323,7 @@ static void tx_dma_buf_init(pc300_t * card, int ch)
 {
        int i;
        int ch_factor = ch * N_DMA_TX_BUF;
-       volatile pcsca_bd_t *ptdescr = (pcsca_bd_t *) (card->hw.rambase
+       volatile pcsca_bd_t __iomem *ptdescr = (card->hw.rambase
                               + DMA_TX_BD_BASE + ch_factor * sizeof(pcsca_bd_t));
 
        for (i = 0; i < N_DMA_TX_BUF; i++, ptdescr++) {
@@ -337,7 +338,7 @@ static void rx_dma_buf_pt_init(pc300_t * card, int ch)
 {
        int i;
        int ch_factor = ch * N_DMA_RX_BUF;
-       volatile pcsca_bd_t *ptdescr = (pcsca_bd_t *) (card->hw.rambase
+       volatile pcsca_bd_t __iomem *ptdescr = (card->hw.rambase
                                       + DMA_RX_BD_BASE + ch_factor * sizeof(pcsca_bd_t));
 
        for (i = 0; i < N_DMA_RX_BUF; i++, ptdescr++) {
@@ -352,7 +353,7 @@ static void rx_dma_buf_init(pc300_t * card, int ch)
 {
        int i;
        int ch_factor = ch * N_DMA_RX_BUF;
-       volatile pcsca_bd_t *ptdescr = (pcsca_bd_t *) (card->hw.rambase
+       volatile pcsca_bd_t __iomem *ptdescr = (card->hw.rambase
                                       + DMA_RX_BD_BASE + ch_factor * sizeof(pcsca_bd_t));
 
        for (i = 0; i < N_DMA_RX_BUF; i++, ptdescr++) {
@@ -365,7 +366,7 @@ static void rx_dma_buf_init(pc300_t * card, int ch)
 
 static void tx_dma_buf_check(pc300_t * card, int ch)
 {
-       volatile pcsca_bd_t *ptdescr;
+       volatile pcsca_bd_t __iomem *ptdescr;
        int i;
        ucshort first_bd = card->chan[ch].tx_first_bd;
        ucshort next_bd = card->chan[ch].tx_next_bd;
@@ -374,13 +375,13 @@ static void tx_dma_buf_check(pc300_t * card, int ch)
               first_bd, TX_BD_ADDR(ch, first_bd),
               next_bd, TX_BD_ADDR(ch, next_bd));
        for (i = first_bd,
-            ptdescr = (pcsca_bd_t *) (card->hw.rambase + TX_BD_ADDR(ch, first_bd));
+            ptdescr = (card->hw.rambase + TX_BD_ADDR(ch, first_bd));
             i != ((next_bd + 1) & (N_DMA_TX_BUF - 1));
             i = (i + 1) & (N_DMA_TX_BUF - 1), 
-                ptdescr = (pcsca_bd_t *) (card->hw.rambase + TX_BD_ADDR(ch, i))) {
-               printk("\n CH%d TX%d: next=0x%lx, ptbuf=0x%lx, ST=0x%x, len=%d",
-                      ch, i, (uclong) cpc_readl(&ptdescr->next),
-                      (uclong) cpc_readl(&ptdescr->ptbuf),
+                ptdescr = (card->hw.rambase + TX_BD_ADDR(ch, i))) {
+               printk("\n CH%d TX%d: next=0x%x, ptbuf=0x%x, ST=0x%x, len=%d",
+                      ch, i, cpc_readl(&ptdescr->next),
+                      cpc_readl(&ptdescr->ptbuf),
                       cpc_readb(&ptdescr->status), cpc_readw(&ptdescr->len));
        }
        printk("\n");
@@ -390,7 +391,7 @@ static void tx_dma_buf_check(pc300_t * card, int ch)
 /* Show all TX buffer descriptors */
 static void tx1_dma_buf_check(pc300_t * card, int ch)
 {
-       volatile pcsca_bd_t *ptdescr;
+       volatile pcsca_bd_t __iomem *ptdescr;
        int i;
        ucshort first_bd = card->chan[ch].tx_first_bd;
        ucshort next_bd = card->chan[ch].tx_next_bd;
@@ -400,14 +401,14 @@ static void tx1_dma_buf_check(pc300_t * card, int ch)
        printk("#CH%d: f_bd = %d(0x%08x), n_bd = %d(0x%08x)\n", ch,
               first_bd, TX_BD_ADDR(ch, first_bd),
               next_bd, TX_BD_ADDR(ch, next_bd));
-       printk("TX_CDA=0x%08lx, TX_EDA=0x%08lx\n",
-              (uclong) cpc_readl(scabase + DTX_REG(CDAL, ch)),
-              (uclong) cpc_readl(scabase + DTX_REG(EDAL, ch)));
+       printk("TX_CDA=0x%08x, TX_EDA=0x%08x\n",
+              cpc_readl(scabase + DTX_REG(CDAL, ch)),
+              cpc_readl(scabase + DTX_REG(EDAL, ch)));
        for (i = 0; i < N_DMA_TX_BUF; i++) {
-               ptdescr = (pcsca_bd_t *) (card->hw.rambase + TX_BD_ADDR(ch, i));
-               printk("\n CH%d TX%d: next=0x%lx, ptbuf=0x%lx, ST=0x%x, len=%d",
-                      ch, i, (uclong) cpc_readl(&ptdescr->next),
-                      (uclong) cpc_readl(&ptdescr->ptbuf),
+               ptdescr = (card->hw.rambase + TX_BD_ADDR(ch, i));
+               printk("\n CH%d TX%d: next=0x%x, ptbuf=0x%x, ST=0x%x, len=%d",
+                      ch, i, cpc_readl(&ptdescr->next),
+                      cpc_readl(&ptdescr->ptbuf),
                       cpc_readb(&ptdescr->status), cpc_readw(&ptdescr->len));
        }
        printk("\n");
@@ -416,7 +417,7 @@ static void tx1_dma_buf_check(pc300_t * card, int ch)
                         
 static void rx_dma_buf_check(pc300_t * card, int ch)
 {
-       volatile pcsca_bd_t *ptdescr;
+       volatile pcsca_bd_t __iomem *ptdescr;
        int i;
        ucshort first_bd = card->chan[ch].rx_first_bd;
        ucshort last_bd = card->chan[ch].rx_last_bd;
@@ -424,27 +425,27 @@ static void rx_dma_buf_check(pc300_t * card, int ch)
 
        ch_factor = ch * N_DMA_RX_BUF;
        printk("#CH%d: f_bd = %d, l_bd = %d\n", ch, first_bd, last_bd);
-       for (i = 0, ptdescr = (pcsca_bd_t *) (card->hw.rambase +
+       for (i = 0, ptdescr = (card->hw.rambase +
                                              DMA_RX_BD_BASE + ch_factor * sizeof(pcsca_bd_t));
             i < N_DMA_RX_BUF; i++, ptdescr++) {
                if (cpc_readb(&ptdescr->status) & DST_OSB)
-                       printk ("\n CH%d RX%d: next=0x%lx, ptbuf=0x%lx, ST=0x%x, len=%d",
-                                ch, i, (uclong) cpc_readl(&ptdescr->next),
-                                (uclong) cpc_readl(&ptdescr->ptbuf),
+                       printk ("\n CH%d RX%d: next=0x%x, ptbuf=0x%x, ST=0x%x, len=%d",
+                                ch, i, cpc_readl(&ptdescr->next),
+                                cpc_readl(&ptdescr->ptbuf),
                                 cpc_readb(&ptdescr->status),
                                 cpc_readw(&ptdescr->len));
        }
        printk("\n");
 }
 
-int dma_get_rx_frame_size(pc300_t * card, int ch)
+static int dma_get_rx_frame_size(pc300_t * card, int ch)
 {
-       volatile pcsca_bd_t *ptdescr;
+       volatile pcsca_bd_t __iomem *ptdescr;
        ucshort first_bd = card->chan[ch].rx_first_bd;
        int rcvd = 0;
        volatile ucchar status;
 
-       ptdescr = (pcsca_bd_t *)(card->hw.rambase + RX_BD_ADDR(ch, first_bd));
+       ptdescr = (card->hw.rambase + RX_BD_ADDR(ch, first_bd));
        while ((status = cpc_readb(&ptdescr->status)) & DST_OSB) {
                rcvd += cpc_readw(&ptdescr->len);
                first_bd = (first_bd + 1) & (N_DMA_RX_BUF - 1);
@@ -453,7 +454,7 @@ int dma_get_rx_frame_size(pc300_t * card, int ch)
                        * (dma_buf_read will clean the buffer descriptors in this case). */
                        return (rcvd);
                }
-               ptdescr = (pcsca_bd_t *)(card->hw.rambase + cpc_readl(&ptdescr->next));
+               ptdescr = (card->hw.rambase + cpc_readl(&ptdescr->next));
        }
        return (-1);
 }
@@ -462,10 +463,10 @@ int dma_get_rx_frame_size(pc300_t * card, int ch)
  * dma_buf_write: writes a frame to the Tx DMA buffers
  * NOTE: this function writes one frame at a time.
  */
-int dma_buf_write(pc300_t * card, int ch, ucchar * ptdata, int len)
+static int dma_buf_write(pc300_t * card, int ch, ucchar * ptdata, int len)
 {
        int i, nchar;
-       volatile pcsca_bd_t *ptdescr;
+       volatile pcsca_bd_t __iomem *ptdescr;
        int tosend = len;
        ucchar nbuf = ((len - 1) / BD_DEF_LEN) + 1;
 
@@ -474,11 +475,11 @@ int dma_buf_write(pc300_t * card, int ch, ucchar * ptdata, int len)
        }
 
        for (i = 0; i < nbuf; i++) {
-               ptdescr = (pcsca_bd_t *) (card->hw.rambase +
+               ptdescr = (card->hw.rambase +
                                          TX_BD_ADDR(ch, card->chan[ch].tx_next_bd));
                nchar = cpc_min(BD_DEF_LEN, tosend);
                if (cpc_readb(&ptdescr->status) & DST_OSB) {
-                       memcpy_toio((void *)(card->hw.rambase + cpc_readl(&ptdescr->ptbuf)),
+                       memcpy_toio((card->hw.rambase + cpc_readl(&ptdescr->ptbuf)),
                                    &ptdata[len - tosend], nchar);
                        cpc_writew(&ptdescr->len, nchar);
                        card->chan[ch].nfree_tx_bd--;
@@ -503,15 +504,15 @@ int dma_buf_write(pc300_t * card, int ch, ucchar * ptdata, int len)
  * dma_buf_read: reads a frame from the Rx DMA buffers
  * NOTE: this function reads one frame at a time.
  */
-int dma_buf_read(pc300_t * card, int ch, struct sk_buff *skb)
+static int dma_buf_read(pc300_t * card, int ch, struct sk_buff *skb)
 {
        int nchar;
        pc300ch_t *chan = (pc300ch_t *) & card->chan[ch];
-       volatile pcsca_bd_t *ptdescr;
+       volatile pcsca_bd_t __iomem *ptdescr;
        int rcvd = 0;
        volatile ucchar status;
 
-       ptdescr = (pcsca_bd_t *) (card->hw.rambase +
+       ptdescr = (card->hw.rambase +
                                  RX_BD_ADDR(ch, chan->rx_first_bd));
        while ((status = cpc_readb(&ptdescr->status)) & DST_OSB) {
                nchar = cpc_readw(&ptdescr->len);
@@ -527,7 +528,7 @@ int dma_buf_read(pc300_t * card, int ch, struct sk_buff *skb)
                                chan->rx_first_bd = (chan->rx_first_bd+1) & (N_DMA_RX_BUF-1);
                                if (status & DST_EOM)
                                        break;
-                               ptdescr = (pcsca_bd_t *) (card->hw.rambase +
+                               ptdescr = (card->hw.rambase +
                                                          cpc_readl(&ptdescr->next));
                                status = cpc_readb(&ptdescr->status);
                        }
@@ -536,7 +537,7 @@ int dma_buf_read(pc300_t * card, int ch, struct sk_buff *skb)
                if (nchar != 0) {
                        if (skb) {
                                memcpy_fromio(skb_put(skb, nchar),
-                                (void *)(card->hw.rambase+cpc_readl(&ptdescr->ptbuf)),nchar);
+                                (card->hw.rambase+cpc_readl(&ptdescr->ptbuf)),nchar);
                        }
                        rcvd += nchar;
                }
@@ -547,7 +548,7 @@ int dma_buf_read(pc300_t * card, int ch, struct sk_buff *skb)
                if (status & DST_EOM)
                        break;
 
-               ptdescr = (pcsca_bd_t *) (card->hw.rambase + cpc_readl(&ptdescr->next));
+               ptdescr = (card->hw.rambase + cpc_readl(&ptdescr->next));
        }
 
        if (rcvd != 0) {
@@ -560,9 +561,9 @@ int dma_buf_read(pc300_t * card, int ch, struct sk_buff *skb)
        return (rcvd);
 }
 
-void tx_dma_stop(pc300_t * card, int ch)
+static void tx_dma_stop(pc300_t * card, int ch)
 {
-       uclong scabase = card->hw.scabase;
+       void __iomem *scabase = card->hw.scabase;
        ucchar drr_ena_bit = 1 << (5 + 2 * ch);
        ucchar drr_rst_bit = 1 << (1 + 2 * ch);
 
@@ -571,9 +572,9 @@ void tx_dma_stop(pc300_t * card, int ch)
        cpc_writeb(scabase + DRR, drr_rst_bit & ~drr_ena_bit);
 }
 
-void rx_dma_stop(pc300_t * card, int ch)
+static void rx_dma_stop(pc300_t * card, int ch)
 {
-       uclong scabase = card->hw.scabase;
+       void __iomem *scabase = card->hw.scabase;
        ucchar drr_ena_bit = 1 << (4 + 2 * ch);
        ucchar drr_rst_bit = 1 << (2 * ch);
 
@@ -582,9 +583,9 @@ void rx_dma_stop(pc300_t * card, int ch)
        cpc_writeb(scabase + DRR, drr_rst_bit & ~drr_ena_bit);
 }
 
-void rx_dma_start(pc300_t * card, int ch)
+static void rx_dma_start(pc300_t * card, int ch)
 {
-       uclong scabase = card->hw.scabase;
+       void __iomem *scabase = card->hw.scabase;
        pc300ch_t *chan = (pc300ch_t *) & card->chan[ch];
        
        /* Start DMA */
@@ -607,9 +608,9 @@ void rx_dma_start(pc300_t * card, int ch)
 /*************************/
 /***   FALC Routines   ***/
 /*************************/
-void falc_issue_cmd(pc300_t * card, int ch, ucchar cmd)
+static void falc_issue_cmd(pc300_t * card, int ch, ucchar cmd)
 {
-       uclong falcbase = card->hw.falcbase;
+       void __iomem *falcbase = card->hw.falcbase;
        unsigned long i = 0;
 
        while (cpc_readb(falcbase + F_REG(SIS, ch)) & SIS_CEC) {
@@ -622,12 +623,12 @@ void falc_issue_cmd(pc300_t * card, int ch, ucchar cmd)
        cpc_writeb(falcbase + F_REG(CMDR, ch), cmd);
 }
 
-void falc_intr_enable(pc300_t * card, int ch)
+static void falc_intr_enable(pc300_t * card, int ch)
 {
        pc300ch_t *chan = (pc300ch_t *) & card->chan[ch];
        pc300chconf_t *conf = (pc300chconf_t *) & chan->conf;
        falc_t *pfalc = (falc_t *) & chan->falc;
-       uclong falcbase = card->hw.falcbase;
+       void __iomem *falcbase = card->hw.falcbase;
 
        /* Interrupt pins are open-drain */
        cpc_writeb(falcbase + F_REG(IPC, ch),
@@ -672,9 +673,9 @@ void falc_intr_enable(pc300_t * card, int ch)
        }
 }
 
-void falc_open_timeslot(pc300_t * card, int ch, int timeslot)
+static void falc_open_timeslot(pc300_t * card, int ch, int timeslot)
 {
-       uclong falcbase = card->hw.falcbase;
+       void __iomem *falcbase = card->hw.falcbase;
        ucchar tshf = card->chan[ch].falc.offset;
 
        cpc_writeb(falcbase + F_REG((ICB1 + (timeslot - tshf) / 8), ch),
@@ -688,9 +689,9 @@ void falc_open_timeslot(pc300_t * card, int ch, int timeslot)
                        (0x80 >> (timeslot & 0x07)));
 }
 
-void falc_close_timeslot(pc300_t * card, int ch, int timeslot)
+static void falc_close_timeslot(pc300_t * card, int ch, int timeslot)
 {
-       uclong falcbase = card->hw.falcbase;
+       void __iomem *falcbase = card->hw.falcbase;
        ucchar tshf = card->chan[ch].falc.offset;
 
        cpc_writeb(falcbase + F_REG((ICB1 + (timeslot - tshf) / 8), ch),
@@ -704,11 +705,11 @@ void falc_close_timeslot(pc300_t * card, int ch, int timeslot)
                   ~(0x80 >> (timeslot & 0x07)));
 }
 
-void falc_close_all_timeslots(pc300_t * card, int ch)
+static void falc_close_all_timeslots(pc300_t * card, int ch)
 {
        pc300ch_t *chan = (pc300ch_t *) & card->chan[ch];
        pc300chconf_t *conf = (pc300chconf_t *) & chan->conf;
-       uclong falcbase = card->hw.falcbase;
+       void __iomem *falcbase = card->hw.falcbase;
 
        cpc_writeb(falcbase + F_REG(ICB1, ch), 0xff);
        cpc_writeb(falcbase + F_REG(TTR1, ch), 0);
@@ -726,11 +727,11 @@ void falc_close_all_timeslots(pc300_t * card, int ch)
        }
 }
 
-void falc_open_all_timeslots(pc300_t * card, int ch)
+static void falc_open_all_timeslots(pc300_t * card, int ch)
 {
        pc300ch_t *chan = (pc300ch_t *) & card->chan[ch];
        pc300chconf_t *conf = (pc300chconf_t *) & chan->conf;
-       uclong falcbase = card->hw.falcbase;
+       void __iomem *falcbase = card->hw.falcbase;
 
        cpc_writeb(falcbase + F_REG(ICB1, ch), 0);
        if (conf->fr_mode == PC300_FR_UNFRAMED) {
@@ -758,7 +759,7 @@ void falc_open_all_timeslots(pc300_t * card, int ch)
        }
 }
 
-void falc_init_timeslot(pc300_t * card, int ch)
+static void falc_init_timeslot(pc300_t * card, int ch)
 {
        pc300ch_t *chan = (pc300ch_t *) & card->chan[ch];
        pc300chconf_t *conf = (pc300chconf_t *) & chan->conf;
@@ -776,7 +777,7 @@ void falc_init_timeslot(pc300_t * card, int ch)
        }
 }
 
-void falc_enable_comm(pc300_t * card, int ch)
+static void falc_enable_comm(pc300_t * card, int ch)
 {
        pc300ch_t *chan = (pc300ch_t *) & card->chan[ch];
        falc_t *pfalc = (falc_t *) & chan->falc;
@@ -792,7 +793,7 @@ void falc_enable_comm(pc300_t * card, int ch)
                   ~((CPLD_REG1_FALC_DCD | CPLD_REG1_FALC_CTS) << (2 * ch)));
 }
 
-void falc_disable_comm(pc300_t * card, int ch)
+static void falc_disable_comm(pc300_t * card, int ch)
 {
        pc300ch_t *chan = (pc300ch_t *) & card->chan[ch];
        falc_t *pfalc = (falc_t *) & chan->falc;
@@ -806,12 +807,12 @@ void falc_disable_comm(pc300_t * card, int ch)
                   ((CPLD_REG1_FALC_DCD | CPLD_REG1_FALC_CTS) << (2 * ch)));
 }
 
-void falc_init_t1(pc300_t * card, int ch)
+static void falc_init_t1(pc300_t * card, int ch)
 {
        pc300ch_t *chan = (pc300ch_t *) & card->chan[ch];
        pc300chconf_t *conf = (pc300chconf_t *) & chan->conf;
        falc_t *pfalc = (falc_t *) & chan->falc;
-       uclong falcbase = card->hw.falcbase;
+       void __iomem *falcbase = card->hw.falcbase;
        ucchar dja = (ch ? (LIM2_DJA2 | LIM2_DJA1) : 0);
 
        /* Switch to T1 mode (PCM 24) */
@@ -975,12 +976,12 @@ void falc_init_t1(pc300_t * card, int ch)
        falc_close_all_timeslots(card, ch);
 }
 
-void falc_init_e1(pc300_t * card, int ch)
+static void falc_init_e1(pc300_t * card, int ch)
 {
        pc300ch_t *chan = (pc300ch_t *) & card->chan[ch];
        pc300chconf_t *conf = (pc300chconf_t *) & chan->conf;
        falc_t *pfalc = (falc_t *) & chan->falc;
-       uclong falcbase = card->hw.falcbase;
+       void __iomem *falcbase = card->hw.falcbase;
        ucchar dja = (ch ? (LIM2_DJA2 | LIM2_DJA1) : 0);
 
        /* Switch to E1 mode (PCM 30) */
@@ -1155,9 +1156,9 @@ void falc_init_e1(pc300_t * card, int ch)
        falc_close_all_timeslots(card, ch);
 }
 
-void falc_init_hdlc(pc300_t * card, int ch)
+static void falc_init_hdlc(pc300_t * card, int ch)
 {
-       uclong falcbase = card->hw.falcbase;
+       void __iomem *falcbase = card->hw.falcbase;
        pc300ch_t *chan = (pc300ch_t *) & card->chan[ch];
        pc300chconf_t *conf = (pc300chconf_t *) & chan->conf;
 
@@ -1181,12 +1182,12 @@ void falc_init_hdlc(pc300_t * card, int ch)
        falc_intr_enable(card, ch);
 }
 
-void te_config(pc300_t * card, int ch)
+static void te_config(pc300_t * card, int ch)
 {
        pc300ch_t *chan = (pc300ch_t *) & card->chan[ch];
        pc300chconf_t *conf = (pc300chconf_t *) & chan->conf;
        falc_t *pfalc = (falc_t *) & chan->falc;
-       uclong falcbase = card->hw.falcbase;
+       void __iomem *falcbase = card->hw.falcbase;
        ucchar dummy;
        unsigned long flags;
 
@@ -1241,12 +1242,12 @@ void te_config(pc300_t * card, int ch)
        CPC_UNLOCK(card, flags);
 }
 
-void falc_check_status(pc300_t * card, int ch, unsigned char frs0)
+static void falc_check_status(pc300_t * card, int ch, unsigned char frs0)
 {
        pc300ch_t *chan = (pc300ch_t *) & card->chan[ch];
        pc300chconf_t *conf = (pc300chconf_t *) & chan->conf;
        falc_t *pfalc = (falc_t *) & chan->falc;
-       uclong falcbase = card->hw.falcbase;
+       void __iomem *falcbase = card->hw.falcbase;
 
        /* Verify LOS */
        if (frs0 & FRS0_LOS) {
@@ -1397,12 +1398,12 @@ void falc_check_status(pc300_t * card, int ch, unsigned char frs0)
        }
 }
 
-void falc_update_stats(pc300_t * card, int ch)
+static void falc_update_stats(pc300_t * card, int ch)
 {
        pc300ch_t *chan = (pc300ch_t *) & card->chan[ch];
        pc300chconf_t *conf = (pc300chconf_t *) & chan->conf;
        falc_t *pfalc = (falc_t *) & chan->falc;
-       uclong falcbase = card->hw.falcbase;
+       void __iomem *falcbase = card->hw.falcbase;
        ucshort counter;
 
        counter = cpc_readb(falcbase + F_REG(FECL, ch));
@@ -1450,12 +1451,12 @@ void falc_update_stats(pc300_t * card, int ch)
  *             the synchronizer and then sent to the system interface.
  *----------------------------------------------------------------------------
  */
-void falc_remote_loop(pc300_t * card, int ch, int loop_on)
+static void falc_remote_loop(pc300_t * card, int ch, int loop_on)
 {
        pc300ch_t *chan = (pc300ch_t *) & card->chan[ch];
        pc300chconf_t *conf = (pc300chconf_t *) & chan->conf;
        falc_t *pfalc = (falc_t *) & chan->falc;
-       uclong falcbase = card->hw.falcbase;
+       void __iomem *falcbase = card->hw.falcbase;
 
        if (loop_on) {
                // EVENT_FALC_ABNORMAL
@@ -1495,11 +1496,11 @@ void falc_remote_loop(pc300_t * card, int ch, int loop_on)
  *             coding must be identical.
  *----------------------------------------------------------------------------
  */
-void falc_local_loop(pc300_t * card, int ch, int loop_on)
+static void falc_local_loop(pc300_t * card, int ch, int loop_on)
 {
        pc300ch_t *chan = (pc300ch_t *) & card->chan[ch];
        falc_t *pfalc = (falc_t *) & chan->falc;
-       uclong falcbase = card->hw.falcbase;
+       void __iomem *falcbase = card->hw.falcbase;
 
        if (loop_on) {
                cpc_writeb(falcbase + F_REG(LIM0, ch),
@@ -1522,12 +1523,12 @@ void falc_local_loop(pc300_t * card, int ch, int loop_on)
  *             looped. They are originated by the FALC-LH transmitter.
  *----------------------------------------------------------------------------
  */
-void falc_payload_loop(pc300_t * card, int ch, int loop_on)
+static void falc_payload_loop(pc300_t * card, int ch, int loop_on)
 {
        pc300ch_t *chan = (pc300ch_t *) & card->chan[ch];
        pc300chconf_t *conf = (pc300chconf_t *) & chan->conf;
        falc_t *pfalc = (falc_t *) & chan->falc;
-       uclong falcbase = card->hw.falcbase;
+       void __iomem *falcbase = card->hw.falcbase;
 
        if (loop_on) {
                // EVENT_FALC_ABNORMAL
@@ -1576,11 +1577,11 @@ void falc_payload_loop(pc300_t * card, int ch, int loop_on)
  * Description:        Turns XLU bit off in the proper register
  *----------------------------------------------------------------------------
  */
-void turn_off_xlu(pc300_t * card, int ch)
+static void turn_off_xlu(pc300_t * card, int ch)
 {
        pc300ch_t *chan = (pc300ch_t *) & card->chan[ch];
        pc300chconf_t *conf = (pc300chconf_t *) & chan->conf;
-       uclong falcbase = card->hw.falcbase;
+       void __iomem *falcbase = card->hw.falcbase;
 
        if (conf->media == IF_IFACE_T1) {
                cpc_writeb(falcbase + F_REG(FMR5, ch),
@@ -1597,11 +1598,11 @@ void turn_off_xlu(pc300_t * card, int ch)
  * Description: Turns XLD bit off in the proper register
  *----------------------------------------------------------------------------
  */
-void turn_off_xld(pc300_t * card, int ch)
+static void turn_off_xld(pc300_t * card, int ch)
 {
        pc300ch_t *chan = (pc300ch_t *) & card->chan[ch];
        pc300chconf_t *conf = (pc300chconf_t *) & chan->conf;
-       uclong falcbase = card->hw.falcbase;
+       void __iomem *falcbase = card->hw.falcbase;
 
        if (conf->media == IF_IFACE_T1) {
                cpc_writeb(falcbase + F_REG(FMR5, ch),
@@ -1619,12 +1620,12 @@ void turn_off_xld(pc300_t * card, int ch)
  *             to generate a LOOP activation code over a T1/E1 line.
  *----------------------------------------------------------------------------
  */
-void falc_generate_loop_up_code(pc300_t * card, int ch)
+static void falc_generate_loop_up_code(pc300_t * card, int ch)
 {
        pc300ch_t *chan = (pc300ch_t *) & card->chan[ch];
        pc300chconf_t *conf = (pc300chconf_t *) & chan->conf;
        falc_t *pfalc = (falc_t *) & chan->falc;
-       uclong falcbase = card->hw.falcbase;
+       void __iomem *falcbase = card->hw.falcbase;
 
        if (conf->media == IF_IFACE_T1) {
                cpc_writeb(falcbase + F_REG(FMR5, ch),
@@ -1652,12 +1653,12 @@ void falc_generate_loop_up_code(pc300_t * card, int ch)
  *             to generate a LOOP deactivation code over a T1/E1 line.
  *----------------------------------------------------------------------------
  */
-void falc_generate_loop_down_code(pc300_t * card, int ch)
+static void falc_generate_loop_down_code(pc300_t * card, int ch)
 {
        pc300ch_t *chan = (pc300ch_t *) & card->chan[ch];
        pc300chconf_t *conf = (pc300chconf_t *) & chan->conf;
        falc_t *pfalc = (falc_t *) & chan->falc;
-       uclong falcbase = card->hw.falcbase;
+       void __iomem *falcbase = card->hw.falcbase;
 
        if (conf->media == IF_IFACE_T1) {
                cpc_writeb(falcbase + F_REG(FMR5, ch),
@@ -1682,12 +1683,12 @@ void falc_generate_loop_down_code(pc300_t * card, int ch)
  *             it on the reception side.
  *----------------------------------------------------------------------------
  */
-void falc_pattern_test(pc300_t * card, int ch, unsigned int activate)
+static void falc_pattern_test(pc300_t * card, int ch, unsigned int activate)
 {
        pc300ch_t *chan = (pc300ch_t *) & card->chan[ch];
        pc300chconf_t *conf = (pc300chconf_t *) & chan->conf;
        falc_t *pfalc = (falc_t *) & chan->falc;
-       uclong falcbase = card->hw.falcbase;
+       void __iomem *falcbase = card->hw.falcbase;
 
        if (activate) {
                pfalc->prbs = 1;
@@ -1729,7 +1730,7 @@ void falc_pattern_test(pc300_t * card, int ch, unsigned int activate)
  * Description:        This routine returns the bit error counter value
  *----------------------------------------------------------------------------
  */
-ucshort falc_pattern_test_error(pc300_t * card, int ch)
+static ucshort falc_pattern_test_error(pc300_t * card, int ch)
 {
        pc300ch_t *chan = (pc300ch_t *) & card->chan[ch];
        falc_t *pfalc = (falc_t *) & chan->falc;
@@ -1769,14 +1770,14 @@ cpc_trace(struct net_device *dev, struct sk_buff *skb_main, char rx_tx)
        netif_rx(skb);
 }
 
-void cpc_tx_timeout(struct net_device *dev)
+static void cpc_tx_timeout(struct net_device *dev)
 {
        pc300dev_t *d = (pc300dev_t *) dev->priv;
        pc300ch_t *chan = (pc300ch_t *) d->chan;
        pc300_t *card = (pc300_t *) chan->card;
        struct net_device_stats *stats = hdlc_stats(dev);
        int ch = chan->channel;
-       uclong flags;
+       unsigned long flags;
        ucchar ilar;
 
        stats->tx_errors++;
@@ -1797,14 +1798,14 @@ void cpc_tx_timeout(struct net_device *dev)
        netif_wake_queue(dev);
 }
 
-int cpc_queue_xmit(struct sk_buff *skb, struct net_device *dev)
+static int cpc_queue_xmit(struct sk_buff *skb, struct net_device *dev)
 {
        pc300dev_t *d = (pc300dev_t *) dev->priv;
        pc300ch_t *chan = (pc300ch_t *) d->chan;
        pc300_t *card = (pc300_t *) chan->card;
        struct net_device_stats *stats = hdlc_stats(dev);
        int ch = chan->channel;
-       uclong flags;
+       unsigned long flags;
 #ifdef PC300_DEBUG_TX
        int i;
 #endif
@@ -1880,7 +1881,7 @@ int cpc_queue_xmit(struct sk_buff *skb, struct net_device *dev)
        return 0;
 }
 
-void cpc_net_rx(struct net_device *dev)
+static void cpc_net_rx(struct net_device *dev)
 {
        pc300dev_t *d = (pc300dev_t *) dev->priv;
        pc300ch_t *chan = (pc300ch_t *) d->chan;
@@ -1959,7 +1960,6 @@ void cpc_net_rx(struct net_device *dev)
                        cpc_trace(dev, skb, 'R');
                }
                stats->rx_packets++;
-               skb->mac.raw = skb->data;
                skb->protocol = hdlc_type_trans(skb, dev);
                netif_rx(skb);
        }
@@ -1973,11 +1973,11 @@ static void sca_tx_intr(pc300dev_t *dev)
        pc300ch_t *chan = (pc300ch_t *)dev->chan; 
        pc300_t *card = (pc300_t *)chan->card; 
        int ch = chan->channel; 
-       volatile pcsca_bd_t * ptdescr; 
+       volatile pcsca_bd_t __iomem * ptdescr; 
        struct net_device_stats *stats = hdlc_stats(dev->dev);
 
     /* Clean up descriptors from previous transmission */
-       ptdescr = (pcsca_bd_t *)(card->hw.rambase +
+       ptdescr = (card->hw.rambase +
                                                TX_BD_ADDR(ch,chan->tx_first_bd));
        while ((cpc_readl(card->hw.scabase + DTX_REG(CDAL,ch)) != 
                                                        TX_BD_ADDR(ch,chan->tx_first_bd)) && 
@@ -1988,8 +1988,7 @@ static void sca_tx_intr(pc300dev_t *dev)
                cpc_writew(&ptdescr->len, 0);
                chan->nfree_tx_bd++;
                chan->tx_first_bd = (chan->tx_first_bd + 1) & (N_DMA_TX_BUF - 1);
-               ptdescr = (pcsca_bd_t *)(card->hw.rambase +
-                                               TX_BD_ADDR(ch,chan->tx_first_bd));
+               ptdescr = (card->hw.rambase + TX_BD_ADDR(ch,chan->tx_first_bd));
     }
 
 #ifdef CONFIG_PC300_MLPPP
@@ -2006,7 +2005,7 @@ static void sca_tx_intr(pc300dev_t *dev)
 
 static void sca_intr(pc300_t * card)
 {
-       uclong scabase = card->hw.scabase;
+       void __iomem *scabase = card->hw.scabase;
        volatile uclong status;
        int ch;
        int intr_count = 0;
@@ -2017,7 +2016,6 @@ static void sca_intr(pc300_t * card)
                        pc300ch_t *chan = &card->chan[ch];
                        pc300dev_t *d = &chan->d;
                        struct net_device *dev = d->dev;
-                       hdlc_device *hdlc = dev_to_hdlc(dev);
 
                        spin_lock(&card->card_lock);
 
@@ -2050,8 +2048,8 @@ static void sca_intr(pc300_t * card)
                                                        }
                                                        cpc_net_rx(dev);
                                                        /* Discard invalid frames */
-                                                       hdlc->stats.rx_errors++;
-                                                       hdlc->stats.rx_over_errors++;
+                                                       hdlc_stats(dev)->rx_errors++;
+                                                       hdlc_stats(dev)->rx_over_errors++;
                                                        chan->rx_first_bd = 0;
                                                        chan->rx_last_bd = N_DMA_RX_BUF - 1;
                                                        rx_dma_start(card, ch);
@@ -2117,8 +2115,8 @@ static void sca_intr(pc300_t * card)
                                                                                   card->hw.cpld_reg2) &
                                                                   ~ (CPLD_REG2_FALC_LED1 << (2 * ch)));
                                                }
-                                               hdlc->stats.tx_errors++;
-                                               hdlc->stats.tx_fifo_errors++;
+                                               hdlc_stats(dev)->tx_errors++;
+                                               hdlc_stats(dev)->tx_fifo_errors++;
                                                sca_tx_intr(d);
                                        }
                                }
@@ -2187,7 +2185,7 @@ static void falc_t1_loop_detection(pc300_t * card, int ch, ucchar frs1)
 {
        pc300ch_t *chan = (pc300ch_t *) & card->chan[ch];
        falc_t *pfalc = (falc_t *) & chan->falc;
-       uclong falcbase = card->hw.falcbase;
+       void __iomem *falcbase = card->hw.falcbase;
 
        if (((cpc_readb(falcbase + F_REG(LCR1, ch)) & LCR1_XPRBS) == 0) &&
            !pfalc->loop_gen) {
@@ -2212,7 +2210,7 @@ static void falc_e1_loop_detection(pc300_t * card, int ch, ucchar rsp)
 {
        pc300ch_t *chan = (pc300ch_t *) & card->chan[ch];
        falc_t *pfalc = (falc_t *) & chan->falc;
-       uclong falcbase = card->hw.falcbase;
+       void __iomem *falcbase = card->hw.falcbase;
 
        if (((cpc_readb(falcbase + F_REG(LCR1, ch)) & LCR1_XPRBS) == 0) &&
            !pfalc->loop_gen) {
@@ -2237,7 +2235,7 @@ static void falc_t1_intr(pc300_t * card, int ch)
 {
        pc300ch_t *chan = (pc300ch_t *) & card->chan[ch];
        falc_t *pfalc = (falc_t *) & chan->falc;
-       uclong falcbase = card->hw.falcbase;
+       void __iomem *falcbase = card->hw.falcbase;
        ucchar isr0, isr3, gis;
        ucchar dummy;
 
@@ -2284,7 +2282,7 @@ static void falc_e1_intr(pc300_t * card, int ch)
 {
        pc300ch_t *chan = (pc300ch_t *) & card->chan[ch];
        falc_t *pfalc = (falc_t *) & chan->falc;
-       uclong falcbase = card->hw.falcbase;
+       void __iomem *falcbase = card->hw.falcbase;
        ucchar isr1, isr2, isr3, gis, rsp;
        ucchar dummy;
 
@@ -2365,7 +2363,7 @@ static void falc_intr(pc300_t * card)
        }
 }
 
-static irqreturn_t cpc_intr(int irq, void *dev_id, struct pt_regs *regs)
+static irqreturn_t cpc_intr(int irq, void *dev_id)
 {
        pc300_t *card;
        volatile ucchar plx_status;
@@ -2405,11 +2403,11 @@ static irqreturn_t cpc_intr(int irq, void *dev_id, struct pt_regs *regs)
        return IRQ_HANDLED;
 }
 
-void cpc_sca_status(pc300_t * card, int ch)
+static void cpc_sca_status(pc300_t * card, int ch)
 {
        ucchar ilar;
-       uclong scabase = card->hw.scabase;
-       uclong flags;
+       void __iomem *scabase = card->hw.scabase;
+       unsigned long flags;
 
        tx_dma_buf_check(card, ch);
        rx_dma_buf_check(card, ch);
@@ -2417,12 +2415,12 @@ void cpc_sca_status(pc300_t * card, int ch)
        printk ("ILAR=0x%02x, WCRL=0x%02x, PCR=0x%02x, BTCR=0x%02x, BOLR=0x%02x\n",
                 ilar, cpc_readb(scabase + WCRL), cpc_readb(scabase + PCR),
                 cpc_readb(scabase + BTCR), cpc_readb(scabase + BOLR));
-       printk("TX_CDA=0x%08lx, TX_EDA=0x%08lx\n",
-              (uclong) cpc_readl(scabase + DTX_REG(CDAL, ch)),
-              (uclong) cpc_readl(scabase + DTX_REG(EDAL, ch)));
-       printk("RX_CDA=0x%08lx, RX_EDA=0x%08lx, BFL=0x%04x\n",
-              (uclong) cpc_readl(scabase + DRX_REG(CDAL, ch)),
-              (uclong) cpc_readl(scabase + DRX_REG(EDAL, ch)),
+       printk("TX_CDA=0x%08x, TX_EDA=0x%08x\n",
+              cpc_readl(scabase + DTX_REG(CDAL, ch)),
+              cpc_readl(scabase + DTX_REG(EDAL, ch)));
+       printk("RX_CDA=0x%08x, RX_EDA=0x%08x, BFL=0x%04x\n",
+              cpc_readl(scabase + DRX_REG(CDAL, ch)),
+              cpc_readl(scabase + DRX_REG(EDAL, ch)),
               cpc_readw(scabase + DRX_REG(BFLL, ch)));
        printk("DMER=0x%02x, DSR_TX=0x%02x, DSR_RX=0x%02x\n",
               cpc_readb(scabase + DMER), cpc_readb(scabase + DSR_TX(ch)),
@@ -2487,7 +2485,7 @@ void cpc_sca_status(pc300_t * card, int ch)
               cpc_readb(scabase + M_REG(IE2, ch)),
               cpc_readb(scabase + M_REG(IE4, ch)),
               cpc_readb(scabase + M_REG(FIE, ch)));
-       printk("IER0=0x%08lx\n", (uclong) cpc_readl(scabase + IER0));
+       printk("IER0=0x%08x\n", cpc_readl(scabase + IER0));
 
        if (ilar != 0) {
                CPC_LOCK(card, flags);
@@ -2497,11 +2495,11 @@ void cpc_sca_status(pc300_t * card, int ch)
        }
 }
 
-void cpc_falc_status(pc300_t * card, int ch)
+static void cpc_falc_status(pc300_t * card, int ch)
 {
        pc300ch_t *chan = &card->chan[ch];
        falc_t *pfalc = (falc_t *) & chan->falc;
-       uclong flags;
+       unsigned long flags;
 
        CPC_LOCK(card, flags);
        printk("CH%d:   %s %s  %d channels\n",
@@ -2525,7 +2523,7 @@ void cpc_falc_status(pc300_t * card, int ch)
        CPC_UNLOCK(card, flags);
 }
 
-int cpc_change_mtu(struct net_device *dev, int new_mtu)
+static int cpc_change_mtu(struct net_device *dev, int new_mtu)
 {
        if ((new_mtu < 128) || (new_mtu > PC300_DEF_MTU))
                return -EINVAL;
@@ -2533,9 +2531,8 @@ int cpc_change_mtu(struct net_device *dev, int new_mtu)
        return 0;
 }
 
-int cpc_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
+static int cpc_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
 {
-       hdlc_device *hdlc = dev_to_hdlc(dev);
        pc300dev_t *d = (pc300dev_t *) dev->priv;
        pc300ch_t *chan = (pc300ch_t *) d->chan;
        pc300_t *card = (pc300_t *) chan->card;
@@ -2544,7 +2541,7 @@ int cpc_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
        int ch = chan->channel;
        void __user *arg = ifr->ifr_data;
        struct if_settings *settings = &ifr->ifr_settings;
-       uclong scabase = card->hw.scabase;
+       void __iomem *scabase = card->hw.scabase;
 
        if (!capable(CAP_NET_ADMIN))
                return -EPERM;
@@ -2553,10 +2550,10 @@ int cpc_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
                case SIOCGPC300CONF:
 #ifdef CONFIG_PC300_MLPPP
                        if (conf->proto != PC300_PROTO_MLPPP) {
-                               conf->proto = hdlc->proto.id;
+                               conf->proto = /* FIXME hdlc->proto.id */ 0;
                        }
 #else
-                       conf->proto = hdlc->proto.id;
+                       conf->proto = /* FIXME hdlc->proto.id */ 0;
 #endif
                        memcpy(&conf_aux.conf, conf, sizeof(pc300chconf_t));
                        memcpy(&conf_aux.hw, &card->hw, sizeof(pc300hw_t));
@@ -2589,12 +2586,12 @@ int cpc_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
                                        }
                                } else {
                                        memcpy(conf, &conf_aux.conf, sizeof(pc300chconf_t));
-                                       hdlc->proto.id = conf->proto;
+                                       /* FIXME hdlc->proto.id = conf->proto; */
                                }
                        }
 #else
                        memcpy(conf, &conf_aux.conf, sizeof(pc300chconf_t));
-                       hdlc->proto.id = conf->proto;
+                       /* FIXME hdlc->proto.id = conf->proto; */
 #endif
                        return 0;
                case SIOCGPC300STATUS:
@@ -2607,7 +2604,7 @@ int cpc_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
                case SIOCGPC300UTILSTATS:
                        {
                                if (!arg) {     /* clear statistics */
-                                       memset(&hdlc->stats, 0, sizeof(struct net_device_stats));
+                                       memset(hdlc_stats(dev), 0, sizeof(struct net_device_stats));
                                        if (card->hw.type == PC300_TE) {
                                                memset(&chan->falc, 0, sizeof(falc_t));
                                        }
@@ -2618,7 +2615,7 @@ int cpc_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
                                        pc300stats.hw_type = card->hw.type;
                                        pc300stats.line_on = card->chan[ch].d.line_on;
                                        pc300stats.line_off = card->chan[ch].d.line_off;
-                                       memcpy(&pc300stats.gen_stats, &hdlc->stats,
+                                       memcpy(&pc300stats.gen_stats, hdlc_stats(dev),
                                               sizeof(struct net_device_stats));
                                        if (card->hw.type == PC300_TE)
                                                memcpy(&pc300stats.te_stats,&chan->falc,sizeof(falc_t));
@@ -2858,19 +2855,18 @@ static int clock_rate_calc(uclong rate, uclong clock, int *br_io)
        }
 }
 
-int ch_config(pc300dev_t * d)
+static int ch_config(pc300dev_t * d)
 {
        pc300ch_t *chan = (pc300ch_t *) d->chan;
        pc300chconf_t *conf = (pc300chconf_t *) & chan->conf;
        pc300_t *card = (pc300_t *) chan->card;
-       uclong scabase = card->hw.scabase;
-       uclong plxbase = card->hw.plxbase;
+       void __iomem *scabase = card->hw.scabase;
+       void __iomem *plxbase = card->hw.plxbase;
        int ch = chan->channel;
        uclong clkrate = chan->conf.phys_settings.clock_rate;
        uclong clktype = chan->conf.phys_settings.clock_type;
        ucshort encoding = chan->conf.proto_settings.encoding;
        ucshort parity = chan->conf.proto_settings.parity;   
-       int tmc, br;
        ucchar md0, md2;
     
        /* Reset the channel */
@@ -2943,8 +2939,12 @@ int ch_config(pc300dev_t * d)
                case PC300_RSV:
                case PC300_X21:
                        if (clktype == CLOCK_INT || clktype == CLOCK_TXINT) {
+                               int tmc, br;
+
                                /* Calculate the clkrate parameters */
                                tmc = clock_rate_calc(clkrate, card->hw.clock, &br);
+                               if (tmc < 0)
+                                       return -EIO;
                                cpc_writeb(scabase + M_REG(TMCT, ch), tmc);
                                cpc_writeb(scabase + M_REG(TXS, ch),
                                           (TXS_DTRXC | TXS_IBRG | br));
@@ -3006,11 +3006,11 @@ int ch_config(pc300dev_t * d)
        return 0;
 }
 
-int rx_config(pc300dev_t * d)
+static int rx_config(pc300dev_t * d)
 {
        pc300ch_t *chan = (pc300ch_t *) d->chan;
        pc300_t *card = (pc300_t *) chan->card;
-       uclong scabase = card->hw.scabase;
+       void __iomem *scabase = card->hw.scabase;
        int ch = chan->channel;
 
        cpc_writeb(scabase + DSR_RX(ch), 0);
@@ -3037,11 +3037,11 @@ int rx_config(pc300dev_t * d)
        return 0;
 }
 
-int tx_config(pc300dev_t * d)
+static int tx_config(pc300dev_t * d)
 {
        pc300ch_t *chan = (pc300ch_t *) d->chan;
        pc300_t *card = (pc300_t *) chan->card;
-       uclong scabase = card->hw.scabase;
+       void __iomem *scabase = card->hw.scabase;
        int ch = chan->channel;
 
        cpc_writeb(scabase + DSR_TX(ch), 0);
@@ -3100,14 +3100,16 @@ static int cpc_attach(struct net_device *dev, unsigned short encoding,
        return 0;
 }
 
-void cpc_opench(pc300dev_t * d)
+static int cpc_opench(pc300dev_t * d)
 {
        pc300ch_t *chan = (pc300ch_t *) d->chan;
        pc300_t *card = (pc300_t *) chan->card;
-       int ch = chan->channel;
-       uclong scabase = card->hw.scabase;
+       int ch = chan->channel, rc;
+       void __iomem *scabase = card->hw.scabase;
 
-       ch_config(d);
+       rc = ch_config(d);
+       if (rc)
+               return rc;
 
        rx_config(d);
 
@@ -3116,9 +3118,11 @@ void cpc_opench(pc300dev_t * d)
        /* Assert RTS and DTR */
        cpc_writeb(scabase + M_REG(CTL, ch),
                   cpc_readb(scabase + M_REG(CTL, ch)) & ~(CTL_RTS | CTL_DTR));
+
+       return 0;
 }
 
-void cpc_closech(pc300dev_t * d)
+static void cpc_closech(pc300dev_t * d)
 {
        pc300ch_t *chan = (pc300ch_t *) d->chan;
        pc300_t *card = (pc300_t *) chan->card;
@@ -3148,7 +3152,6 @@ void cpc_closech(pc300dev_t * d)
 
 int cpc_open(struct net_device *dev)
 {
-       hdlc_device *hdlc = dev_to_hdlc(dev);
        pc300dev_t *d = (pc300dev_t *) dev->priv;
        struct ifreq ifr;
        int result;
@@ -3157,12 +3160,14 @@ int cpc_open(struct net_device *dev)
        printk("pc300: cpc_open");
 #endif
 
+#ifdef FIXME
        if (hdlc->proto.id == IF_PROTO_PPP) {
                d->if_ptr = &hdlc->state.ppp.pppdev;
        }
+#endif
 
        result = hdlc_open(dev);
-       if (hdlc->proto.id == IF_PROTO_PPP) {
+       if (/* FIXME hdlc->proto.id == IF_PROTO_PPP*/ 0) {
                dev->priv = d;
        }
        if (result) {
@@ -3170,18 +3175,24 @@ int cpc_open(struct net_device *dev)
        }
 
        sprintf(ifr.ifr_name, "%s", dev->name);
-       cpc_opench(d);
+       result = cpc_opench(d);
+       if (result)
+               goto err_out;
+
        netif_start_queue(dev);
        return 0;
+
+err_out:
+       hdlc_close(dev);
+       return result;
 }
 
-int cpc_close(struct net_device *dev)
+static int cpc_close(struct net_device *dev)
 {
-       hdlc_device *hdlc = dev_to_hdlc(dev);
        pc300dev_t *d = (pc300dev_t *) dev->priv;
        pc300ch_t *chan = (pc300ch_t *) d->chan;
        pc300_t *card = (pc300_t *) chan->card;
-       uclong flags;
+       unsigned long flags;
 
 #ifdef PC300_DEBUG_OTHER
        printk("pc300: cpc_close");
@@ -3194,7 +3205,7 @@ int cpc_close(struct net_device *dev)
        CPC_UNLOCK(card, flags);
 
        hdlc_close(dev);
-       if (hdlc->proto.id == IF_PROTO_PPP) {
+       if (/* FIXME hdlc->proto.id == IF_PROTO_PPP*/ 0) {
                d->if_ptr = NULL;
        }
 #ifdef CONFIG_PC300_MLPPP
@@ -3211,7 +3222,7 @@ static uclong detect_ram(pc300_t * card)
 {
        uclong i;
        ucchar data;
-       uclong rambase = card->hw.rambase;
+       void __iomem *rambase = card->hw.rambase;
 
        card->hw.ramsize = PC300_RAMSIZE;
        /* Let's find out how much RAM is present on this board */
@@ -3227,7 +3238,7 @@ static uclong detect_ram(pc300_t * card)
 
 static void plx_init(pc300_t * card)
 {
-       struct RUNTIME_9050 *plx_ctl = (struct RUNTIME_9050 *) card->hw.plxbase;
+       struct RUNTIME_9050 __iomem *plx_ctl = card->hw.plxbase;
 
        /* Reset PLX */
        cpc_writel(&plx_ctl->init_ctrl,
@@ -3408,12 +3419,12 @@ static void cpc_init_card(pc300_t * card)
                                        printk("RSV ");
                                        break;
                        }
-                       printk (" #%d, %ldKB of RAM at 0x%08lx, IRQ%d, channel %d.\n",
+                       printk (" #%d, %dKB of RAM at 0x%08x, IRQ%d, channel %d.\n",
                                 board_nbr, card->hw.ramsize / 1024,
                                 card->hw.ramphys, card->hw.irq, i + 1);
                        devcount++;
                } else {
-                       printk ("Dev%d on card(0x%08lx): unable to allocate i/f name.\n",
+                       printk ("Dev%d on card(0x%08x): unable to allocate i/f name.\n",
                                 i + 1, card->hw.ramphys);
                        free_netdev(dev);
                        continue;
@@ -3429,7 +3440,7 @@ cpc_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
 {
        static int first_time = 1;
        ucchar cpc_rev_id;
-       int err = 0, eeprom_outdated = 0;
+       int err, eeprom_outdated = 0;
        ucshort device_id;
        pc300_t *card;
 
@@ -3441,15 +3452,21 @@ cpc_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
 #endif
        }
 
-       card = (pc300_t *) kmalloc(sizeof(pc300_t), GFP_KERNEL);
+       if ((err = pci_enable_device(pdev)) < 0)
+               return err;
+
+       card = kmalloc(sizeof(pc300_t), GFP_KERNEL);
        if (card == NULL) {
-               printk("PC300 found at RAM 0x%08lx, "
+               printk("PC300 found at RAM 0x%016llx, "
                       "but could not allocate card structure.\n",
-                      pci_resource_start(pdev, 3));
-               return -ENOMEM;
+                      (unsigned long long)pci_resource_start(pdev, 3));
+               err = -ENOMEM;
+               goto err_disable_dev;
        }
        memset(card, 0, sizeof(pc300_t));
 
+       err = -ENODEV;
+
        /* read PCI configuration area */
        device_id = ent->device;
        card->hw.irq = pdev->irq;
@@ -3493,7 +3510,7 @@ cpc_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
        if (!request_region(card->hw.iophys, card->hw.iosize, "PLX Registers")) {
                /* In case we can't allocate it, warn user */
                printk("WARNING: couldn't allocate I/O region for PC300 board "
-                      "at 0x%08lx!\n", card->hw.ramphys);
+                      "at 0x%08x!\n", card->hw.ramphys);
        }
 
        if (card->hw.plxphys) {
@@ -3506,36 +3523,29 @@ cpc_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
 
        if (!request_mem_region(card->hw.plxphys, card->hw.plxsize,
                                "PLX Registers")) {
-               printk("PC300 found at RAM 0x%08lx, "
+               printk("PC300 found at RAM 0x%08x, "
                       "but could not allocate PLX mem region.\n",
                       card->hw.ramphys);
-               err = -ENODEV;
                goto err_release_io;
        }
        if (!request_mem_region(card->hw.ramphys, card->hw.alloc_ramsize,
                                "On-board RAM")) {
-               printk("PC300 found at RAM 0x%08lx, "
+               printk("PC300 found at RAM 0x%08x, "
                       "but could not allocate RAM mem region.\n",
                       card->hw.ramphys);
-               err = -ENODEV;
                goto err_release_plx;
        }
        if (!request_mem_region(card->hw.scaphys, card->hw.scasize,
                                "SCA-II Registers")) {
-               printk("PC300 found at RAM 0x%08lx, "
+               printk("PC300 found at RAM 0x%08x, "
                       "but could not allocate SCA mem region.\n",
                       card->hw.ramphys);
-               err = -ENODEV;
                goto err_release_ram;
        }
 
-       if ((err = pci_enable_device(pdev)) != 0)
-               goto err_release_sca;
-
-       card->hw.plxbase = (uclong) ioremap(card->hw.plxphys, card->hw.plxsize);
-       card->hw.rambase = (uclong) ioremap(card->hw.ramphys,
-                                           card->hw.alloc_ramsize);
-       card->hw.scabase = (uclong) ioremap(card->hw.scaphys, card->hw.scasize);
+       card->hw.plxbase = ioremap(card->hw.plxphys, card->hw.plxsize);
+       card->hw.rambase = ioremap(card->hw.ramphys, card->hw.alloc_ramsize);
+       card->hw.scabase = ioremap(card->hw.scaphys, card->hw.scasize);
        switch (device_id) {
                case PCI_DEVICE_ID_PC300_TE_1:
                case PCI_DEVICE_ID_PC300_TE_2:
@@ -3543,14 +3553,13 @@ cpc_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
                case PCI_DEVICE_ID_PC300_TE_M_2:
                        request_mem_region(card->hw.falcphys, card->hw.falcsize,
                                           "FALC Registers");
-                       card->hw.falcbase = (uclong) ioremap(card->hw.falcphys,
-                                                            card->hw.falcsize);
+                       card->hw.falcbase = ioremap(card->hw.falcphys, card->hw.falcsize);
                        break;
 
                case PCI_DEVICE_ID_PC300_RX_1:
                case PCI_DEVICE_ID_PC300_RX_2:
                default:
-                       card->hw.falcbase = 0;
+                       card->hw.falcbase = NULL;
                        break;
        }
 
@@ -3603,8 +3612,8 @@ cpc_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
        }
 
        /* Allocate IRQ */
-       if (request_irq(card->hw.irq, cpc_intr, SA_SHIRQ, "Cyclades-PC300", card)) {
-               printk ("PC300 found at RAM 0x%08lx, but could not allocate IRQ%d.\n",
+       if (request_irq(card->hw.irq, cpc_intr, IRQF_SHARED, "Cyclades-PC300", card)) {
+               printk ("PC300 found at RAM 0x%08x, but could not allocate IRQ%d.\n",
                         card->hw.ramphys, card->hw.irq);
                goto err_io_unmap;
        }
@@ -3616,14 +3625,13 @@ cpc_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
        return 0;
 
 err_io_unmap:
-       iounmap((void *) card->hw.plxbase);
-       iounmap((void *) card->hw.scabase);
-       iounmap((void *) card->hw.rambase);
+       iounmap(card->hw.plxbase);
+       iounmap(card->hw.scabase);
+       iounmap(card->hw.rambase);
        if (card->hw.type == PC300_TE) {
-               iounmap((void *) card->hw.falcbase);
+               iounmap(card->hw.falcbase);
                release_mem_region(card->hw.falcphys, card->hw.falcsize);
        }
-err_release_sca:
        release_mem_region(card->hw.scaphys, card->hw.scasize);
 err_release_ram:
        release_mem_region(card->hw.ramphys, card->hw.alloc_ramsize);
@@ -3632,7 +3640,9 @@ err_release_plx:
 err_release_io:
        release_region(card->hw.iophys, card->hw.iosize);
        kfree(card);
-       return -ENODEV;
+err_disable_dev:
+       pci_disable_device(pdev);
+       return err;
 }
 
 static void __devexit cpc_remove_one(struct pci_dev *pdev)
@@ -3649,15 +3659,15 @@ static void __devexit cpc_remove_one(struct pci_dev *pdev)
                for (i = 0; i < card->hw.nchan; i++) {
                        unregister_hdlc_device(card->chan[i].d.dev);
                }
-               iounmap((void *) card->hw.plxbase);
-               iounmap((void *) card->hw.scabase);
-               iounmap((void *) card->hw.rambase);
+               iounmap(card->hw.plxbase);
+               iounmap(card->hw.scabase);
+               iounmap(card->hw.rambase);
                release_mem_region(card->hw.plxphys, card->hw.plxsize);
                release_mem_region(card->hw.ramphys, card->hw.alloc_ramsize);
                release_mem_region(card->hw.scaphys, card->hw.scasize);
                release_region(card->hw.iophys, card->hw.iosize);
                if (card->hw.type == PC300_TE) {
-                       iounmap((void *) card->hw.falcbase);
+                       iounmap(card->hw.falcbase);
                        release_mem_region(card->hw.falcphys, card->hw.falcsize);
                }
                for (i = 0; i < card->hw.nchan; i++)
@@ -3666,6 +3676,7 @@ static void __devexit cpc_remove_one(struct pci_dev *pdev)
                if (card->hw.irq)
                        free_irq(card->hw.irq, card);
                kfree(card);
+               pci_disable_device(pdev);
        }
 }
 
@@ -3678,7 +3689,7 @@ static struct pci_driver cpc_driver = {
 
 static int __init cpc_init(void)
 {
-       return pci_module_init(&cpc_driver);
+       return pci_register_driver(&cpc_driver);
 }
 
 static void __exit cpc_cleanup_module(void)