fedora core 6 1.2949 + vserver 2.2.0
[linux-2.6.git] / drivers / net / wan / pc300_drv.c
index 7a972ca..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);
@@ -378,9 +379,9 @@ static void tx_dma_buf_check(pc300_t * card, int ch)
             i != ((next_bd + 1) & (N_DMA_TX_BUF - 1));
             i = (i + 1) & (N_DMA_TX_BUF - 1), 
                 ptdescr = (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),
+               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");
@@ -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 = (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),
+               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");
@@ -428,16 +429,16 @@ static void rx_dma_buf_check(pc300_t * card, int ch)
                                              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 __iomem *ptdescr;
        ucshort first_bd = card->chan[ch].rx_first_bd;
@@ -462,7 +463,7 @@ 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 __iomem *ptdescr;
@@ -503,7 +504,7 @@ 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];
@@ -560,7 +561,7 @@ 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)
 {
        void __iomem *scabase = card->hw.scabase;
        ucchar drr_ena_bit = 1 << (5 + 2 * ch);
@@ -571,7 +572,7 @@ 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)
 {
        void __iomem *scabase = card->hw.scabase;
        ucchar drr_ena_bit = 1 << (4 + 2 * ch);
@@ -582,7 +583,7 @@ 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)
 {
        void __iomem *scabase = card->hw.scabase;
        pc300ch_t *chan = (pc300ch_t *) & card->chan[ch];
@@ -607,7 +608,7 @@ 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)
 {
        void __iomem *falcbase = card->hw.falcbase;
        unsigned long i = 0;
@@ -622,7 +623,7 @@ 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;
@@ -672,7 +673,7 @@ 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)
 {
        void __iomem *falcbase = card->hw.falcbase;
        ucchar tshf = card->chan[ch].falc.offset;
@@ -688,7 +689,7 @@ 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)
 {
        void __iomem *falcbase = card->hw.falcbase;
        ucchar tshf = card->chan[ch].falc.offset;
@@ -704,7 +705,7 @@ 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;
@@ -726,7 +727,7 @@ 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;
@@ -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,7 +807,7 @@ 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;
@@ -975,7 +976,7 @@ 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;
@@ -1155,7 +1156,7 @@ 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)
 {
        void __iomem *falcbase = card->hw.falcbase;
        pc300ch_t *chan = (pc300ch_t *) & card->chan[ch];
@@ -1181,7 +1182,7 @@ 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;
@@ -1241,7 +1242,7 @@ 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;
@@ -1397,7 +1398,7 @@ 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;
@@ -1450,7 +1451,7 @@ 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;
@@ -1495,7 +1496,7 @@ 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;
@@ -1522,7 +1523,7 @@ 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;
@@ -1576,7 +1577,7 @@ 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;
@@ -1597,7 +1598,7 @@ 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;
@@ -1619,7 +1620,7 @@ 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;
@@ -1652,7 +1653,7 @@ 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;
@@ -1682,7 +1683,7 @@ 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;
@@ -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);
        }
@@ -2016,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);
 
@@ -2049,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);
@@ -2116,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);
                                        }
                                }
@@ -2364,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;
@@ -2404,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;
        void __iomem *scabase = card->hw.scabase;
-       uclong flags;
+       unsigned long flags;
 
        tx_dma_buf_check(card, ch);
        rx_dma_buf_check(card, ch);
@@ -2416,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)),
@@ -2486,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);
@@ -2496,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",
@@ -2524,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;
@@ -2532,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;
@@ -2552,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));
@@ -2588,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:
@@ -2606,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));
                                        }
@@ -2617,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));
@@ -2857,7 +2855,7 @@ 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;
@@ -2869,7 +2867,6 @@ int ch_config(pc300dev_t * d)
        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 */
@@ -2942,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));
@@ -3005,7 +3006,7 @@ 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;
@@ -3036,7 +3037,7 @@ 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;
@@ -3099,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;
+       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);
 
@@ -3115,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;
@@ -3147,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;
@@ -3156,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) {
@@ -3169,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");
@@ -3193,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
@@ -3407,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;
@@ -3428,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;
 
@@ -3440,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;
@@ -3492,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) {
@@ -3505,32 +3523,26 @@ 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 = 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);
@@ -3600,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;
        }
@@ -3620,7 +3632,6 @@ err_io_unmap:
                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);
@@ -3629,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)
@@ -3663,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);
        }
 }
 
@@ -3675,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)