aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authorRussell King <rmk+kernel@arm.linux.org.uk>2012-01-08 11:26:15 -0500
committerRussell King <rmk+kernel@arm.linux.org.uk>2012-02-09 10:37:56 -0500
commit374f77390ca99b401ee121616524ed32c54d5ad6 (patch)
tree05842d8761113b0bd485adb012511d1b26dc4d7b /drivers
parent3d26db137ac3169623a132ea310d26af6a48bf88 (diff)
NET: sa11x0-ir: indirect handling of SIR and FIR interrupts
Use the same method for doing this as we do for the tx_start functions. Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/net/irda/sa1100_ir.c50
1 files changed, 24 insertions, 26 deletions
diff --git a/drivers/net/irda/sa1100_ir.c b/drivers/net/irda/sa1100_ir.c
index 8b8cf4152604..32dee3322679 100644
--- a/drivers/net/irda/sa1100_ir.c
+++ b/drivers/net/irda/sa1100_ir.c
@@ -70,6 +70,7 @@ struct sa1100_irda {
70 iobuff_t rx_buff; 70 iobuff_t rx_buff;
71 71
72 int (*tx_start)(struct sk_buff *, struct net_device *, struct sa1100_irda *); 72 int (*tx_start)(struct sk_buff *, struct net_device *, struct sa1100_irda *);
73 irqreturn_t (*irq)(struct net_device *, struct sa1100_irda *);
73}; 74};
74 75
75static int sa1100_irda_set_speed(struct sa1100_irda *, int); 76static int sa1100_irda_set_speed(struct sa1100_irda *, int);
@@ -197,6 +198,8 @@ static int sa1100_irda_fir_tx_start(struct sk_buff *skb, struct net_device *dev,
197 return NETDEV_TX_OK; 198 return NETDEV_TX_OK;
198} 199}
199 200
201static irqreturn_t sa1100_irda_sir_irq(struct net_device *, struct sa1100_irda *);
202static irqreturn_t sa1100_irda_fir_irq(struct net_device *, struct sa1100_irda *);
200 203
201/* 204/*
202 * Set the IrDA communications speed. 205 * Set the IrDA communications speed.
@@ -236,6 +239,7 @@ static int sa1100_irda_set_speed(struct sa1100_irda *si, int speed)
236 239
237 si->speed = speed; 240 si->speed = speed;
238 si->tx_start = sa1100_irda_sir_tx_start; 241 si->tx_start = sa1100_irda_sir_tx_start;
242 si->irq = sa1100_irda_sir_irq;
239 243
240 local_irq_restore(flags); 244 local_irq_restore(flags);
241 ret = 0; 245 ret = 0;
@@ -252,6 +256,7 @@ static int sa1100_irda_set_speed(struct sa1100_irda *si, int speed)
252 256
253 si->speed = speed; 257 si->speed = speed;
254 si->tx_start = sa1100_irda_fir_tx_start; 258 si->tx_start = sa1100_irda_fir_tx_start;
259 si->irq = sa1100_irda_fir_irq;
255 260
256 if (si->pdata->set_speed) 261 if (si->pdata->set_speed)
257 si->pdata->set_speed(si->dev, speed); 262 si->pdata->set_speed(si->dev, speed);
@@ -304,9 +309,8 @@ sa1100_set_power(struct sa1100_irda *si, unsigned int state)
304/* 309/*
305 * HP-SIR format interrupt service routines. 310 * HP-SIR format interrupt service routines.
306 */ 311 */
307static void sa1100_irda_hpsir_irq(struct net_device *dev) 312static irqreturn_t sa1100_irda_sir_irq(struct net_device *dev, struct sa1100_irda *si)
308{ 313{
309 struct sa1100_irda *si = netdev_priv(dev);
310 int status; 314 int status;
311 315
312 status = Ser2UTSR0; 316 status = Ser2UTSR0;
@@ -395,6 +399,8 @@ static void sa1100_irda_hpsir_irq(struct net_device *dev)
395 netif_wake_queue(dev); 399 netif_wake_queue(dev);
396 } 400 }
397 } 401 }
402
403 return IRQ_HANDLED;
398} 404}
399 405
400static void sa1100_irda_fir_error(struct sa1100_irda *si, struct net_device *dev) 406static void sa1100_irda_fir_error(struct sa1100_irda *si, struct net_device *dev)
@@ -475,10 +481,8 @@ static void sa1100_irda_fir_error(struct sa1100_irda *si, struct net_device *dev
475 * 481 *
476 * No matter what, we disable RX, process, and the restart RX. 482 * No matter what, we disable RX, process, and the restart RX.
477 */ 483 */
478static void sa1100_irda_fir_irq(struct net_device *dev) 484static irqreturn_t sa1100_irda_fir_irq(struct net_device *dev, struct sa1100_irda *si)
479{ 485{
480 struct sa1100_irda *si = netdev_priv(dev);
481
482 /* 486 /*
483 * Stop RX DMA 487 * Stop RX DMA
484 */ 488 */
@@ -520,16 +524,16 @@ static void sa1100_irda_fir_irq(struct net_device *dev)
520 * No matter what happens, we must restart reception. 524 * No matter what happens, we must restart reception.
521 */ 525 */
522 sa1100_irda_rx_dma_start(si); 526 sa1100_irda_rx_dma_start(si);
527
528 return IRQ_HANDLED;
523} 529}
524 530
525static irqreturn_t sa1100_irda_irq(int irq, void *dev_id) 531static irqreturn_t sa1100_irda_irq(int irq, void *dev_id)
526{ 532{
527 struct net_device *dev = dev_id; 533 struct net_device *dev = dev_id;
528 if (IS_FIR(((struct sa1100_irda *)netdev_priv(dev)))) 534 struct sa1100_irda *si = netdev_priv(dev);
529 sa1100_irda_fir_irq(dev); 535
530 else 536 return si->irq(dev, si);
531 sa1100_irda_hpsir_irq(dev);
532 return IRQ_HANDLED;
533} 537}
534 538
535/* 539/*
@@ -728,10 +732,6 @@ static int sa1100_irda_start(struct net_device *dev)
728 732
729 si->speed = 9600; 733 si->speed = 9600;
730 734
731 err = request_irq(dev->irq, sa1100_irda_irq, 0, dev->name, dev);
732 if (err)
733 goto err_irq;
734
735 err = sa1100_request_dma(DMA_Ser2HSSPRd, "IrDA receive", 735 err = sa1100_request_dma(DMA_Ser2HSSPRd, "IrDA receive",
736 NULL, NULL, &si->dma_rx.regs); 736 NULL, NULL, &si->dma_rx.regs);
737 if (err) 737 if (err)
@@ -743,11 +743,6 @@ static int sa1100_irda_start(struct net_device *dev)
743 goto err_tx_dma; 743 goto err_tx_dma;
744 744
745 /* 745 /*
746 * The interrupt must remain disabled for now.
747 */
748 disable_irq(dev->irq);
749
750 /*
751 * Setup the serial port for the specified speed. 746 * Setup the serial port for the specified speed.
752 */ 747 */
753 err = sa1100_irda_startup(si); 748 err = sa1100_irda_startup(si);
@@ -762,15 +757,21 @@ static int sa1100_irda_start(struct net_device *dev)
762 if (!si->irlap) 757 if (!si->irlap)
763 goto err_irlap; 758 goto err_irlap;
764 759
760 err = request_irq(dev->irq, sa1100_irda_irq, 0, dev->name, dev);
761 if (err)
762 goto err_irq;
763
765 /* 764 /*
766 * Now enable the interrupt and start the queue 765 * Now enable the interrupt and start the queue
767 */ 766 */
768 si->open = 1; 767 si->open = 1;
769 sa1100_set_power(si, power_level); /* low power mode */ 768 sa1100_set_power(si, power_level); /* low power mode */
770 enable_irq(dev->irq); 769
771 netif_start_queue(dev); 770 netif_start_queue(dev);
772 return 0; 771 return 0;
773 772
773err_irq:
774 irlap_close(si->irlap);
774err_irlap: 775err_irlap:
775 si->open = 0; 776 si->open = 0;
776 sa1100_irda_shutdown(si); 777 sa1100_irda_shutdown(si);
@@ -779,8 +780,6 @@ err_startup:
779err_tx_dma: 780err_tx_dma:
780 sa1100_free_dma(si->dma_rx.regs); 781 sa1100_free_dma(si->dma_rx.regs);
781err_rx_dma: 782err_rx_dma:
782 free_irq(dev->irq, dev);
783err_irq:
784 return err; 783 return err;
785} 784}
786 785
@@ -789,7 +788,9 @@ static int sa1100_irda_stop(struct net_device *dev)
789 struct sa1100_irda *si = netdev_priv(dev); 788 struct sa1100_irda *si = netdev_priv(dev);
790 struct sk_buff *skb; 789 struct sk_buff *skb;
791 790
792 disable_irq(dev->irq); 791 netif_stop_queue(dev);
792
793 si->open = 0;
793 sa1100_irda_shutdown(si); 794 sa1100_irda_shutdown(si);
794 795
795 /* 796 /*
@@ -818,9 +819,6 @@ static int sa1100_irda_stop(struct net_device *dev)
818 si->irlap = NULL; 819 si->irlap = NULL;
819 } 820 }
820 821
821 netif_stop_queue(dev);
822 si->open = 0;
823
824 /* 822 /*
825 * Free resources 823 * Free resources
826 */ 824 */