vserver 1.9.5.x5
[linux-2.6.git] / drivers / net / irda / nsc-ircc.c
index 2248e66..b9b66a7 100644 (file)
@@ -52,6 +52,7 @@
 #include <linux/slab.h>
 #include <linux/init.h>
 #include <linux/rtnetlink.h>
+#include <linux/dma-mapping.h>
 
 #include <asm/io.h>
 #include <asm/dma.h>
@@ -307,8 +308,9 @@ static int __init nsc_ircc_open(int i, chipio_t *info)
        self->tx_buff.truesize = 14384;
 
        /* Allocate memory if needed */
-       self->rx_buff.head = (__u8 *) kmalloc(self->rx_buff.truesize,
-                                             GFP_KERNEL|GFP_DMA);
+       self->rx_buff.head =
+               dma_alloc_coherent(NULL, self->rx_buff.truesize,
+                                  &self->rx_buff_dma, GFP_KERNEL);
        if (self->rx_buff.head == NULL) {
                err = -ENOMEM;
                goto out2;
@@ -316,8 +318,9 @@ static int __init nsc_ircc_open(int i, chipio_t *info)
        }
        memset(self->rx_buff.head, 0, self->rx_buff.truesize);
        
-       self->tx_buff.head = (__u8 *) kmalloc(self->tx_buff.truesize, 
-                                             GFP_KERNEL|GFP_DMA);
+       self->tx_buff.head =
+               dma_alloc_coherent(NULL, self->tx_buff.truesize,
+                                  &self->tx_buff_dma, GFP_KERNEL);
        if (self->tx_buff.head == NULL) {
                err = -ENOMEM;
                goto out3;
@@ -348,8 +351,9 @@ static int __init nsc_ircc_open(int i, chipio_t *info)
        }
        MESSAGE("IrDA: Registered device %s\n", dev->name);
 
-       /* Check if user has supplied the dongle id or not */
-       if (!dongle_id) {
+       /* Check if user has supplied a valid dongle id or not */
+       if ((dongle_id <= 0) ||
+           (dongle_id >= (sizeof(dongle_types) / sizeof(dongle_types[0]))) ) {
                dongle_id = nsc_ircc_read_dongle_id(self->io.fir_base);
                
                MESSAGE("%s, Found dongle: %s\n", driver_name,
@@ -368,9 +372,11 @@ static int __init nsc_ircc_open(int i, chipio_t *info)
 
        return 0;
  out4:
-       kfree(self->tx_buff.head);
+       dma_free_coherent(NULL, self->tx_buff.truesize,
+                         self->tx_buff.head, self->tx_buff_dma);
  out3:
-       kfree(self->rx_buff.head);
+       dma_free_coherent(NULL, self->rx_buff.truesize,
+                         self->rx_buff.head, self->rx_buff_dma);
  out2:
        release_region(self->io.fir_base, self->io.fir_ext);
  out1:
@@ -404,10 +410,12 @@ static int __exit nsc_ircc_close(struct nsc_ircc_cb *self)
        release_region(self->io.fir_base, self->io.fir_ext);
 
        if (self->tx_buff.head)
-               kfree(self->tx_buff.head);
+               dma_free_coherent(NULL, self->tx_buff.truesize,
+                                 self->tx_buff.head, self->tx_buff_dma);
        
        if (self->rx_buff.head)
-               kfree(self->rx_buff.head);
+               dma_free_coherent(NULL, self->rx_buff.truesize,
+                                 self->rx_buff.head, self->rx_buff_dma);
 
        dev_self[self->index] = NULL;
        free_netdev(self->netdev);
@@ -1409,7 +1417,8 @@ static void nsc_ircc_dma_xmit(struct nsc_ircc_cb *self, int iobase)
        outb(ECR1_DMASWP|ECR1_DMANF|ECR1_EXT_SL, iobase+ECR1);
        
        irda_setup_dma(self->io.dma, 
-                      self->tx_fifo.queue[self->tx_fifo.ptr].start, 
+                      ((u8 *)self->tx_fifo.queue[self->tx_fifo.ptr].start -
+                       self->tx_buff.head) + self->tx_buff_dma,
                       self->tx_fifo.queue[self->tx_fifo.ptr].len, 
                       DMA_TX_MODE);
 
@@ -1566,8 +1575,8 @@ static int nsc_ircc_dma_receive(struct nsc_ircc_cb *self)
        self->st_fifo.len = self->st_fifo.pending_bytes = 0;
        self->st_fifo.tail = self->st_fifo.head = 0;
        
-       irda_setup_dma(self->io.dma, self->rx_buff.data, 
-                      self->rx_buff.truesize, DMA_RX_MODE);
+       irda_setup_dma(self->io.dma, self->rx_buff_dma, self->rx_buff.truesize,
+                      DMA_RX_MODE);
 
        /* Enable DMA */
        switch_bank(iobase, BANK0);
@@ -2197,15 +2206,15 @@ MODULE_DESCRIPTION("NSC IrDA Device Driver");
 MODULE_LICENSE("GPL");
 
 
-MODULE_PARM(qos_mtt_bits, "i");
+module_param(qos_mtt_bits, int, 0);
 MODULE_PARM_DESC(qos_mtt_bits, "Minimum Turn Time");
-MODULE_PARM(io,  "1-4i");
+module_param_array(io, int, NULL, 0);
 MODULE_PARM_DESC(io, "Base I/O addresses");
-MODULE_PARM(irq, "1-4i");
+module_param_array(irq, int, NULL, 0);
 MODULE_PARM_DESC(irq, "IRQ lines");
-MODULE_PARM(dma, "1-4i");
+module_param_array(dma, int, NULL, 0);
 MODULE_PARM_DESC(dma, "DMA channels");
-MODULE_PARM(dongle_id, "i");
+module_param(dongle_id, int, 0);
 MODULE_PARM_DESC(dongle_id, "Type-id of used dongle");
 
 module_init(nsc_ircc_init);