diff options
author | Russell King <rmk+kernel@arm.linux.org.uk> | 2012-01-12 07:45:00 -0500 |
---|---|---|
committer | Russell King <rmk+kernel@arm.linux.org.uk> | 2012-02-09 10:37:57 -0500 |
commit | 32273f50608e9b98116622e32187cbd139c09716 (patch) | |
tree | 0a967d657efb0506848d7b63b1ae635024259805 /drivers/net/irda/sa1100_ir.c | |
parent | 6a7f4911a470fede7d40746487fb1e4a95657efd (diff) |
NET: sa11x0-ir: convert to use scatterlist DMA API
Convert the sa11x0 IrDA driver to use the scatterlist DMA API. This
is a preparatory patch for converting the driver to use the DMA engine
API, which requires a struct scatterlist for every transfer.
Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
Diffstat (limited to 'drivers/net/irda/sa1100_ir.c')
-rw-r--r-- | drivers/net/irda/sa1100_ir.c | 42 |
1 files changed, 21 insertions, 21 deletions
diff --git a/drivers/net/irda/sa1100_ir.c b/drivers/net/irda/sa1100_ir.c index d428dd0a8bce..86d296ed69a7 100644 --- a/drivers/net/irda/sa1100_ir.c +++ b/drivers/net/irda/sa1100_ir.c | |||
@@ -45,7 +45,7 @@ static int max_rate = 4000000; | |||
45 | 45 | ||
46 | struct sa1100_buf { | 46 | struct sa1100_buf { |
47 | struct sk_buff *skb; | 47 | struct sk_buff *skb; |
48 | dma_addr_t dma; | 48 | struct scatterlist sg; |
49 | dma_regs_t *regs; | 49 | dma_regs_t *regs; |
50 | }; | 50 | }; |
51 | 51 | ||
@@ -98,10 +98,8 @@ static int sa1100_irda_rx_alloc(struct sa1100_irda *si) | |||
98 | */ | 98 | */ |
99 | skb_reserve(si->dma_rx.skb, 1); | 99 | skb_reserve(si->dma_rx.skb, 1); |
100 | 100 | ||
101 | si->dma_rx.dma = dma_map_single(si->dev, si->dma_rx.skb->data, | 101 | sg_set_buf(&si->dma_rx.sg, si->dma_rx.skb->data, HPSIR_MAX_RXLEN); |
102 | HPSIR_MAX_RXLEN, | 102 | if (dma_map_sg(si->dev, &si->dma_rx.sg, 1, DMA_FROM_DEVICE) == 0) { |
103 | DMA_FROM_DEVICE); | ||
104 | if (dma_mapping_error(si->dev, si->dma_rx.dma)) { | ||
105 | dev_kfree_skb_any(si->dma_rx.skb); | 103 | dev_kfree_skb_any(si->dma_rx.skb); |
106 | return -ENOMEM; | 104 | return -ENOMEM; |
107 | } | 105 | } |
@@ -129,7 +127,8 @@ static void sa1100_irda_rx_dma_start(struct sa1100_irda *si) | |||
129 | * Enable the DMA, receiver and receive interrupt. | 127 | * Enable the DMA, receiver and receive interrupt. |
130 | */ | 128 | */ |
131 | sa1100_clear_dma(si->dma_rx.regs); | 129 | sa1100_clear_dma(si->dma_rx.regs); |
132 | sa1100_start_dma(si->dma_rx.regs, si->dma_rx.dma, HPSIR_MAX_RXLEN); | 130 | sa1100_start_dma(si->dma_rx.regs, sg_dma_address(&si->dma_rx.sg), |
131 | sg_dma_len(&si->dma_rx.sg)); | ||
133 | Ser2HSCR0 = HSCR0_HSSP | HSCR0_RXE; | 132 | Ser2HSCR0 = HSCR0_HSSP | HSCR0_RXE; |
134 | } | 133 | } |
135 | 134 | ||
@@ -296,8 +295,8 @@ static void sa1100_irda_firtxdma_irq(void *id) | |||
296 | /* Account and free the packet. */ | 295 | /* Account and free the packet. */ |
297 | skb = si->dma_tx.skb; | 296 | skb = si->dma_tx.skb; |
298 | if (skb) { | 297 | if (skb) { |
299 | dma_unmap_single(si->dev, si->dma_tx.dma, skb->len, | 298 | dma_unmap_sg(si->dev, &si->dma_tx.sg, 1, |
300 | DMA_TO_DEVICE); | 299 | DMA_TO_DEVICE); |
301 | dev->stats.tx_packets ++; | 300 | dev->stats.tx_packets ++; |
302 | dev->stats.tx_bytes += skb->len; | 301 | dev->stats.tx_bytes += skb->len; |
303 | dev_kfree_skb_irq(skb); | 302 | dev_kfree_skb_irq(skb); |
@@ -317,9 +316,8 @@ static int sa1100_irda_fir_tx_start(struct sk_buff *skb, struct net_device *dev, | |||
317 | int mtt = irda_get_mtt(skb); | 316 | int mtt = irda_get_mtt(skb); |
318 | 317 | ||
319 | si->dma_tx.skb = skb; | 318 | si->dma_tx.skb = skb; |
320 | si->dma_tx.dma = dma_map_single(si->dev, skb->data, skb->len, | 319 | sg_set_buf(&si->dma_tx.sg, skb->data, skb->len); |
321 | DMA_TO_DEVICE); | 320 | if (dma_map_sg(si->dev, &si->dma_tx.sg, 1, DMA_TO_DEVICE) == 0) { |
322 | if (dma_mapping_error(si->dev, si->dma_tx.dma)) { | ||
323 | si->dma_tx.skb = NULL; | 321 | si->dma_tx.skb = NULL; |
324 | netif_wake_queue(dev); | 322 | netif_wake_queue(dev); |
325 | dev->stats.tx_dropped++; | 323 | dev->stats.tx_dropped++; |
@@ -327,7 +325,8 @@ static int sa1100_irda_fir_tx_start(struct sk_buff *skb, struct net_device *dev, | |||
327 | return NETDEV_TX_OK; | 325 | return NETDEV_TX_OK; |
328 | } | 326 | } |
329 | 327 | ||
330 | sa1100_start_dma(si->dma_tx.regs, si->dma_tx.dma, skb->len); | 328 | sa1100_start_dma(si->dma_tx.regs, sg_dma_address(&si->dma_tx.sg), |
329 | sg_dma_len(&si->dma_tx.sg)); | ||
331 | 330 | ||
332 | /* | 331 | /* |
333 | * If we have a mean turn-around time, impose the specified | 332 | * If we have a mean turn-around time, impose the specified |
@@ -357,10 +356,10 @@ static void sa1100_irda_fir_error(struct sa1100_irda *si, struct net_device *dev | |||
357 | * Get the current data position. | 356 | * Get the current data position. |
358 | */ | 357 | */ |
359 | dma_addr = sa1100_get_dma_pos(si->dma_rx.regs); | 358 | dma_addr = sa1100_get_dma_pos(si->dma_rx.regs); |
360 | len = dma_addr - si->dma_rx.dma; | 359 | len = dma_addr - sg_dma_address(&si->dma_rx.sg); |
361 | if (len > HPSIR_MAX_RXLEN) | 360 | if (len > HPSIR_MAX_RXLEN) |
362 | len = HPSIR_MAX_RXLEN; | 361 | len = HPSIR_MAX_RXLEN; |
363 | dma_unmap_single(si->dev, si->dma_rx.dma, len, DMA_FROM_DEVICE); | 362 | dma_unmap_sg(si->dev, &si->dma_rx.sg, 1, DMA_FROM_DEVICE); |
364 | 363 | ||
365 | do { | 364 | do { |
366 | /* | 365 | /* |
@@ -408,9 +407,7 @@ static void sa1100_irda_fir_error(struct sa1100_irda *si, struct net_device *dev | |||
408 | * Remap the buffer - it was previously mapped, and we | 407 | * Remap the buffer - it was previously mapped, and we |
409 | * hope that this succeeds. | 408 | * hope that this succeeds. |
410 | */ | 409 | */ |
411 | si->dma_rx.dma = dma_map_single(si->dev, si->dma_rx.skb->data, | 410 | dma_map_sg(si->dev, &si->dma_rx.sg, 1, DMA_FROM_DEVICE); |
412 | HPSIR_MAX_RXLEN, | ||
413 | DMA_FROM_DEVICE); | ||
414 | } | 411 | } |
415 | } | 412 | } |
416 | 413 | ||
@@ -786,16 +783,16 @@ static int sa1100_irda_stop(struct net_device *dev) | |||
786 | */ | 783 | */ |
787 | skb = si->dma_rx.skb; | 784 | skb = si->dma_rx.skb; |
788 | if (skb) { | 785 | if (skb) { |
789 | dma_unmap_single(si->dev, si->dma_rx.dma, HPSIR_MAX_RXLEN, | 786 | dma_unmap_sg(si->dev, &si->dma_rx.sg, 1, |
790 | DMA_FROM_DEVICE); | 787 | DMA_FROM_DEVICE); |
791 | dev_kfree_skb(skb); | 788 | dev_kfree_skb(skb); |
792 | si->dma_rx.skb = NULL; | 789 | si->dma_rx.skb = NULL; |
793 | } | 790 | } |
794 | 791 | ||
795 | skb = si->dma_tx.skb; | 792 | skb = si->dma_tx.skb; |
796 | if (skb) { | 793 | if (skb) { |
797 | dma_unmap_single(si->dev, si->dma_tx.dma, skb->len, | 794 | dma_unmap_sg(si->dev, &si->dma_tx.sg, 1, |
798 | DMA_TO_DEVICE); | 795 | DMA_TO_DEVICE); |
799 | dev_kfree_skb(skb); | 796 | dev_kfree_skb(skb); |
800 | si->dma_tx.skb = NULL; | 797 | si->dma_tx.skb = NULL; |
801 | } | 798 | } |
@@ -871,6 +868,9 @@ static int sa1100_irda_probe(struct platform_device *pdev) | |||
871 | si->dev = &pdev->dev; | 868 | si->dev = &pdev->dev; |
872 | si->pdata = pdev->dev.platform_data; | 869 | si->pdata = pdev->dev.platform_data; |
873 | 870 | ||
871 | sg_init_table(&si->dma_rx.sg, 1); | ||
872 | sg_init_table(&si->dma_tx.sg, 1); | ||
873 | |||
874 | /* | 874 | /* |
875 | * Initialise the HP-SIR buffers | 875 | * Initialise the HP-SIR buffers |
876 | */ | 876 | */ |