Commit 0e888ee3 authored by Russell King's avatar Russell King

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: default avatarRussell King <rmk+kernel@arm.linux.org.uk>
parent cbe1d24f
...@@ -70,6 +70,8 @@ struct sa1100_irda { ...@@ -70,6 +70,8 @@ struct sa1100_irda {
iobuff_t rx_buff; iobuff_t rx_buff;
}; };
static int sa1100_irda_set_speed(struct sa1100_irda *, int);
#define IS_FIR(si) ((si)->speed >= 4000000) #define IS_FIR(si) ((si)->speed >= 4000000)
#define HPSIR_MAX_RXLEN 2047 #define HPSIR_MAX_RXLEN 2047
...@@ -129,6 +131,14 @@ static void sa1100_irda_rx_dma_start(struct sa1100_irda *si) ...@@ -129,6 +131,14 @@ static void sa1100_irda_rx_dma_start(struct sa1100_irda *si)
Ser2HSCR0 = si->hscr0 | HSCR0_HSSP | HSCR0_RXE; Ser2HSCR0 = si->hscr0 | HSCR0_HSSP | HSCR0_RXE;
} }
static void sa1100_irda_check_speed(struct sa1100_irda *si)
{
if (si->newspeed) {
sa1100_irda_set_speed(si, si->newspeed);
si->newspeed = 0;
}
}
/* /*
* Set the IrDA communications speed. * Set the IrDA communications speed.
*/ */
...@@ -318,10 +328,7 @@ static void sa1100_irda_hpsir_irq(struct net_device *dev) ...@@ -318,10 +328,7 @@ static void sa1100_irda_hpsir_irq(struct net_device *dev)
Ser2UTSR0 = UTSR0_REB | UTSR0_RBB | UTSR0_RID; Ser2UTSR0 = UTSR0_REB | UTSR0_RBB | UTSR0_RID;
Ser2UTCR3 = UTCR3_RIE | UTCR3_RXE | UTCR3_TXE; Ser2UTCR3 = UTCR3_RIE | UTCR3_RXE | UTCR3_TXE;
if (si->newspeed) { sa1100_irda_check_speed(si);
sa1100_irda_set_speed(si, si->newspeed);
si->newspeed = 0;
}
/* I'm hungry! */ /* I'm hungry! */
netif_wake_queue(dev); netif_wake_queue(dev);
...@@ -492,10 +499,7 @@ static void sa1100_irda_txdma_irq(void *id) ...@@ -492,10 +499,7 @@ static void sa1100_irda_txdma_irq(void *id)
* here - we don't free the old dma_rx.skb. We don't need * here - we don't free the old dma_rx.skb. We don't need
* to allocate a buffer either. * to allocate a buffer either.
*/ */
if (si->newspeed) { sa1100_irda_check_speed(si);
sa1100_irda_set_speed(si, si->newspeed);
si->newspeed = 0;
}
/* /*
* Start reception. This disables the transmitter for * 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,10 +542,7 @@ static int sa1100_irda_hard_xmit(struct sk_buff *skb, struct net_device *dev)
* If this is an empty frame, we can bypass a lot. * If this is an empty frame, we can bypass a lot.
*/ */
if (skb->len == 0) { if (skb->len == 0) {
if (si->newspeed) { sa1100_irda_check_speed(si);
si->newspeed = 0;
sa1100_irda_set_speed(si, speed);
}
dev_kfree_skb(skb); dev_kfree_skb(skb);
return NETDEV_TX_OK; return NETDEV_TX_OK;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment