NET: sa11x0-ir: split si->dev for IrDA transmit and receive buffers
authorRussell King <rmk+kernel@arm.linux.org.uk>
Thu, 12 Jan 2012 13:56:28 +0000 (13:56 +0000)
committerRussell King <rmk+kernel@arm.linux.org.uk>
Thu, 9 Feb 2012 15:37:57 +0000 (15:37 +0000)
The sa11x0-ir device is not the device which is doing the DMA, the
DMA is being performed by a separate DMA engine.  Split the struct
device associated with each DMA channel from the main struct device,
but for the time being initialize it from the main struct device.

This is another preparatory step to converting this driver to use the
DMA engine API.

Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
drivers/net/irda/sa1100_ir.c

index be67bdc0ca0281401cf1f2f01184f64eb9e7b19e..9c748f38b9d587925bb68caeb98850b205662db6 100644 (file)
@@ -44,6 +44,7 @@ static int tx_lpm;
 static int max_rate = 4000000;
 
 struct sa1100_buf {
+       struct device           *dev;
        struct sk_buff          *skb;
        struct scatterlist      sg;
        dma_regs_t              *regs;
@@ -99,7 +100,7 @@ static int sa1100_irda_rx_alloc(struct sa1100_irda *si)
        skb_reserve(si->dma_rx.skb, 1);
 
        sg_set_buf(&si->dma_rx.sg, si->dma_rx.skb->data, HPSIR_MAX_RXLEN);
-       if (dma_map_sg(si->dev, &si->dma_rx.sg, 1, DMA_FROM_DEVICE) == 0) {
+       if (dma_map_sg(si->dma_rx.dev, &si->dma_rx.sg, 1, DMA_FROM_DEVICE) == 0) {
                dev_kfree_skb_any(si->dma_rx.skb);
                return -ENOMEM;
        }
@@ -295,7 +296,7 @@ static void sa1100_irda_firtxdma_irq(void *id)
        /* Account and free the packet. */
        skb = si->dma_tx.skb;
        if (skb) {
-               dma_unmap_sg(si->dev, &si->dma_tx.sg, 1,
+               dma_unmap_sg(si->dma_tx.dev, &si->dma_tx.sg, 1,
                             DMA_TO_DEVICE);
                dev->stats.tx_packets ++;
                dev->stats.tx_bytes += skb->len;
@@ -317,7 +318,7 @@ static int sa1100_irda_fir_tx_start(struct sk_buff *skb, struct net_device *dev,
 
        si->dma_tx.skb = skb;
        sg_set_buf(&si->dma_tx.sg, skb->data, skb->len);
-       if (dma_map_sg(si->dev, &si->dma_tx.sg, 1, DMA_TO_DEVICE) == 0) {
+       if (dma_map_sg(si->dma_tx.dev, &si->dma_tx.sg, 1, DMA_TO_DEVICE) == 0) {
                si->dma_tx.skb = NULL;
                netif_wake_queue(dev);
                dev->stats.tx_dropped++;
@@ -359,7 +360,7 @@ static void sa1100_irda_fir_error(struct sa1100_irda *si, struct net_device *dev
        len = dma_addr - sg_dma_address(&si->dma_rx.sg);
        if (len > HPSIR_MAX_RXLEN)
                len = HPSIR_MAX_RXLEN;
-       dma_unmap_sg(si->dev, &si->dma_rx.sg, 1, DMA_FROM_DEVICE);
+       dma_unmap_sg(si->dma_rx.dev, &si->dma_rx.sg, 1, DMA_FROM_DEVICE);
 
        do {
                /*
@@ -407,7 +408,7 @@ static void sa1100_irda_fir_error(struct sa1100_irda *si, struct net_device *dev
                 * Remap the buffer - it was previously mapped, and we
                 * hope that this succeeds.
                 */
-               dma_map_sg(si->dev, &si->dma_rx.sg, 1, DMA_FROM_DEVICE);
+               dma_map_sg(si->dma_rx.dev, &si->dma_rx.sg, 1, DMA_FROM_DEVICE);
        }
 }
 
@@ -726,6 +727,9 @@ static int sa1100_irda_start(struct net_device *dev)
        if (err)
                goto err_tx_dma;
 
+       si->dma_rx.dev = si->dev;
+       si->dma_tx.dev = si->dev;
+
        /*
         * Setup the serial port for the specified speed.
         */
@@ -783,7 +787,7 @@ static int sa1100_irda_stop(struct net_device *dev)
         */
        skb = si->dma_rx.skb;
        if (skb) {
-               dma_unmap_sg(si->dev, &si->dma_rx.sg, 1,
+               dma_unmap_sg(si->dma_rx.dev, &si->dma_rx.sg, 1,
                             DMA_FROM_DEVICE);
                dev_kfree_skb(skb);
                si->dma_rx.skb = NULL;
@@ -791,7 +795,7 @@ static int sa1100_irda_stop(struct net_device *dev)
 
        skb = si->dma_tx.skb;
        if (skb) {
-               dma_unmap_sg(si->dev, &si->dma_tx.sg, 1,
+               dma_unmap_sg(si->dma_tx.dev, &si->dma_tx.sg, 1,
                             DMA_TO_DEVICE);
                dev_kfree_skb(skb);
                si->dma_tx.skb = NULL;
This page took 0.030034 seconds and 5 git commands to generate.