Commit d10d0198 authored by David S. Miller's avatar David S. Miller

Merge branch 'w83977af_ir-neatening'

Joe Perches says:

====================
irda: w83977af_ir: Neatening

Originally on top of Arnd's overly long udelay patches because I
noticed a misindented block.  That's now already fixed along with some
other whitespace problems.  These patches are the remainder style
issues from my original series.

Even though I haven't turned on the netwinder in a box in the
garage in who knows how long, if this device is still used somewhere,
might as well neaten the code too.
====================
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parents c63d352f 99d8d215
...@@ -39,6 +39,8 @@ ...@@ -39,6 +39,8 @@
* *
********************************************************************/ ********************************************************************/
#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
#include <linux/module.h> #include <linux/module.h>
#include <linux/kernel.h> #include <linux/kernel.h>
#include <linux/types.h> #include <linux/types.h>
...@@ -110,7 +112,7 @@ static int __init w83977af_init(void) ...@@ -110,7 +112,7 @@ static int __init w83977af_init(void)
{ {
int i; int i;
for (i=0; i < ARRAY_SIZE(dev_self) && io[i] < 2000; i++) { for (i = 0; i < ARRAY_SIZE(dev_self) && io[i] < 2000; i++) {
if (w83977af_open(i, io[i], irq[i], dma[i]) == 0) if (w83977af_open(i, io[i], irq[i], dma[i]) == 0)
return 0; return 0;
} }
...@@ -127,7 +129,7 @@ static void __exit w83977af_cleanup(void) ...@@ -127,7 +129,7 @@ static void __exit w83977af_cleanup(void)
{ {
int i; int i;
for (i=0; i < ARRAY_SIZE(dev_self); i++) { for (i = 0; i < ARRAY_SIZE(dev_self); i++) {
if (dev_self[i]) if (dev_self[i])
w83977af_close(dev_self[i]); w83977af_close(dev_self[i]);
} }
...@@ -155,8 +157,8 @@ static int w83977af_open(int i, unsigned int iobase, unsigned int irq, ...@@ -155,8 +157,8 @@ static int w83977af_open(int i, unsigned int iobase, unsigned int irq,
/* Lock the port that we need */ /* Lock the port that we need */
if (!request_region(iobase, CHIP_IO_EXTENT, driver_name)) { if (!request_region(iobase, CHIP_IO_EXTENT, driver_name)) {
pr_debug("%s(), can't get iobase of 0x%03x\n", pr_debug("%s: can't get iobase of 0x%03x\n",
__func__ , iobase); __func__, iobase);
return -ENODEV; return -ENODEV;
} }
...@@ -168,9 +170,8 @@ static int w83977af_open(int i, unsigned int iobase, unsigned int irq, ...@@ -168,9 +170,8 @@ static int w83977af_open(int i, unsigned int iobase, unsigned int irq,
* Allocate new instance of the driver * Allocate new instance of the driver
*/ */
dev = alloc_irdadev(sizeof(struct w83977af_ir)); dev = alloc_irdadev(sizeof(struct w83977af_ir));
if (dev == NULL) { if (!dev) {
printk( KERN_ERR "IrDA: Can't allocate memory for " pr_err("IrDA: Can't allocate memory for IrDA control block!\n");
"IrDA control block!\n");
err = -ENOMEM; err = -ENOMEM;
goto err_out; goto err_out;
} }
...@@ -178,7 +179,6 @@ static int w83977af_open(int i, unsigned int iobase, unsigned int irq, ...@@ -178,7 +179,6 @@ static int w83977af_open(int i, unsigned int iobase, unsigned int irq,
self = netdev_priv(dev); self = netdev_priv(dev);
spin_lock_init(&self->lock); spin_lock_init(&self->lock);
/* Initialize IO */ /* Initialize IO */
self->io.fir_base = iobase; self->io.fir_base = iobase;
self->io.irq = irq; self->io.irq = irq;
...@@ -192,8 +192,8 @@ static int w83977af_open(int i, unsigned int iobase, unsigned int irq, ...@@ -192,8 +192,8 @@ static int w83977af_open(int i, unsigned int iobase, unsigned int irq,
/* The only value we must override it the baudrate */ /* The only value we must override it the baudrate */
/* FIXME: The HP HDLS-1100 does not support 1152000! */ /* FIXME: The HP HDLS-1100 does not support 1152000! */
self->qos.baud_rate.bits = IR_9600|IR_19200|IR_38400|IR_57600| self->qos.baud_rate.bits = IR_9600 | IR_19200 | IR_38400 | IR_57600 |
IR_115200|IR_576000|IR_1152000|(IR_4000000 << 8); IR_115200 | IR_576000 | IR_1152000 | (IR_4000000 << 8);
/* The HP HDLS-1100 needs 1 ms according to the specs */ /* The HP HDLS-1100 needs 1 ms according to the specs */
self->qos.min_turn_time.bits = qos_mtt_bits; self->qos.min_turn_time.bits = qos_mtt_bits;
...@@ -207,7 +207,7 @@ static int w83977af_open(int i, unsigned int iobase, unsigned int irq, ...@@ -207,7 +207,7 @@ static int w83977af_open(int i, unsigned int iobase, unsigned int irq,
self->rx_buff.head = self->rx_buff.head =
dma_zalloc_coherent(NULL, self->rx_buff.truesize, dma_zalloc_coherent(NULL, self->rx_buff.truesize,
&self->rx_buff_dma, GFP_KERNEL); &self->rx_buff_dma, GFP_KERNEL);
if (self->rx_buff.head == NULL) { if (!self->rx_buff.head) {
err = -ENOMEM; err = -ENOMEM;
goto err_out1; goto err_out1;
} }
...@@ -215,7 +215,7 @@ static int w83977af_open(int i, unsigned int iobase, unsigned int irq, ...@@ -215,7 +215,7 @@ static int w83977af_open(int i, unsigned int iobase, unsigned int irq,
self->tx_buff.head = self->tx_buff.head =
dma_zalloc_coherent(NULL, self->tx_buff.truesize, dma_zalloc_coherent(NULL, self->tx_buff.truesize,
&self->tx_buff_dma, GFP_KERNEL); &self->tx_buff_dma, GFP_KERNEL);
if (self->tx_buff.head == NULL) { if (!self->tx_buff.head) {
err = -ENOMEM; err = -ENOMEM;
goto err_out2; goto err_out2;
} }
...@@ -230,7 +230,7 @@ static int w83977af_open(int i, unsigned int iobase, unsigned int irq, ...@@ -230,7 +230,7 @@ static int w83977af_open(int i, unsigned int iobase, unsigned int irq,
err = register_netdev(dev); err = register_netdev(dev);
if (err) { if (err) {
net_err_ratelimited("%s(), register_netdevice() failed!\n", net_err_ratelimited("%s:, register_netdevice() failed!\n",
__func__); __func__);
goto err_out3; goto err_out3;
} }
...@@ -281,8 +281,7 @@ static int w83977af_close(struct w83977af_ir *self) ...@@ -281,8 +281,7 @@ static int w83977af_close(struct w83977af_ir *self)
unregister_netdev(self->netdev); unregister_netdev(self->netdev);
/* Release the PORT that this driver is using */ /* Release the PORT that this driver is using */
pr_debug("%s(), Releasing Region %03x\n", pr_debug("%s: Releasing Region %03x\n", __func__, self->io.fir_base);
__func__ , self->io.fir_base);
release_region(self->io.fir_base, self->io.fir_ext); release_region(self->io.fir_base, self->io.fir_ext);
if (self->tx_buff.head) if (self->tx_buff.head)
...@@ -303,7 +302,7 @@ static int w83977af_probe(int iobase, int irq, int dma) ...@@ -303,7 +302,7 @@ static int w83977af_probe(int iobase, int irq, int dma)
int version; int version;
int i; int i;
for (i=0; i < 2; i++) { for (i = 0; i < 2; i++) {
#ifdef CONFIG_USE_W977_PNP #ifdef CONFIG_USE_W977_PNP
/* Enter PnP configuration mode */ /* Enter PnP configuration mode */
w977_efm_enter(efbase[i]); w977_efm_enter(efbase[i]);
...@@ -317,7 +316,7 @@ static int w83977af_probe(int iobase, int irq, int dma) ...@@ -317,7 +316,7 @@ static int w83977af_probe(int iobase, int irq, int dma)
w977_write_reg(0x70, irq, efbase[i]); w977_write_reg(0x70, irq, efbase[i]);
#ifdef CONFIG_ARCH_NETWINDER #ifdef CONFIG_ARCH_NETWINDER
/* Netwinder uses 1 higher than Linux */ /* Netwinder uses 1 higher than Linux */
w977_write_reg(0x74, dma+1, efbase[i]); w977_write_reg(0x74, dma + 1, efbase[i]);
#else #else
w977_write_reg(0x74, dma, efbase[i]); w977_write_reg(0x74, dma, efbase[i]);
#endif /* CONFIG_ARCH_NETWINDER */ #endif /* CONFIG_ARCH_NETWINDER */
...@@ -333,23 +332,23 @@ static int w83977af_probe(int iobase, int irq, int dma) ...@@ -333,23 +332,23 @@ static int w83977af_probe(int iobase, int irq, int dma)
#endif /* CONFIG_USE_W977_PNP */ #endif /* CONFIG_USE_W977_PNP */
/* Disable Advanced mode */ /* Disable Advanced mode */
switch_bank(iobase, SET2); switch_bank(iobase, SET2);
outb(iobase+2, 0x00); outb(iobase + 2, 0x00);
/* Turn on UART (global) interrupts */ /* Turn on UART (global) interrupts */
switch_bank(iobase, SET0); switch_bank(iobase, SET0);
outb(HCR_EN_IRQ, iobase+HCR); outb(HCR_EN_IRQ, iobase + HCR);
/* Switch to advanced mode */ /* Switch to advanced mode */
switch_bank(iobase, SET2); switch_bank(iobase, SET2);
outb(inb(iobase+ADCR1) | ADCR1_ADV_SL, iobase+ADCR1); outb(inb(iobase + ADCR1) | ADCR1_ADV_SL, iobase + ADCR1);
/* Set default IR-mode */ /* Set default IR-mode */
switch_bank(iobase, SET0); switch_bank(iobase, SET0);
outb(HCR_SIR, iobase+HCR); outb(HCR_SIR, iobase + HCR);
/* Read the Advanced IR ID */ /* Read the Advanced IR ID */
switch_bank(iobase, SET3); switch_bank(iobase, SET3);
version = inb(iobase+AUID); version = inb(iobase + AUID);
/* Should be 0x1? */ /* Should be 0x1? */
if (0x10 == (version & 0xf0)) { if (0x10 == (version & 0xf0)) {
...@@ -357,17 +356,17 @@ static int w83977af_probe(int iobase, int irq, int dma) ...@@ -357,17 +356,17 @@ static int w83977af_probe(int iobase, int irq, int dma)
/* Set FIFO size to 32 */ /* Set FIFO size to 32 */
switch_bank(iobase, SET2); switch_bank(iobase, SET2);
outb(ADCR2_RXFS32|ADCR2_TXFS32, iobase+ADCR2); outb(ADCR2_RXFS32 | ADCR2_TXFS32, iobase + ADCR2);
/* Set FIFO threshold to TX17, RX16 */ /* Set FIFO threshold to TX17, RX16 */
switch_bank(iobase, SET0); switch_bank(iobase, SET0);
outb(UFR_RXTL|UFR_TXTL|UFR_TXF_RST|UFR_RXF_RST| outb(UFR_RXTL | UFR_TXTL | UFR_TXF_RST | UFR_RXF_RST |
UFR_EN_FIFO,iobase+UFR); UFR_EN_FIFO, iobase + UFR);
/* Receiver frame length */ /* Receiver frame length */
switch_bank(iobase, SET4); switch_bank(iobase, SET4);
outb(2048 & 0xff, iobase+6); outb(2048 & 0xff, iobase + 6);
outb((2048 >> 8) & 0x1f, iobase+7); outb((2048 >> 8) & 0x1f, iobase + 7);
/* /*
* Init HP HSDL-1100 transceiver. * Init HP HSDL-1100 transceiver.
...@@ -382,7 +381,7 @@ static int w83977af_probe(int iobase, int irq, int dma) ...@@ -382,7 +381,7 @@ static int w83977af_probe(int iobase, int irq, int dma)
* CIRRX pin 40 connected to pin 37 * CIRRX pin 40 connected to pin 37
*/ */
switch_bank(iobase, SET7); switch_bank(iobase, SET7);
outb(0x40, iobase+7); outb(0x40, iobase + 7);
net_info_ratelimited("W83977AF (IR) driver loaded. Version: 0x%02x\n", net_info_ratelimited("W83977AF (IR) driver loaded. Version: 0x%02x\n",
version); version);
...@@ -390,7 +389,7 @@ static int w83977af_probe(int iobase, int irq, int dma) ...@@ -390,7 +389,7 @@ static int w83977af_probe(int iobase, int irq, int dma)
return 0; return 0;
} else { } else {
/* Try next extented function register address */ /* Try next extented function register address */
pr_debug("%s(), Wrong chip version", __func__); pr_debug("%s: Wrong chip version\n", __func__);
} }
} }
return -1; return -1;
...@@ -408,66 +407,67 @@ static void w83977af_change_speed(struct w83977af_ir *self, __u32 speed) ...@@ -408,66 +407,67 @@ static void w83977af_change_speed(struct w83977af_ir *self, __u32 speed)
self->io.speed = speed; self->io.speed = speed;
/* Save current bank */ /* Save current bank */
set = inb(iobase+SSR); set = inb(iobase + SSR);
/* Disable interrupts */ /* Disable interrupts */
switch_bank(iobase, SET0); switch_bank(iobase, SET0);
outb(0, iobase+ICR); outb(0, iobase + ICR);
/* Select Set 2 */ /* Select Set 2 */
switch_bank(iobase, SET2); switch_bank(iobase, SET2);
outb(0x00, iobase+ABHL); outb(0x00, iobase + ABHL);
switch (speed) { switch (speed) {
case 9600: outb(0x0c, iobase+ABLL); break; case 9600: outb(0x0c, iobase + ABLL); break;
case 19200: outb(0x06, iobase+ABLL); break; case 19200: outb(0x06, iobase + ABLL); break;
case 38400: outb(0x03, iobase+ABLL); break; case 38400: outb(0x03, iobase + ABLL); break;
case 57600: outb(0x02, iobase+ABLL); break; case 57600: outb(0x02, iobase + ABLL); break;
case 115200: outb(0x01, iobase+ABLL); break; case 115200: outb(0x01, iobase + ABLL); break;
case 576000: case 576000:
ir_mode = HCR_MIR_576; ir_mode = HCR_MIR_576;
pr_debug("%s(), handling baud of 576000\n", __func__); pr_debug("%s: handling baud of 576000\n", __func__);
break; break;
case 1152000: case 1152000:
ir_mode = HCR_MIR_1152; ir_mode = HCR_MIR_1152;
pr_debug("%s(), handling baud of 1152000\n", __func__); pr_debug("%s: handling baud of 1152000\n", __func__);
break; break;
case 4000000: case 4000000:
ir_mode = HCR_FIR; ir_mode = HCR_FIR;
pr_debug("%s(), handling baud of 4000000\n", __func__); pr_debug("%s: handling baud of 4000000\n", __func__);
break; break;
default: default:
ir_mode = HCR_FIR; ir_mode = HCR_FIR;
pr_debug("%s(), unknown baud rate of %d\n", __func__ , speed); pr_debug("%s: unknown baud rate of %d\n", __func__, speed);
break; break;
} }
/* Set speed mode */ /* Set speed mode */
switch_bank(iobase, SET0); switch_bank(iobase, SET0);
outb(ir_mode, iobase+HCR); outb(ir_mode, iobase + HCR);
/* set FIFO size to 32 */ /* set FIFO size to 32 */
switch_bank(iobase, SET2); switch_bank(iobase, SET2);
outb(ADCR2_RXFS32|ADCR2_TXFS32, iobase+ADCR2); outb(ADCR2_RXFS32 | ADCR2_TXFS32, iobase + ADCR2);
/* set FIFO threshold to TX17, RX16 */ /* set FIFO threshold to TX17, RX16 */
switch_bank(iobase, SET0); switch_bank(iobase, SET0);
outb(0x00, iobase+UFR); /* Reset */ outb(0x00, iobase + UFR); /* Reset */
outb(UFR_EN_FIFO, iobase+UFR); /* First we must enable FIFO */ outb(UFR_EN_FIFO, iobase + UFR); /* First we must enable FIFO */
outb(0xa7, iobase+UFR); outb(0xa7, iobase + UFR);
netif_wake_queue(self->netdev); netif_wake_queue(self->netdev);
/* Enable some interrupts so we can receive frames */ /* Enable some interrupts so we can receive frames */
switch_bank(iobase, SET0); switch_bank(iobase, SET0);
if (speed > PIO_MAX_SPEED) { if (speed > PIO_MAX_SPEED) {
outb(ICR_EFSFI, iobase+ICR); outb(ICR_EFSFI, iobase + ICR);
w83977af_dma_receive(self); w83977af_dma_receive(self);
} else } else {
outb(ICR_ERBRI, iobase+ICR); outb(ICR_ERBRI, iobase + ICR);
}
/* Restore SSR */ /* Restore SSR */
outb(set, iobase+SSR); outb(set, iobase + SSR);
} }
/* /*
...@@ -489,8 +489,7 @@ static netdev_tx_t w83977af_hard_xmit(struct sk_buff *skb, ...@@ -489,8 +489,7 @@ static netdev_tx_t w83977af_hard_xmit(struct sk_buff *skb,
iobase = self->io.fir_base; iobase = self->io.fir_base;
pr_debug("%s(%ld), skb->len=%d\n", __func__ , jiffies, pr_debug("%s: %ld, skb->len=%d\n", __func__, jiffies, (int)skb->len);
(int)skb->len);
/* Lock transmit buffer */ /* Lock transmit buffer */
netif_stop_queue(dev); netif_stop_queue(dev);
...@@ -503,12 +502,12 @@ static netdev_tx_t w83977af_hard_xmit(struct sk_buff *skb, ...@@ -503,12 +502,12 @@ static netdev_tx_t w83977af_hard_xmit(struct sk_buff *skb,
w83977af_change_speed(self, speed); w83977af_change_speed(self, speed);
dev_kfree_skb(skb); dev_kfree_skb(skb);
return NETDEV_TX_OK; return NETDEV_TX_OK;
} else }
self->new_speed = speed; self->new_speed = speed;
} }
/* Save current set */ /* Save current set */
set = inb(iobase+SSR); set = inb(iobase + SSR);
/* Decide if we should use PIO or DMA transfer */ /* Decide if we should use PIO or DMA transfer */
if (self->io.speed > PIO_MAX_SPEED) { if (self->io.speed > PIO_MAX_SPEED) {
...@@ -517,15 +516,15 @@ static netdev_tx_t w83977af_hard_xmit(struct sk_buff *skb, ...@@ -517,15 +516,15 @@ static netdev_tx_t w83977af_hard_xmit(struct sk_buff *skb,
self->tx_buff.len = skb->len; self->tx_buff.len = skb->len;
mtt = irda_get_mtt(skb); mtt = irda_get_mtt(skb);
pr_debug("%s(%ld), mtt=%d\n", __func__ , jiffies, mtt); pr_debug("%s: %ld, mtt=%d\n", __func__, jiffies, mtt);
if (mtt > 1000) if (mtt > 1000)
mdelay(mtt/1000); mdelay(mtt / 1000);
else if (mtt) else if (mtt)
udelay(mtt); udelay(mtt);
/* Enable DMA interrupt */ /* Enable DMA interrupt */
switch_bank(iobase, SET0); switch_bank(iobase, SET0);
outb(ICR_EDMAI, iobase+ICR); outb(ICR_EDMAI, iobase + ICR);
w83977af_dma_write(self, iobase); w83977af_dma_write(self, iobase);
} else { } else {
self->tx_buff.data = self->tx_buff.head; self->tx_buff.data = self->tx_buff.head;
...@@ -534,12 +533,12 @@ static netdev_tx_t w83977af_hard_xmit(struct sk_buff *skb, ...@@ -534,12 +533,12 @@ static netdev_tx_t w83977af_hard_xmit(struct sk_buff *skb,
/* Add interrupt on tx low level (will fire immediately) */ /* Add interrupt on tx low level (will fire immediately) */
switch_bank(iobase, SET0); switch_bank(iobase, SET0);
outb(ICR_ETXTHI, iobase+ICR); outb(ICR_ETXTHI, iobase + ICR);
} }
dev_kfree_skb(skb); dev_kfree_skb(skb);
/* Restore set register */ /* Restore set register */
outb(set, iobase+SSR); outb(set, iobase + SSR);
return NETDEV_TX_OK; return NETDEV_TX_OK;
} }
...@@ -553,28 +552,29 @@ static netdev_tx_t w83977af_hard_xmit(struct sk_buff *skb, ...@@ -553,28 +552,29 @@ static netdev_tx_t w83977af_hard_xmit(struct sk_buff *skb,
static void w83977af_dma_write(struct w83977af_ir *self, int iobase) static void w83977af_dma_write(struct w83977af_ir *self, int iobase)
{ {
__u8 set; __u8 set;
pr_debug("%s(), len=%d\n", __func__ , self->tx_buff.len);
pr_debug("%s: len=%d\n", __func__, self->tx_buff.len);
/* Save current set */ /* Save current set */
set = inb(iobase+SSR); set = inb(iobase + SSR);
/* Disable DMA */ /* Disable DMA */
switch_bank(iobase, SET0); switch_bank(iobase, SET0);
outb(inb(iobase+HCR) & ~HCR_EN_DMA, iobase+HCR); outb(inb(iobase + HCR) & ~HCR_EN_DMA, iobase + HCR);
/* Choose transmit DMA channel */ /* Choose transmit DMA channel */
switch_bank(iobase, SET2); switch_bank(iobase, SET2);
outb(ADCR1_D_CHSW|/*ADCR1_DMA_F|*/ADCR1_ADV_SL, iobase+ADCR1); outb(ADCR1_D_CHSW | /*ADCR1_DMA_F|*/ADCR1_ADV_SL, iobase + ADCR1);
irda_setup_dma(self->io.dma, self->tx_buff_dma, self->tx_buff.len, irda_setup_dma(self->io.dma, self->tx_buff_dma, self->tx_buff.len,
DMA_MODE_WRITE); DMA_MODE_WRITE);
self->io.direction = IO_XMIT; self->io.direction = IO_XMIT;
/* Enable DMA */ /* Enable DMA */
switch_bank(iobase, SET0); switch_bank(iobase, SET0);
outb(inb(iobase+HCR) | HCR_EN_DMA | HCR_TX_WT, iobase+HCR); outb(inb(iobase + HCR) | HCR_EN_DMA | HCR_TX_WT, iobase + HCR);
/* Restore set register */ /* Restore set register */
outb(set, iobase+SSR); outb(set, iobase + SSR);
} }
/* /*
...@@ -589,28 +589,27 @@ static int w83977af_pio_write(int iobase, __u8 *buf, int len, int fifo_size) ...@@ -589,28 +589,27 @@ static int w83977af_pio_write(int iobase, __u8 *buf, int len, int fifo_size)
__u8 set; __u8 set;
/* Save current bank */ /* Save current bank */
set = inb(iobase+SSR); set = inb(iobase + SSR);
switch_bank(iobase, SET0); switch_bank(iobase, SET0);
if (!(inb_p(iobase+USR) & USR_TSRE)) { if (!(inb_p(iobase + USR) & USR_TSRE)) {
pr_debug("%s(), warning, FIFO not empty yet!\n", __func__); pr_debug("%s: warning, FIFO not empty yet!\n", __func__);
fifo_size -= 17; fifo_size -= 17;
pr_debug("%s(), %d bytes left in tx fifo\n", pr_debug("%s: %d bytes left in tx fifo\n", __func__, fifo_size);
__func__ , fifo_size);
} }
/* Fill FIFO with current frame */ /* Fill FIFO with current frame */
while ((fifo_size-- > 0) && (actual < len)) { while ((fifo_size-- > 0) && (actual < len)) {
/* Transmit next byte */ /* Transmit next byte */
outb(buf[actual++], iobase+TBR); outb(buf[actual++], iobase + TBR);
} }
pr_debug("%s(), fifo_size %d ; %d sent of %d\n", pr_debug("%s: fifo_size %d ; %d sent of %d\n",
__func__ , fifo_size, actual, len); __func__, fifo_size, actual, len);
/* Restore bank */ /* Restore bank */
outb(set, iobase+SSR); outb(set, iobase + SSR);
return actual; return actual;
} }
...@@ -627,31 +626,31 @@ static void w83977af_dma_xmit_complete(struct w83977af_ir *self) ...@@ -627,31 +626,31 @@ static void w83977af_dma_xmit_complete(struct w83977af_ir *self)
int iobase; int iobase;
__u8 set; __u8 set;
pr_debug("%s(%ld)\n", __func__ , jiffies); pr_debug("%s: %ld\n", __func__, jiffies);
IRDA_ASSERT(self != NULL, return;); IRDA_ASSERT(self, return;);
iobase = self->io.fir_base; iobase = self->io.fir_base;
/* Save current set */ /* Save current set */
set = inb(iobase+SSR); set = inb(iobase + SSR);
/* Disable DMA */ /* Disable DMA */
switch_bank(iobase, SET0); switch_bank(iobase, SET0);
outb(inb(iobase+HCR) & ~HCR_EN_DMA, iobase+HCR); outb(inb(iobase + HCR) & ~HCR_EN_DMA, iobase + HCR);
/* Check for underrun! */ /* Check for underrun! */
if (inb(iobase+AUDR) & AUDR_UNDR) { if (inb(iobase + AUDR) & AUDR_UNDR) {
pr_debug("%s(), Transmit underrun!\n", __func__); pr_debug("%s: Transmit underrun!\n", __func__);
self->netdev->stats.tx_errors++; self->netdev->stats.tx_errors++;
self->netdev->stats.tx_fifo_errors++; self->netdev->stats.tx_fifo_errors++;
/* Clear bit, by writing 1 to it */ /* Clear bit, by writing 1 to it */
outb(AUDR_UNDR, iobase+AUDR); outb(AUDR_UNDR, iobase + AUDR);
} else } else {
self->netdev->stats.tx_packets++; self->netdev->stats.tx_packets++;
}
if (self->new_speed) { if (self->new_speed) {
w83977af_change_speed(self, self->new_speed); w83977af_change_speed(self, self->new_speed);
...@@ -663,7 +662,7 @@ static void w83977af_dma_xmit_complete(struct w83977af_ir *self) ...@@ -663,7 +662,7 @@ static void w83977af_dma_xmit_complete(struct w83977af_ir *self)
netif_wake_queue(self->netdev); netif_wake_queue(self->netdev);
/* Restore set */ /* Restore set */
outb(set, iobase+SSR); outb(set, iobase + SSR);
} }
/* /*
...@@ -681,23 +680,23 @@ static int w83977af_dma_receive(struct w83977af_ir *self) ...@@ -681,23 +680,23 @@ static int w83977af_dma_receive(struct w83977af_ir *self)
unsigned long flags; unsigned long flags;
__u8 hcr; __u8 hcr;
#endif #endif
IRDA_ASSERT(self != NULL, return -1;); IRDA_ASSERT(self, return -1;);
pr_debug("%s\n", __func__); pr_debug("%s\n", __func__);
iobase= self->io.fir_base; iobase = self->io.fir_base;
/* Save current set */ /* Save current set */
set = inb(iobase+SSR); set = inb(iobase + SSR);
/* Disable DMA */ /* Disable DMA */
switch_bank(iobase, SET0); switch_bank(iobase, SET0);
outb(inb(iobase+HCR) & ~HCR_EN_DMA, iobase+HCR); outb(inb(iobase + HCR) & ~HCR_EN_DMA, iobase + HCR);
/* Choose DMA Rx, DMA Fairness, and Advanced mode */ /* Choose DMA Rx, DMA Fairness, and Advanced mode */
switch_bank(iobase, SET2); switch_bank(iobase, SET2);
outb((inb(iobase+ADCR1) & ~ADCR1_D_CHSW)/*|ADCR1_DMA_F*/|ADCR1_ADV_SL, outb((inb(iobase + ADCR1) & ~ADCR1_D_CHSW)/*|ADCR1_DMA_F*/ | ADCR1_ADV_SL,
iobase+ADCR1); iobase + ADCR1);
self->io.direction = IO_RECV; self->io.direction = IO_RECV;
self->rx_buff.data = self->rx_buff.head; self->rx_buff.data = self->rx_buff.head;
...@@ -720,21 +719,21 @@ static int w83977af_dma_receive(struct w83977af_ir *self) ...@@ -720,21 +719,21 @@ static int w83977af_dma_receive(struct w83977af_ir *self)
* be finished transmitting yet * be finished transmitting yet
*/ */
switch_bank(iobase, SET0); switch_bank(iobase, SET0);
outb(UFR_RXTL|UFR_TXTL|UFR_RXF_RST|UFR_EN_FIFO, iobase+UFR); outb(UFR_RXTL | UFR_TXTL | UFR_RXF_RST | UFR_EN_FIFO, iobase + UFR);
self->st_fifo.len = self->st_fifo.tail = self->st_fifo.head = 0; self->st_fifo.len = self->st_fifo.tail = self->st_fifo.head = 0;
/* Enable DMA */ /* Enable DMA */
switch_bank(iobase, SET0); switch_bank(iobase, SET0);
#ifdef CONFIG_ARCH_NETWINDER #ifdef CONFIG_ARCH_NETWINDER
hcr = inb(iobase+HCR); hcr = inb(iobase + HCR);
outb(hcr | HCR_EN_DMA, iobase+HCR); outb(hcr | HCR_EN_DMA, iobase + HCR);
enable_dma(self->io.dma); enable_dma(self->io.dma);
spin_unlock_irqrestore(&self->lock, flags); spin_unlock_irqrestore(&self->lock, flags);
#else #else
outb(inb(iobase+HCR) | HCR_EN_DMA, iobase+HCR); outb(inb(iobase + HCR) | HCR_EN_DMA, iobase + HCR);
#endif #endif
/* Restore set */ /* Restore set */
outb(set, iobase+SSR); outb(set, iobase + SSR);
return 0; return 0;
} }
...@@ -761,17 +760,17 @@ static int w83977af_dma_receive_complete(struct w83977af_ir *self) ...@@ -761,17 +760,17 @@ static int w83977af_dma_receive_complete(struct w83977af_ir *self)
iobase = self->io.fir_base; iobase = self->io.fir_base;
/* Save current set */ /* Save current set */
set = inb(iobase+SSR); set = inb(iobase + SSR);
iobase = self->io.fir_base; iobase = self->io.fir_base;
/* Read status FIFO */ /* Read status FIFO */
switch_bank(iobase, SET5); switch_bank(iobase, SET5);
while ((status = inb(iobase+FS_FO)) & FS_FO_FSFDR) { while ((status = inb(iobase + FS_FO)) & FS_FO_FSFDR) {
st_fifo->entries[st_fifo->tail].status = status; st_fifo->entries[st_fifo->tail].status = status;
st_fifo->entries[st_fifo->tail].len = inb(iobase+RFLFL); st_fifo->entries[st_fifo->tail].len = inb(iobase + RFLFL);
st_fifo->entries[st_fifo->tail].len |= inb(iobase+RFLFH) << 8; st_fifo->entries[st_fifo->tail].len |= inb(iobase + RFLFH) << 8;
st_fifo->tail++; st_fifo->tail++;
st_fifo->len++; st_fifo->len++;
...@@ -814,16 +813,15 @@ static int w83977af_dma_receive_complete(struct w83977af_ir *self) ...@@ -814,16 +813,15 @@ static int w83977af_dma_receive_complete(struct w83977af_ir *self)
} else { } else {
/* Check if we have transferred all data to memory */ /* Check if we have transferred all data to memory */
switch_bank(iobase, SET0); switch_bank(iobase, SET0);
if (inb(iobase+USR) & USR_RDR) { if (inb(iobase + USR) & USR_RDR)
udelay(80); /* Should be enough!? */ udelay(80); /* Should be enough!? */
}
skb = dev_alloc_skb(len+1); skb = dev_alloc_skb(len + 1);
if (skb == NULL) { if (!skb) {
printk(KERN_INFO pr_info("%s: memory squeeze, dropping frame\n",
"%s(), memory squeeze, dropping frame.\n", __func__); __func__);
/* Restore set register */ /* Restore set register */
outb(set, iobase+SSR); outb(set, iobase + SSR);
return FALSE; return FALSE;
} }
...@@ -833,12 +831,12 @@ static int w83977af_dma_receive_complete(struct w83977af_ir *self) ...@@ -833,12 +831,12 @@ static int w83977af_dma_receive_complete(struct w83977af_ir *self)
/* Copy frame without CRC */ /* Copy frame without CRC */
if (self->io.speed < 4000000) { if (self->io.speed < 4000000) {
skb_put(skb, len-2); skb_put(skb, len - 2);
skb_copy_to_linear_data(skb, skb_copy_to_linear_data(skb,
self->rx_buff.data, self->rx_buff.data,
len - 2); len - 2);
} else { } else {
skb_put(skb, len-4); skb_put(skb, len - 4);
skb_copy_to_linear_data(skb, skb_copy_to_linear_data(skb,
self->rx_buff.data, self->rx_buff.data,
len - 4); len - 4);
...@@ -855,7 +853,7 @@ static int w83977af_dma_receive_complete(struct w83977af_ir *self) ...@@ -855,7 +853,7 @@ static int w83977af_dma_receive_complete(struct w83977af_ir *self)
} }
} }
/* Restore set register */ /* Restore set register */
outb(set, iobase+SSR); outb(set, iobase + SSR);
return TRUE; return TRUE;
} }
...@@ -871,16 +869,16 @@ static void w83977af_pio_receive(struct w83977af_ir *self) ...@@ -871,16 +869,16 @@ static void w83977af_pio_receive(struct w83977af_ir *self)
__u8 byte = 0x00; __u8 byte = 0x00;
int iobase; int iobase;
IRDA_ASSERT(self != NULL, return;); IRDA_ASSERT(self, return;);
iobase = self->io.fir_base; iobase = self->io.fir_base;
/* Receive all characters in Rx FIFO */ /* Receive all characters in Rx FIFO */
do { do {
byte = inb(iobase+RBR); byte = inb(iobase + RBR);
async_unwrap_char(self->netdev, &self->netdev->stats, &self->rx_buff, async_unwrap_char(self->netdev, &self->netdev->stats, &self->rx_buff,
byte); byte);
} while (inb(iobase+USR) & USR_RDR); /* Data available */ } while (inb(iobase + USR) & USR_RDR); /* Data available */
} }
/* /*
...@@ -896,7 +894,7 @@ static __u8 w83977af_sir_interrupt(struct w83977af_ir *self, int isr) ...@@ -896,7 +894,7 @@ static __u8 w83977af_sir_interrupt(struct w83977af_ir *self, int isr)
__u8 set; __u8 set;
int iobase; int iobase;
pr_debug("%s(), isr=%#x\n", __func__ , isr); pr_debug("%s: isr=%#x\n", __func__, isr);
iobase = self->io.fir_base; iobase = self->io.fir_base;
/* Transmit FIFO low on data */ /* Transmit FIFO low on data */
...@@ -916,10 +914,10 @@ static __u8 w83977af_sir_interrupt(struct w83977af_ir *self, int isr) ...@@ -916,10 +914,10 @@ static __u8 w83977af_sir_interrupt(struct w83977af_ir *self, int isr)
if (self->tx_buff.len > 0) { if (self->tx_buff.len > 0) {
new_icr |= ICR_ETXTHI; new_icr |= ICR_ETXTHI;
} else { } else {
set = inb(iobase+SSR); set = inb(iobase + SSR);
switch_bank(iobase, SET0); switch_bank(iobase, SET0);
outb(AUDR_SFEND, iobase+AUDR); outb(AUDR_SFEND, iobase + AUDR);
outb(set, iobase+SSR); outb(set, iobase + SSR);
self->netdev->stats.tx_packets++; self->netdev->stats.tx_packets++;
...@@ -932,7 +930,7 @@ static __u8 w83977af_sir_interrupt(struct w83977af_ir *self, int isr) ...@@ -932,7 +930,7 @@ static __u8 w83977af_sir_interrupt(struct w83977af_ir *self, int isr)
if (isr & ISR_TXEMP_I) { if (isr & ISR_TXEMP_I) {
/* Check if we need to change the speed? */ /* Check if we need to change the speed? */
if (self->new_speed) { if (self->new_speed) {
pr_debug("%s(), Changing speed!\n", __func__); pr_debug("%s: Changing speed!\n", __func__);
w83977af_change_speed(self, self->new_speed); w83977af_change_speed(self, self->new_speed);
self->new_speed = 0; self->new_speed = 0;
} }
...@@ -965,12 +963,11 @@ static __u8 w83977af_fir_interrupt(struct w83977af_ir *self, int isr) ...@@ -965,12 +963,11 @@ static __u8 w83977af_fir_interrupt(struct w83977af_ir *self, int isr)
int iobase; int iobase;
iobase = self->io.fir_base; iobase = self->io.fir_base;
set = inb(iobase+SSR); set = inb(iobase + SSR);
/* End of frame detected in FIFO */ /* End of frame detected in FIFO */
if (isr & (ISR_FEND_I|ISR_FSF_I)) { if (isr & (ISR_FEND_I | ISR_FSF_I)) {
if (w83977af_dma_receive_complete(self)) { if (w83977af_dma_receive_complete(self)) {
/* Wait for next status FIFO interrupt */ /* Wait for next status FIFO interrupt */
new_icr |= ICR_EFSFI; new_icr |= ICR_EFSFI;
} else { } else {
...@@ -978,11 +975,11 @@ static __u8 w83977af_fir_interrupt(struct w83977af_ir *self, int isr) ...@@ -978,11 +975,11 @@ static __u8 w83977af_fir_interrupt(struct w83977af_ir *self, int isr)
/* Set timer value, resolution 1 ms */ /* Set timer value, resolution 1 ms */
switch_bank(iobase, SET4); switch_bank(iobase, SET4);
outb(0x01, iobase+TMRL); /* 1 ms */ outb(0x01, iobase + TMRL); /* 1 ms */
outb(0x00, iobase+TMRH); outb(0x00, iobase + TMRH);
/* Start timer */ /* Start timer */
outb(IR_MSL_EN_TMR, iobase+IR_MSL); outb(IR_MSL_EN_TMR, iobase + IR_MSL);
new_icr |= ICR_ETMRI; new_icr |= ICR_ETMRI;
} }
...@@ -991,7 +988,7 @@ static __u8 w83977af_fir_interrupt(struct w83977af_ir *self, int isr) ...@@ -991,7 +988,7 @@ static __u8 w83977af_fir_interrupt(struct w83977af_ir *self, int isr)
if (isr & ISR_TMR_I) { if (isr & ISR_TMR_I) {
/* Disable timer */ /* Disable timer */
switch_bank(iobase, SET4); switch_bank(iobase, SET4);
outb(0, iobase+IR_MSL); outb(0, iobase + IR_MSL);
/* Clear timer event */ /* Clear timer event */
/* switch_bank(iobase, SET0); */ /* switch_bank(iobase, SET0); */
...@@ -1026,7 +1023,7 @@ static __u8 w83977af_fir_interrupt(struct w83977af_ir *self, int isr) ...@@ -1026,7 +1023,7 @@ static __u8 w83977af_fir_interrupt(struct w83977af_ir *self, int isr)
} }
/* Restore set */ /* Restore set */
outb(set, iobase+SSR); outb(set, iobase + SSR);
return new_icr; return new_icr;
} }
...@@ -1049,24 +1046,24 @@ static irqreturn_t w83977af_interrupt(int irq, void *dev_id) ...@@ -1049,24 +1046,24 @@ static irqreturn_t w83977af_interrupt(int irq, void *dev_id)
iobase = self->io.fir_base; iobase = self->io.fir_base;
/* Save current bank */ /* Save current bank */
set = inb(iobase+SSR); set = inb(iobase + SSR);
switch_bank(iobase, SET0); switch_bank(iobase, SET0);
icr = inb(iobase+ICR); icr = inb(iobase + ICR);
isr = inb(iobase+ISR) & icr; /* Mask out the interesting ones */ isr = inb(iobase + ISR) & icr; /* Mask out the interesting ones */
outb(0, iobase+ICR); /* Disable interrupts */ outb(0, iobase + ICR); /* Disable interrupts */
if (isr) { if (isr) {
/* Dispatch interrupt handler for the current speed */ /* Dispatch interrupt handler for the current speed */
if (self->io.speed > PIO_MAX_SPEED ) if (self->io.speed > PIO_MAX_SPEED)
icr = w83977af_fir_interrupt(self, isr); icr = w83977af_fir_interrupt(self, isr);
else else
icr = w83977af_sir_interrupt(self, isr); icr = w83977af_sir_interrupt(self, isr);
} }
outb(icr, iobase+ICR); /* Restore (new) interrupts */ outb(icr, iobase + ICR); /* Restore (new) interrupts */
outb(set, iobase+SSR); /* Restore bank register */ outb(set, iobase + SSR); /* Restore bank register */
return IRQ_RETVAL(isr); return IRQ_RETVAL(isr);
} }
...@@ -1082,21 +1079,22 @@ static int w83977af_is_receiving(struct w83977af_ir *self) ...@@ -1082,21 +1079,22 @@ static int w83977af_is_receiving(struct w83977af_ir *self)
int iobase; int iobase;
__u8 set; __u8 set;
IRDA_ASSERT(self != NULL, return FALSE;); IRDA_ASSERT(self, return FALSE;);
if (self->io.speed > 115200) { if (self->io.speed > 115200) {
iobase = self->io.fir_base; iobase = self->io.fir_base;
/* Check if rx FIFO is not empty */ /* Check if rx FIFO is not empty */
set = inb(iobase+SSR); set = inb(iobase + SSR);
switch_bank(iobase, SET2); switch_bank(iobase, SET2);
if ((inb(iobase+RXFDTH) & 0x3f) != 0) { if ((inb(iobase + RXFDTH) & 0x3f) != 0) {
/* We are receiving something */ /* We are receiving something */
status = TRUE; status = TRUE;
} }
outb(set, iobase+SSR); outb(set, iobase + SSR);
} else } else {
status = (self->rx_buff.state != OUTSIDE_FRAME); status = (self->rx_buff.state != OUTSIDE_FRAME);
}
return status; return status;
} }
...@@ -1114,16 +1112,15 @@ static int w83977af_net_open(struct net_device *dev) ...@@ -1114,16 +1112,15 @@ static int w83977af_net_open(struct net_device *dev)
char hwname[32]; char hwname[32];
__u8 set; __u8 set;
IRDA_ASSERT(dev, return -1;);
IRDA_ASSERT(dev != NULL, return -1;);
self = netdev_priv(dev); self = netdev_priv(dev);
IRDA_ASSERT(self != NULL, return 0;); IRDA_ASSERT(self, return 0;);
iobase = self->io.fir_base; iobase = self->io.fir_base;
if (request_irq(self->io.irq, w83977af_interrupt, 0, dev->name, if (request_irq(self->io.irq, w83977af_interrupt, 0, dev->name,
(void *) dev)) { (void *)dev)) {
return -EAGAIN; return -EAGAIN;
} }
/* /*
...@@ -1136,18 +1133,19 @@ static int w83977af_net_open(struct net_device *dev) ...@@ -1136,18 +1133,19 @@ static int w83977af_net_open(struct net_device *dev)
} }
/* Save current set */ /* Save current set */
set = inb(iobase+SSR); set = inb(iobase + SSR);
/* Enable some interrupts so we can receive frames again */ /* Enable some interrupts so we can receive frames again */
switch_bank(iobase, SET0); switch_bank(iobase, SET0);
if (self->io.speed > 115200) { if (self->io.speed > 115200) {
outb(ICR_EFSFI, iobase+ICR); outb(ICR_EFSFI, iobase + ICR);
w83977af_dma_receive(self); w83977af_dma_receive(self);
} else } else {
outb(ICR_ERBRI, iobase+ICR); outb(ICR_ERBRI, iobase + ICR);
}
/* Restore bank register */ /* Restore bank register */
outb(set, iobase+SSR); outb(set, iobase + SSR);
/* Ready to play! */ /* Ready to play! */
netif_start_queue(dev); netif_start_queue(dev);
...@@ -1176,11 +1174,11 @@ static int w83977af_net_close(struct net_device *dev) ...@@ -1176,11 +1174,11 @@ static int w83977af_net_close(struct net_device *dev)
int iobase; int iobase;
__u8 set; __u8 set;
IRDA_ASSERT(dev != NULL, return -1;); IRDA_ASSERT(dev, return -1;);
self = netdev_priv(dev); self = netdev_priv(dev);
IRDA_ASSERT(self != NULL, return 0;); IRDA_ASSERT(self, return 0;);
iobase = self->io.fir_base; iobase = self->io.fir_base;
...@@ -1195,17 +1193,17 @@ static int w83977af_net_close(struct net_device *dev) ...@@ -1195,17 +1193,17 @@ static int w83977af_net_close(struct net_device *dev)
disable_dma(self->io.dma); disable_dma(self->io.dma);
/* Save current set */ /* Save current set */
set = inb(iobase+SSR); set = inb(iobase + SSR);
/* Disable interrupts */ /* Disable interrupts */
switch_bank(iobase, SET0); switch_bank(iobase, SET0);
outb(0, iobase+ICR); outb(0, iobase + ICR);
free_irq(self->io.irq, dev); free_irq(self->io.irq, dev);
free_dma(self->io.dma); free_dma(self->io.dma);
/* Restore bank register */ /* Restore bank register */
outb(set, iobase+SSR); outb(set, iobase + SSR);
return 0; return 0;
} }
...@@ -1218,18 +1216,18 @@ static int w83977af_net_close(struct net_device *dev) ...@@ -1218,18 +1216,18 @@ static int w83977af_net_close(struct net_device *dev)
*/ */
static int w83977af_net_ioctl(struct net_device *dev, struct ifreq *rq, int cmd) static int w83977af_net_ioctl(struct net_device *dev, struct ifreq *rq, int cmd)
{ {
struct if_irda_req *irq = (struct if_irda_req *) rq; struct if_irda_req *irq = (struct if_irda_req *)rq;
struct w83977af_ir *self; struct w83977af_ir *self;
unsigned long flags; unsigned long flags;
int ret = 0; int ret = 0;
IRDA_ASSERT(dev != NULL, return -1;); IRDA_ASSERT(dev, return -1;);
self = netdev_priv(dev); self = netdev_priv(dev);
IRDA_ASSERT(self != NULL, return -1;); IRDA_ASSERT(self, return -1;);
pr_debug("%s(), %s, (cmd=0x%X)\n", __func__ , dev->name, cmd); pr_debug("%s: %s, (cmd=0x%X)\n", __func__, dev->name, cmd);
spin_lock_irqsave(&self->lock, flags); spin_lock_irqsave(&self->lock, flags);
...@@ -1263,7 +1261,6 @@ MODULE_AUTHOR("Dag Brattli <dagb@cs.uit.no>"); ...@@ -1263,7 +1261,6 @@ MODULE_AUTHOR("Dag Brattli <dagb@cs.uit.no>");
MODULE_DESCRIPTION("Winbond W83977AF IrDA Device Driver"); MODULE_DESCRIPTION("Winbond W83977AF IrDA Device Driver");
MODULE_LICENSE("GPL"); MODULE_LICENSE("GPL");
module_param(qos_mtt_bits, int, 0); module_param(qos_mtt_bits, int, 0);
MODULE_PARM_DESC(qos_mtt_bits, "Mimimum Turn Time"); MODULE_PARM_DESC(qos_mtt_bits, "Mimimum Turn Time");
module_param_array(io, int, NULL, 0); module_param_array(io, int, NULL, 0);
......
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