VServer 1.9.2 (patch-2.6.8.1-vs1.9.2.diff)
[linux-2.6.git] / drivers / net / irda / nsc-ircc.c
index 2248e66..c1e79f5 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;
@@ -368,9 +371,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 +409,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 +1416,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 +1574,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);