solos: Set RX empty flag at startup only for !dma mode
[safe/jmp/linux-2.6] / drivers / atm / he.c
index 7d9b4e5..bdbad7e 100644 (file)
@@ -1,5 +1,3 @@
-/* $Id: he.c,v 1.18 2003/05/06 22:57:15 chas Exp $ */
-
 /*
 
   he.c
 #include <linux/atm.h>
 #include <linux/sonet.h>
 
-#define USE_TASKLET
 #undef USE_SCATTERGATHER
 #undef USE_CHECKSUM_HW                 /* still confused about this */
-#define USE_RBPS
-#undef USE_RBPS_POOL                   /* if memory is tight try this */
-#undef USE_RBPL_POOL                   /* if memory is tight try this */
-#define USE_TPD_POOL
-/* #undef CONFIG_ATM_HE_USE_SUNI */
 /* #undef HE_DEBUG */
 
 #include "he.h"
 #define HPRINTK(fmt,args...)   do { } while (0)
 #endif /* HE_DEBUG */
 
-/* version definition */
-
-static char *version = "$Id: he.c,v 1.18 2003/05/06 22:57:15 chas Exp $";
-
 /* declarations */
 
 static int he_open(struct atm_vcc *vcc);
@@ -366,7 +354,7 @@ he_init_one(struct pci_dev *pci_dev, const struct pci_device_id *pci_ent)
        struct he_dev *he_dev = NULL;
        int err = 0;
 
-       printk(KERN_INFO "he: %s\n", version);
+       printk(KERN_INFO "ATM he driver\n");
 
        if (pci_enable_device(pci_dev))
                return -EIO;
@@ -394,6 +382,9 @@ he_init_one(struct pci_dev *pci_dev, const struct pci_device_id *pci_ent)
        he_dev->atm_dev->dev_data = he_dev;
        atm_dev->dev_data = he_dev;
        he_dev->number = atm_dev->number;
+       tasklet_init(&he_dev->tasklet, he_tasklet, (unsigned long) he_dev);
+       spin_lock_init(&he_dev->global_lock);
+
        if (he_start(atm_dev)) {
                he_stop(he_dev);
                err = -ENODEV;
@@ -788,23 +779,13 @@ he_init_group(struct he_dev *he_dev, int group)
 {
        int i;
 
-#ifdef USE_RBPS
        /* small buffer pool */
-#ifdef USE_RBPS_POOL
        he_dev->rbps_pool = pci_pool_create("rbps", he_dev->pci_dev,
                        CONFIG_RBPS_BUFSIZE, 8, 0);
        if (he_dev->rbps_pool == NULL) {
                hprintk("unable to create rbps pages\n");
                return -ENOMEM;
        }
-#else /* !USE_RBPS_POOL */
-       he_dev->rbps_pages = pci_alloc_consistent(he_dev->pci_dev,
-               CONFIG_RBPS_SIZE * CONFIG_RBPS_BUFSIZE, &he_dev->rbps_pages_phys);
-       if (he_dev->rbps_pages == NULL) {
-               hprintk("unable to create rbps page pool\n");
-               return -ENOMEM;
-       }
-#endif /* USE_RBPS_POOL */
 
        he_dev->rbps_base = pci_alloc_consistent(he_dev->pci_dev,
                CONFIG_RBPS_SIZE * sizeof(struct he_rbp), &he_dev->rbps_phys);
@@ -819,14 +800,9 @@ he_init_group(struct he_dev *he_dev, int group)
                dma_addr_t dma_handle;
                void *cpuaddr;
 
-#ifdef USE_RBPS_POOL 
                cpuaddr = pci_pool_alloc(he_dev->rbps_pool, GFP_KERNEL|GFP_DMA, &dma_handle);
                if (cpuaddr == NULL)
                        return -ENOMEM;
-#else
-               cpuaddr = he_dev->rbps_pages + (i * CONFIG_RBPS_BUFSIZE);
-               dma_handle = he_dev->rbps_pages_phys + (i * CONFIG_RBPS_BUFSIZE);
-#endif
 
                he_dev->rbps_virt[i].virt = cpuaddr;
                he_dev->rbps_base[i].status = RBP_LOANED | RBP_SMALLBUF | (i << RBP_INDEX_OFF);
@@ -845,30 +821,14 @@ he_init_group(struct he_dev *he_dev, int group)
                        RBP_QSIZE(CONFIG_RBPS_SIZE - 1) |
                        RBP_INT_ENB,
                                                G0_RBPS_QI + (group * 32));
-#else /* !USE_RBPS */
-       he_writel(he_dev, 0x0, G0_RBPS_S + (group * 32));
-       he_writel(he_dev, 0x0, G0_RBPS_T + (group * 32));
-       he_writel(he_dev, 0x0, G0_RBPS_QI + (group * 32));
-       he_writel(he_dev, RBP_THRESH(0x1) | RBP_QSIZE(0x0),
-                                               G0_RBPS_BS + (group * 32));
-#endif /* USE_RBPS */
 
        /* large buffer pool */
-#ifdef USE_RBPL_POOL
        he_dev->rbpl_pool = pci_pool_create("rbpl", he_dev->pci_dev,
                        CONFIG_RBPL_BUFSIZE, 8, 0);
        if (he_dev->rbpl_pool == NULL) {
                hprintk("unable to create rbpl pool\n");
                return -ENOMEM;
        }
-#else /* !USE_RBPL_POOL */
-       he_dev->rbpl_pages = (void *) pci_alloc_consistent(he_dev->pci_dev,
-               CONFIG_RBPL_SIZE * CONFIG_RBPL_BUFSIZE, &he_dev->rbpl_pages_phys);
-       if (he_dev->rbpl_pages == NULL) {
-               hprintk("unable to create rbpl pages\n");
-               return -ENOMEM;
-       }
-#endif /* USE_RBPL_POOL */
 
        he_dev->rbpl_base = pci_alloc_consistent(he_dev->pci_dev,
                CONFIG_RBPL_SIZE * sizeof(struct he_rbp), &he_dev->rbpl_phys);
@@ -883,14 +843,9 @@ he_init_group(struct he_dev *he_dev, int group)
                dma_addr_t dma_handle;
                void *cpuaddr;
 
-#ifdef USE_RBPL_POOL
                cpuaddr = pci_pool_alloc(he_dev->rbpl_pool, GFP_KERNEL|GFP_DMA, &dma_handle);
                if (cpuaddr == NULL)
                        return -ENOMEM;
-#else
-               cpuaddr = he_dev->rbpl_pages + (i * CONFIG_RBPL_BUFSIZE);
-               dma_handle = he_dev->rbpl_pages_phys + (i * CONFIG_RBPL_BUFSIZE);
-#endif
 
                he_dev->rbpl_virt[i].virt = cpuaddr;
                he_dev->rbpl_base[i].status = RBP_LOANED | (i << RBP_INDEX_OFF);
@@ -1173,11 +1128,6 @@ he_start(struct atm_dev *dev)
        if ((err = he_init_irq(he_dev)) != 0)
                return err;
 
-#ifdef USE_TASKLET
-       tasklet_init(&he_dev->tasklet, he_tasklet, (unsigned long) he_dev);
-#endif
-       spin_lock_init(&he_dev->global_lock);
-
        /* 4.11 enable pci bus controller state machines */
        host_cntl |= (OUTFF_ENB | CMDFF_ENB |
                                QUICK_RD_RETRY | QUICK_WR_RETRY | PERR_INT_ENB);
@@ -1481,7 +1431,6 @@ he_start(struct atm_dev *dev)
 
        he_init_tpdrq(he_dev);
 
-#ifdef USE_TPD_POOL
        he_dev->tpd_pool = pci_pool_create("tpd", he_dev->pci_dev,
                sizeof(struct he_tpd), TPD_ALIGNMENT, 0);
        if (he_dev->tpd_pool == NULL) {
@@ -1490,20 +1439,6 @@ he_start(struct atm_dev *dev)
        }
 
        INIT_LIST_HEAD(&he_dev->outstanding_tpds);
-#else
-       he_dev->tpd_base = (void *) pci_alloc_consistent(he_dev->pci_dev,
-                       CONFIG_NUMTPDS * sizeof(struct he_tpd), &he_dev->tpd_base_phys);
-       if (!he_dev->tpd_base)
-               return -ENOMEM;
-
-       for (i = 0; i < CONFIG_NUMTPDS; ++i) {
-               he_dev->tpd_base[i].status = (i << TPD_ADDR_SHIFT);
-               he_dev->tpd_base[i].inuse = 0;
-       }
-               
-       he_dev->tpd_head = he_dev->tpd_base;
-       he_dev->tpd_end = &he_dev->tpd_base[CONFIG_NUMTPDS - 1];
-#endif
 
        if (he_init_group(he_dev, 0) != 0)
                return -ENOMEM;
@@ -1548,7 +1483,8 @@ he_start(struct atm_dev *dev)
        /* initialize framer */
 
 #ifdef CONFIG_ATM_HE_USE_SUNI
-       suni_init(he_dev->atm_dev);
+       if (he_isMM(he_dev))
+               suni_init(he_dev->atm_dev);
        if (he_dev->atm_dev->phy && he_dev->atm_dev->phy->start)
                he_dev->atm_dev->phy->start(he_dev->atm_dev);
 #endif /* CONFIG_ATM_HE_USE_SUNI */
@@ -1560,6 +1496,7 @@ he_start(struct atm_dev *dev)
                val = he_phy_get(he_dev->atm_dev, SUNI_TPOP_APM);
                val = (val & ~SUNI_TPOP_APM_S) | (SUNI_TPOP_S_SDH << SUNI_TPOP_APM_S_SHIFT);
                he_phy_put(he_dev->atm_dev, val, SUNI_TPOP_APM);
+               he_phy_put(he_dev->atm_dev, SUNI_TACP_IUCHP_CLP, SUNI_TACP_IUCHP);
        }
 
        /* 5.1.12 enable transmit and receive */
@@ -1610,9 +1547,7 @@ he_stop(struct he_dev *he_dev)
                gen_cntl_0 &= ~(INT_PROC_ENBL | INIT_ENB);
                pci_write_config_dword(pci_dev, GEN_CNTL_0, gen_cntl_0);
 
-#ifdef USE_TASKLET
                tasklet_disable(&he_dev->tasklet);
-#endif
 
                /* disable recv and transmit */
 
@@ -1642,49 +1577,36 @@ he_stop(struct he_dev *he_dev)
                                                he_dev->hsp, he_dev->hsp_phys);
 
        if (he_dev->rbpl_base) {
-#ifdef USE_RBPL_POOL
+               int i;
+
                for (i = 0; i < CONFIG_RBPL_SIZE; ++i) {
                        void *cpuaddr = he_dev->rbpl_virt[i].virt;
                        dma_addr_t dma_handle = he_dev->rbpl_base[i].phys;
 
                        pci_pool_free(he_dev->rbpl_pool, cpuaddr, dma_handle);
                }
-#else
-               pci_free_consistent(he_dev->pci_dev, CONFIG_RBPL_SIZE
-                       * CONFIG_RBPL_BUFSIZE, he_dev->rbpl_pages, he_dev->rbpl_pages_phys);
-#endif
                pci_free_consistent(he_dev->pci_dev, CONFIG_RBPL_SIZE
                        * sizeof(struct he_rbp), he_dev->rbpl_base, he_dev->rbpl_phys);
        }
 
-#ifdef USE_RBPL_POOL
        if (he_dev->rbpl_pool)
                pci_pool_destroy(he_dev->rbpl_pool);
-#endif
 
-#ifdef USE_RBPS
        if (he_dev->rbps_base) {
-#ifdef USE_RBPS_POOL
+               int i;
+
                for (i = 0; i < CONFIG_RBPS_SIZE; ++i) {
                        void *cpuaddr = he_dev->rbps_virt[i].virt;
                        dma_addr_t dma_handle = he_dev->rbps_base[i].phys;
 
                        pci_pool_free(he_dev->rbps_pool, cpuaddr, dma_handle);
                }
-#else
-               pci_free_consistent(he_dev->pci_dev, CONFIG_RBPS_SIZE
-                       * CONFIG_RBPS_BUFSIZE, he_dev->rbps_pages, he_dev->rbps_pages_phys);
-#endif
                pci_free_consistent(he_dev->pci_dev, CONFIG_RBPS_SIZE
                        * sizeof(struct he_rbp), he_dev->rbps_base, he_dev->rbps_phys);
        }
 
-#ifdef USE_RBPS_POOL
        if (he_dev->rbps_pool)
                pci_pool_destroy(he_dev->rbps_pool);
-#endif
-
-#endif /* USE_RBPS */
 
        if (he_dev->rbrq_base)
                pci_free_consistent(he_dev->pci_dev, CONFIG_RBRQ_SIZE * sizeof(struct he_rbrq),
@@ -1698,14 +1620,8 @@ he_stop(struct he_dev *he_dev)
                pci_free_consistent(he_dev->pci_dev, CONFIG_TBRQ_SIZE * sizeof(struct he_tbrq),
                                                        he_dev->tpdrq_base, he_dev->tpdrq_phys);
 
-#ifdef USE_TPD_POOL
        if (he_dev->tpd_pool)
                pci_pool_destroy(he_dev->tpd_pool);
-#else
-       if (he_dev->tpd_base)
-               pci_free_consistent(he_dev->pci_dev, CONFIG_NUMTPDS * sizeof(struct he_tpd),
-                                                       he_dev->tpd_base, he_dev->tpd_base_phys);
-#endif
 
        if (he_dev->pci_dev) {
                pci_read_config_word(he_dev->pci_dev, PCI_COMMAND, &command);
@@ -1720,7 +1636,6 @@ he_stop(struct he_dev *he_dev)
 static struct he_tpd *
 __alloc_tpd(struct he_dev *he_dev)
 {
-#ifdef USE_TPD_POOL
        struct he_tpd *tpd;
        dma_addr_t dma_handle; 
 
@@ -1735,27 +1650,6 @@ __alloc_tpd(struct he_dev *he_dev)
        tpd->iovec[2].addr = 0; tpd->iovec[2].len = 0;
 
        return tpd;
-#else
-       int i;
-
-       for (i = 0; i < CONFIG_NUMTPDS; ++i) {
-               ++he_dev->tpd_head;
-               if (he_dev->tpd_head > he_dev->tpd_end) {
-                       he_dev->tpd_head = he_dev->tpd_base;
-               }
-
-               if (!he_dev->tpd_head->inuse) {
-                       he_dev->tpd_head->inuse = 1;
-                       he_dev->tpd_head->status &= TPD_MASK;
-                       he_dev->tpd_head->iovec[0].addr = 0; he_dev->tpd_head->iovec[0].len = 0;
-                       he_dev->tpd_head->iovec[1].addr = 0; he_dev->tpd_head->iovec[1].len = 0;
-                       he_dev->tpd_head->iovec[2].addr = 0; he_dev->tpd_head->iovec[2].len = 0;
-                       return he_dev->tpd_head;
-               }
-       }
-       hprintk("out of tpds -- increase CONFIG_NUMTPDS (%d)\n", CONFIG_NUMTPDS);
-       return NULL;
-#endif
 }
 
 #define AAL5_LEN(buf,len)                                              \
@@ -1804,11 +1698,9 @@ he_service_rbrq(struct he_dev *he_dev, int group)
                        RBRQ_CON_CLOSED(he_dev->rbrq_head) ? " CON_CLOSED" : "",
                        RBRQ_HBUF_ERR(he_dev->rbrq_head) ? " HBUF_ERR" : "");
 
-#ifdef USE_RBPS
                if (RBRQ_ADDR(he_dev->rbrq_head) & RBP_SMALLBUF)
                        rbp = &he_dev->rbps_base[RBP_INDEX(RBRQ_ADDR(he_dev->rbrq_head))];
                else
-#endif
                        rbp = &he_dev->rbpl_base[RBP_INDEX(RBRQ_ADDR(he_dev->rbrq_head))];
                
                buf_len = RBRQ_BUFLEN(he_dev->rbrq_head) * 4;
@@ -1887,12 +1779,10 @@ he_service_rbrq(struct he_dev *he_dev, int group)
 
                for (iov = he_vcc->iov_head;
                                iov < he_vcc->iov_tail; ++iov) {
-#ifdef USE_RBPS
                        if (iov->iov_base & RBP_SMALLBUF)
                                memcpy(skb_put(skb, iov->iov_len),
                                        he_dev->rbps_virt[RBP_INDEX(iov->iov_base)].virt, iov->iov_len);
                        else
-#endif
                                memcpy(skb_put(skb, iov->iov_len),
                                        he_dev->rbpl_virt[RBP_INDEX(iov->iov_base)].virt, iov->iov_len);
                }
@@ -1901,13 +1791,13 @@ he_service_rbrq(struct he_dev *he_dev, int group)
                        case ATM_AAL0:
                                /* 2.10.1.5 raw cell receive */
                                skb->len = ATM_AAL0_SDU;
-                               skb->tail = skb->data + skb->len;
+                               skb_set_tail_pointer(skb, skb->len);
                                break;
                        case ATM_AAL5:
                                /* 2.10.1.2 aal5 receive */
 
                                skb->len = AAL5_LEN(skb->data, he_vcc->pdu_len);
-                               skb->tail = skb->data + skb->len;
+                               skb_set_tail_pointer(skb, skb->len);
 #ifdef USE_CHECKSUM_HW
                                if (vcc->vpi == 0 && vcc->vci >= ATM_NOT_RSV_VCI) {
                                        skb->ip_summed = CHECKSUM_COMPLETE;
@@ -1937,11 +1827,9 @@ return_host_buffers:
 
                for (iov = he_vcc->iov_head;
                                iov < he_vcc->iov_tail; ++iov) {
-#ifdef USE_RBPS
                        if (iov->iov_base & RBP_SMALLBUF)
                                rbp = &he_dev->rbps_base[RBP_INDEX(iov->iov_base)];
                        else
-#endif
                                rbp = &he_dev->rbpl_base[RBP_INDEX(iov->iov_base)];
 
                        rbp->status &= ~RBP_LOANED;
@@ -1977,9 +1865,7 @@ he_service_tbrq(struct he_dev *he_dev, int group)
                                        he_dev->hsp->group[group].tbrq_tail);
        struct he_tpd *tpd;
        int slot, updated = 0;
-#ifdef USE_TPD_POOL
        struct he_tpd *__tpd;
-#endif
 
        /* 2.1.6 transmit buffer return queue */
 
@@ -1991,7 +1877,6 @@ he_service_tbrq(struct he_dev *he_dev, int group)
                        TBRQ_TPD(he_dev->tbrq_head), 
                        TBRQ_EOS(he_dev->tbrq_head) ? " EOS" : "",
                        TBRQ_MULTIPLE(he_dev->tbrq_head) ? " MULTIPLE" : "");
-#ifdef USE_TPD_POOL
                tpd = NULL;
                list_for_each_entry(__tpd, &he_dev->outstanding_tpds, entry) {
                        if (TPD_ADDR(__tpd->status) == TBRQ_TPD(he_dev->tbrq_head)) {
@@ -2006,9 +1891,6 @@ he_service_tbrq(struct he_dev *he_dev, int group)
                                                TBRQ_TPD(he_dev->tbrq_head));
                        goto next_tbrq_entry;
                }
-#else
-               tpd = &he_dev->tpd_base[ TPD_INDEX(TBRQ_TPD(he_dev->tbrq_head)) ];
-#endif
 
                if (TBRQ_EOS(he_dev->tbrq_head)) {
                        HPRINTK("wake_up(tx_waitq) cid 0x%x\n",
@@ -2038,12 +1920,8 @@ he_service_tbrq(struct he_dev *he_dev, int group)
                }
 
 next_tbrq_entry:
-#ifdef USE_TPD_POOL
                if (tpd)
                        pci_pool_free(he_dev->tpd_pool, tpd, TPD_ADDR(tpd->status));
-#else
-               tpd->inuse = 0;
-#endif
                he_dev->tbrq_head = (struct he_tbrq *)
                                ((unsigned long) he_dev->tbrq_base |
                                        TBRQ_MASK(++he_dev->tbrq_head));
@@ -2086,7 +1964,6 @@ he_service_rbpl(struct he_dev *he_dev, int group)
                he_writel(he_dev, RBPL_MASK(he_dev->rbpl_tail), G0_RBPL_T);
 }
 
-#ifdef USE_RBPS
 static void
 he_service_rbps(struct he_dev *he_dev, int group)
 {
@@ -2113,7 +1990,6 @@ he_service_rbps(struct he_dev *he_dev, int group)
        if (moved)
                he_writel(he_dev, RBPS_MASK(he_dev->rbps_tail), G0_RBPS_T);
 }
-#endif /* USE_RBPS */
 
 static void
 he_tasklet(unsigned long data)
@@ -2124,9 +2000,7 @@ he_tasklet(unsigned long data)
        int updated = 0;
 
        HPRINTK("tasklet (0x%lx)\n", data);
-#ifdef USE_TASKLET
        spin_lock_irqsave(&he_dev->global_lock, flags);
-#endif
 
        while (he_dev->irq_head != he_dev->irq_tail) {
                ++updated;
@@ -2141,9 +2015,7 @@ he_tasklet(unsigned long data)
                        case ITYPE_RBRQ_TIMER:
                                if (he_service_rbrq(he_dev, group)) {
                                        he_service_rbpl(he_dev, group);
-#ifdef USE_RBPS
                                        he_service_rbps(he_dev, group);
-#endif /* USE_RBPS */
                                }
                                break;
                        case ITYPE_TBRQ_THRESH:
@@ -2156,9 +2028,7 @@ he_tasklet(unsigned long data)
                                he_service_rbpl(he_dev, group);
                                break;
                        case ITYPE_RBPS_THRESH:
-#ifdef USE_RBPS
                                he_service_rbps(he_dev, group);
-#endif /* USE_RBPS */
                                break;
                        case ITYPE_PHY:
                                HPRINTK("phy interrupt\n");
@@ -2186,9 +2056,7 @@ he_tasklet(unsigned long data)
 
                                he_service_rbrq(he_dev, 0);
                                he_service_rbpl(he_dev, 0);
-#ifdef USE_RBPS
                                he_service_rbps(he_dev, 0);
-#endif /* USE_RBPS */
                                he_service_tbrq(he_dev, 0);
                                break;
                        default:
@@ -2210,9 +2078,7 @@ he_tasklet(unsigned long data)
                        IRQ_TAIL(he_dev->irq_tail), IRQ0_HEAD);
                (void) he_readl(he_dev, INT_FIFO); /* 8.1.2 controller errata; flush posted writes */
        }
-#ifdef USE_TASKLET
        spin_unlock_irqrestore(&he_dev->global_lock, flags);
-#endif
 }
 
 static irqreturn_t
@@ -2244,11 +2110,7 @@ he_irq_handler(int irq, void *dev_id)
 
        if (he_dev->irq_head != he_dev->irq_tail) {
                handled = 1;
-#ifdef USE_TASKLET
                tasklet_schedule(&he_dev->tasklet);
-#else
-               he_tasklet((unsigned long) he_dev);
-#endif
                he_writel(he_dev, INT_CLEAR_A, INT_FIFO);       /* clear interrupt */
                (void) he_readl(he_dev, INT_FIFO);              /* flush posted writes */
        }
@@ -2305,23 +2167,14 @@ __enqueue_tpd(struct he_dev *he_dev, struct he_tpd *tpd, unsigned cid)
                                        dev_kfree_skb_any(tpd->skb);
                                atomic_inc(&tpd->vcc->stats->tx_err);
                        }
-#ifdef USE_TPD_POOL
                        pci_pool_free(he_dev->tpd_pool, tpd, TPD_ADDR(tpd->status));
-#else
-                       tpd->inuse = 0;
-#endif
                        return;
                }
        }
 
        /* 2.1.5 transmit packet descriptor ready queue */
-#ifdef USE_TPD_POOL
        list_add_tail(&tpd->entry, &he_dev->outstanding_tpds);
        he_dev->tpdrq_tail->tpd = TPD_ADDR(tpd->status);
-#else
-       he_dev->tpdrq_tail->tpd = he_dev->tpd_base_phys +
-                               (TPD_INDEX(tpd->status) * sizeof(struct he_tpd));
-#endif
        he_dev->tpdrq_tail->cid = cid;
        wmb();
 
@@ -2351,7 +2204,7 @@ he_open(struct atm_vcc *vcc)
 
        cid = he_mkcid(he_dev, vpi, vci);
 
-       he_vcc = (struct he_vcc *) kmalloc(sizeof(struct he_vcc), GFP_ATOMIC);
+       he_vcc = kmalloc(sizeof(struct he_vcc), GFP_ATOMIC);
        if (he_vcc == NULL) {
                hprintk("unable to allocate he_vcc during open\n");
                return -ENOMEM;
@@ -2511,13 +2364,8 @@ he_open(struct atm_vcc *vcc)
                        goto open_failed;
                }
 
-#ifdef USE_RBPS
                rsr1 = RSR1_GROUP(0);
                rsr4 = RSR4_GROUP(0);
-#else /* !USE_RBPS */
-               rsr1 = RSR1_GROUP(0)|RSR1_RBPL_ONLY;
-               rsr4 = RSR4_GROUP(0)|RSR4_RBPL_ONLY;
-#endif /* USE_RBPS */
                rsr0 = vcc->qos.rxtp.traffic_class == ATM_UBR ? 
                                (RSR0_EPD_ENABLE|RSR0_PPD_ENABLE) : 0;
 
@@ -2846,10 +2694,15 @@ he_ioctl(struct atm_dev *atm_dev, unsigned int cmd, void __user *arg)
                        if (copy_from_user(&reg, arg,
                                           sizeof(struct he_ioctl_reg)))
                                return -EFAULT;
-                       
+
                        spin_lock_irqsave(&he_dev->global_lock, flags);
                        switch (reg.type) {
                                case HE_REGTYPE_PCI:
+                                       if (reg.addr < 0 || reg.addr >= HE_REGMAP_SIZE) {
+                                               err = -EINVAL;
+                                               break;
+                                       }
+
                                        reg.val = he_readl(he_dev, reg.addr);
                                        break;
                                case HE_REGTYPE_RCM:
@@ -2933,7 +2786,7 @@ he_proc_read(struct atm_dev *dev, loff_t *pos, char *page)
 
        left = *pos;
        if (!left--)
-               return sprintf(page, "%s\n", version);
+               return sprintf(page, "ATM he driver\n");
 
        if (!left--)
                return sprintf(page, "%s%s\n\n",
@@ -3002,8 +2855,7 @@ he_proc_read(struct atm_dev *dev, loff_t *pos, char *page)
 
 /* eeprom routines  -- see 4.7 */
 
-u8
-read_prom_byte(struct he_dev *he_dev, int addr)
+static u8 read_prom_byte(struct he_dev *he_dev, int addr)
 {
        u32 val = 0, tmp_read = 0;
        int i, j = 0;
@@ -3017,7 +2869,7 @@ read_prom_byte(struct he_dev *he_dev, int addr)
        he_writel(he_dev, val, HOST_CNTL);
        
        /* Send READ instruction */
-       for (i = 0; i < sizeof(readtab)/sizeof(readtab[0]); i++) {
+       for (i = 0; i < ARRAY_SIZE(readtab); i++) {
                he_writel(he_dev, val | readtab[i], HOST_CNTL);
                udelay(EEPROM_DELAY);
        }