aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/irda/sa1100_ir.c
diff options
context:
space:
mode:
authorRussell King <rmk+kernel@arm.linux.org.uk>2012-01-08 12:48:02 -0500
committerRussell King <rmk+kernel@arm.linux.org.uk>2012-02-09 10:37:56 -0500
commit26f2bee1a3063ddd89f76a75b99adb32636f3513 (patch)
treeff38b198d579d620fedf70f8fc38f46ec775a618 /drivers/net/irda/sa1100_ir.c
parenta6b2ea66d630ad0687a1ac25d5a6afb282bd364a (diff)
NET: sa11x0-ir: move sa1100_irda_txdma_irq
Move the FIR DMA transmit completion function along-side the other FIR protocol functions. 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.c108
1 files changed, 53 insertions, 55 deletions
diff --git a/drivers/net/irda/sa1100_ir.c b/drivers/net/irda/sa1100_ir.c
index 61b42d1265b4..0b5a2e2a7be4 100644
--- a/drivers/net/irda/sa1100_ir.c
+++ b/drivers/net/irda/sa1100_ir.c
@@ -261,6 +261,57 @@ static irqreturn_t sa1100_irda_sir_irq(struct net_device *dev, struct sa1100_ird
261/* 261/*
262 * FIR format support. 262 * FIR format support.
263 */ 263 */
264static void sa1100_irda_firtxdma_irq(void *id)
265{
266 struct net_device *dev = id;
267 struct sa1100_irda *si = netdev_priv(dev);
268 struct sk_buff *skb;
269
270 /*
271 * Wait for the transmission to complete. Unfortunately,
272 * the hardware doesn't give us an interrupt to indicate
273 * "end of frame".
274 */
275 do
276 rmb();
277 while (!(Ser2HSSR0 & HSSR0_TUR) || Ser2HSSR1 & HSSR1_TBY);
278
279 /*
280 * Clear the transmit underrun bit.
281 */
282 Ser2HSSR0 = HSSR0_TUR;
283
284 /*
285 * Do we need to change speed? Note that we're lazy
286 * here - we don't free the old dma_rx.skb. We don't need
287 * to allocate a buffer either.
288 */
289 sa1100_irda_check_speed(si);
290
291 /*
292 * Start reception. This disables the transmitter for
293 * us. This will be using the existing RX buffer.
294 */
295 sa1100_irda_rx_dma_start(si);
296
297 /* Account and free the packet. */
298 skb = si->dma_tx.skb;
299 if (skb) {
300 dma_unmap_single(si->dev, si->dma_tx.dma, skb->len,
301 DMA_TO_DEVICE);
302 dev->stats.tx_packets ++;
303 dev->stats.tx_bytes += skb->len;
304 dev_kfree_skb_irq(skb);
305 si->dma_tx.skb = NULL;
306 }
307
308 /*
309 * Make sure that the TX queue is available for sending
310 * (for retries). TX has priority over RX at all times.
311 */
312 netif_wake_queue(dev);
313}
314
264static int sa1100_irda_fir_tx_start(struct sk_buff *skb, struct net_device *dev, 315static int sa1100_irda_fir_tx_start(struct sk_buff *skb, struct net_device *dev,
265 struct sa1100_irda *si) 316 struct sa1100_irda *si)
266{ 317{
@@ -528,60 +579,6 @@ static irqreturn_t sa1100_irda_irq(int irq, void *dev_id)
528 return si->irq(dev, si); 579 return si->irq(dev, si);
529} 580}
530 581
531/*
532 * TX DMA completion handler.
533 */
534static void sa1100_irda_txdma_irq(void *id)
535{
536 struct net_device *dev = id;
537 struct sa1100_irda *si = netdev_priv(dev);
538 struct sk_buff *skb;
539
540 /*
541 * Wait for the transmission to complete. Unfortunately,
542 * the hardware doesn't give us an interrupt to indicate
543 * "end of frame".
544 */
545 do
546 rmb();
547 while (!(Ser2HSSR0 & HSSR0_TUR) || Ser2HSSR1 & HSSR1_TBY);
548
549 /*
550 * Clear the transmit underrun bit.
551 */
552 Ser2HSSR0 = HSSR0_TUR;
553
554 /*
555 * Do we need to change speed? Note that we're lazy
556 * here - we don't free the old dma_rx.skb. We don't need
557 * to allocate a buffer either.
558 */
559 sa1100_irda_check_speed(si);
560
561 /*
562 * Start reception. This disables the transmitter for
563 * us. This will be using the existing RX buffer.
564 */
565 sa1100_irda_rx_dma_start(si);
566
567 /* Account and free the packet. */
568 skb = si->dma_tx.skb;
569 if (skb) {
570 dma_unmap_single(si->dev, si->dma_tx.dma, skb->len,
571 DMA_TO_DEVICE);
572 dev->stats.tx_packets ++;
573 dev->stats.tx_bytes += skb->len;
574 dev_kfree_skb_irq(skb);
575 si->dma_tx.skb = NULL;
576 }
577
578 /*
579 * Make sure that the TX queue is available for sending
580 * (for retries). TX has priority over RX at all times.
581 */
582 netif_wake_queue(dev);
583}
584
585static int sa1100_irda_hard_xmit(struct sk_buff *skb, struct net_device *dev) 582static int sa1100_irda_hard_xmit(struct sk_buff *skb, struct net_device *dev)
586{ 583{
587 struct sa1100_irda *si = netdev_priv(dev); 584 struct sa1100_irda *si = netdev_priv(dev);
@@ -730,7 +727,8 @@ static int sa1100_irda_start(struct net_device *dev)
730 goto err_rx_dma; 727 goto err_rx_dma;
731 728
732 err = sa1100_request_dma(DMA_Ser2HSSPWr, "IrDA transmit", 729 err = sa1100_request_dma(DMA_Ser2HSSPWr, "IrDA transmit",
733 sa1100_irda_txdma_irq, dev, &si->dma_tx.regs); 730 sa1100_irda_firtxdma_irq, dev,
731 &si->dma_tx.regs);
734 if (err) 732 if (err)
735 goto err_tx_dma; 733 goto err_tx_dma;
736 734