aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/irda
diff options
context:
space:
mode:
authorRussell King <rmk+kernel@arm.linux.org.uk>2012-01-08 11:30:44 -0500
committerRussell King <rmk+kernel@arm.linux.org.uk>2012-02-09 10:37:55 -0500
commit0e888ee31566c3f5071474ddd68457a7ad2ae5ac (patch)
tree78e102ec67f0873c6095826796077ced2e7cded3 /drivers/net/irda
parentcbe1d24fb70751ef14801338aa945e807ba63a90 (diff)
NET: sa11x0-ir: factor out speed checks
Whenever we complete a transmit, we always check for a speed change. This check was open coded in several places. Provide a helper function to do this instead. Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
Diffstat (limited to 'drivers/net/irda')
-rw-r--r--drivers/net/irda/sa1100_ir.c25
1 files changed, 13 insertions, 12 deletions
diff --git a/drivers/net/irda/sa1100_ir.c b/drivers/net/irda/sa1100_ir.c
index 32ac4a44ce76..bfae34fa7a9e 100644
--- a/drivers/net/irda/sa1100_ir.c
+++ b/drivers/net/irda/sa1100_ir.c
@@ -70,6 +70,8 @@ struct sa1100_irda {
70 iobuff_t rx_buff; 70 iobuff_t rx_buff;
71}; 71};
72 72
73static int sa1100_irda_set_speed(struct sa1100_irda *, int);
74
73#define IS_FIR(si) ((si)->speed >= 4000000) 75#define IS_FIR(si) ((si)->speed >= 4000000)
74 76
75#define HPSIR_MAX_RXLEN 2047 77#define HPSIR_MAX_RXLEN 2047
@@ -129,6 +131,14 @@ static void sa1100_irda_rx_dma_start(struct sa1100_irda *si)
129 Ser2HSCR0 = si->hscr0 | HSCR0_HSSP | HSCR0_RXE; 131 Ser2HSCR0 = si->hscr0 | HSCR0_HSSP | HSCR0_RXE;
130} 132}
131 133
134static void sa1100_irda_check_speed(struct sa1100_irda *si)
135{
136 if (si->newspeed) {
137 sa1100_irda_set_speed(si, si->newspeed);
138 si->newspeed = 0;
139 }
140}
141
132/* 142/*
133 * Set the IrDA communications speed. 143 * Set the IrDA communications speed.
134 */ 144 */
@@ -318,10 +328,7 @@ static void sa1100_irda_hpsir_irq(struct net_device *dev)
318 Ser2UTSR0 = UTSR0_REB | UTSR0_RBB | UTSR0_RID; 328 Ser2UTSR0 = UTSR0_REB | UTSR0_RBB | UTSR0_RID;
319 Ser2UTCR3 = UTCR3_RIE | UTCR3_RXE | UTCR3_TXE; 329 Ser2UTCR3 = UTCR3_RIE | UTCR3_RXE | UTCR3_TXE;
320 330
321 if (si->newspeed) { 331 sa1100_irda_check_speed(si);
322 sa1100_irda_set_speed(si, si->newspeed);
323 si->newspeed = 0;
324 }
325 332
326 /* I'm hungry! */ 333 /* I'm hungry! */
327 netif_wake_queue(dev); 334 netif_wake_queue(dev);
@@ -492,10 +499,7 @@ static void sa1100_irda_txdma_irq(void *id)
492 * here - we don't free the old dma_rx.skb. We don't need 499 * here - we don't free the old dma_rx.skb. We don't need
493 * to allocate a buffer either. 500 * to allocate a buffer either.
494 */ 501 */
495 if (si->newspeed) { 502 sa1100_irda_check_speed(si);
496 sa1100_irda_set_speed(si, si->newspeed);
497 si->newspeed = 0;
498 }
499 503
500 /* 504 /*
501 * Start reception. This disables the transmitter for 505 * Start reception. This disables the transmitter for
@@ -538,10 +542,7 @@ static int sa1100_irda_hard_xmit(struct sk_buff *skb, struct net_device *dev)
538 * If this is an empty frame, we can bypass a lot. 542 * If this is an empty frame, we can bypass a lot.
539 */ 543 */
540 if (skb->len == 0) { 544 if (skb->len == 0) {
541 if (si->newspeed) { 545 sa1100_irda_check_speed(si);
542 si->newspeed = 0;
543 sa1100_irda_set_speed(si, speed);
544 }
545 dev_kfree_skb(skb); 546 dev_kfree_skb(skb);
546 return NETDEV_TX_OK; 547 return NETDEV_TX_OK;
547 } 548 }