Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

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

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
Loading
Loading
Loading
Loading
+160 −163
Original line number Diff line number Diff line
@@ -39,6 +39,8 @@
 *
 ********************************************************************/

#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt

#include <linux/module.h>
#include <linux/kernel.h>
#include <linux/types.h>
@@ -155,7 +157,7 @@ static int w83977af_open(int i, unsigned int iobase, unsigned int irq,

	/* Lock the port that we need */
	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);
		return -ENODEV;
	}
@@ -168,9 +170,8 @@ static int w83977af_open(int i, unsigned int iobase, unsigned int irq,
	 *  Allocate new instance of the driver
	 */
	dev = alloc_irdadev(sizeof(struct w83977af_ir));
	if (dev == NULL) {
		printk( KERN_ERR "IrDA: Can't allocate memory for "
			"IrDA control block!\n");
	if (!dev) {
		pr_err("IrDA: Can't allocate memory for IrDA control block!\n");
		err = -ENOMEM;
		goto err_out;
	}
@@ -178,7 +179,6 @@ static int w83977af_open(int i, unsigned int iobase, unsigned int irq,
	self = netdev_priv(dev);
	spin_lock_init(&self->lock);


	/* Initialize IO */
	self->io.fir_base = iobase;
	self->io.irq = irq;
@@ -207,7 +207,7 @@ static int w83977af_open(int i, unsigned int iobase, unsigned int irq,
	self->rx_buff.head =
		dma_zalloc_coherent(NULL, self->rx_buff.truesize,
				    &self->rx_buff_dma, GFP_KERNEL);
	if (self->rx_buff.head == NULL) {
	if (!self->rx_buff.head) {
		err = -ENOMEM;
		goto err_out1;
	}
@@ -215,7 +215,7 @@ static int w83977af_open(int i, unsigned int iobase, unsigned int irq,
	self->tx_buff.head =
		dma_zalloc_coherent(NULL, self->tx_buff.truesize,
				    &self->tx_buff_dma, GFP_KERNEL);
	if (self->tx_buff.head == NULL) {
	if (!self->tx_buff.head) {
		err = -ENOMEM;
		goto err_out2;
	}
@@ -230,7 +230,7 @@ static int w83977af_open(int i, unsigned int iobase, unsigned int irq,

	err = register_netdev(dev);
	if (err) {
		net_err_ratelimited("%s(), register_netdevice() failed!\n",
		net_err_ratelimited("%s:, register_netdevice() failed!\n",
				    __func__);
		goto err_out3;
	}
@@ -281,8 +281,7 @@ static int w83977af_close(struct w83977af_ir *self)
	unregister_netdev(self->netdev);

	/* Release the PORT that this driver is using */
	pr_debug("%s(), Releasing Region %03x\n",
		 __func__ , self->io.fir_base);
	pr_debug("%s: Releasing Region %03x\n", __func__, self->io.fir_base);
	release_region(self->io.fir_base, self->io.fir_ext);

	if (self->tx_buff.head)
@@ -390,7 +389,7 @@ static int w83977af_probe(int iobase, int irq, int dma)
			return 0;
		} else {
			/* Try next extented function register address */
			pr_debug("%s(), Wrong chip version", __func__);
			pr_debug("%s: Wrong chip version\n", __func__);
		}
	}
	return -1;
@@ -426,19 +425,19 @@ static void w83977af_change_speed(struct w83977af_ir *self, __u32 speed)
	case 115200: outb(0x01, iobase + ABLL); break;
	case 576000:
		ir_mode = HCR_MIR_576;
		pr_debug("%s(), handling baud of 576000\n", __func__);
		pr_debug("%s: handling baud of 576000\n", __func__);
		break;
	case 1152000:
		ir_mode = HCR_MIR_1152;
		pr_debug("%s(), handling baud of 1152000\n", __func__);
		pr_debug("%s: handling baud of 1152000\n", __func__);
		break;
	case 4000000:
		ir_mode = HCR_FIR;
		pr_debug("%s(), handling baud of 4000000\n", __func__);
		pr_debug("%s: handling baud of 4000000\n", __func__);
		break;
	default:
		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;
	}

@@ -463,8 +462,9 @@ static void w83977af_change_speed(struct w83977af_ir *self, __u32 speed)
	if (speed > PIO_MAX_SPEED) {
		outb(ICR_EFSFI, iobase + ICR);
		w83977af_dma_receive(self);
	} else
	} else {
		outb(ICR_ERBRI, iobase + ICR);
	}

	/* Restore SSR */
	outb(set, iobase + SSR);
@@ -489,8 +489,7 @@ static netdev_tx_t w83977af_hard_xmit(struct sk_buff *skb,

	iobase = self->io.fir_base;

	pr_debug("%s(%ld), skb->len=%d\n", __func__ , jiffies,
		 (int)skb->len);
	pr_debug("%s: %ld, skb->len=%d\n", __func__, jiffies, (int)skb->len);

	/* Lock transmit buffer */
	netif_stop_queue(dev);
@@ -503,7 +502,7 @@ static netdev_tx_t w83977af_hard_xmit(struct sk_buff *skb,
			w83977af_change_speed(self, speed);
			dev_kfree_skb(skb);
			return NETDEV_TX_OK;
		} else
		}
		self->new_speed = speed;
	}

@@ -517,7 +516,7 @@ static netdev_tx_t w83977af_hard_xmit(struct sk_buff *skb,
		self->tx_buff.len = skb->len;

		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)
				mdelay(mtt / 1000);
			else if (mtt)
@@ -553,7 +552,8 @@ static netdev_tx_t w83977af_hard_xmit(struct sk_buff *skb,
static void w83977af_dma_write(struct w83977af_ir *self, int iobase)
{
	__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 */
	set = inb(iobase + SSR);
@@ -593,11 +593,10 @@ static int w83977af_pio_write(int iobase, __u8 *buf, int len, int fifo_size)

	switch_bank(iobase, SET0);
	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;
		pr_debug("%s(), %d bytes left in tx fifo\n",
			 __func__ , fifo_size);
		pr_debug("%s: %d bytes left in tx fifo\n", __func__, fifo_size);
	}

	/* Fill FIFO with current frame */
@@ -606,7 +605,7 @@ static int w83977af_pio_write(int iobase, __u8 *buf, int len, int fifo_size)
		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);

	/* Restore bank */
@@ -627,9 +626,9 @@ static void w83977af_dma_xmit_complete(struct w83977af_ir *self)
	int iobase;
	__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;

@@ -642,16 +641,16 @@ static void w83977af_dma_xmit_complete(struct w83977af_ir *self)

	/* Check for underrun! */
	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_fifo_errors++;

		/* Clear bit, by writing 1 to it */
		outb(AUDR_UNDR, iobase + AUDR);
	} else
	} else {
		self->netdev->stats.tx_packets++;

	}

	if (self->new_speed) {
		w83977af_change_speed(self, self->new_speed);
@@ -681,7 +680,7 @@ static int w83977af_dma_receive(struct w83977af_ir *self)
	unsigned long flags;
	__u8 hcr;
#endif
	IRDA_ASSERT(self != NULL, return -1;);
	IRDA_ASSERT(self, return -1;);

	pr_debug("%s\n", __func__);

@@ -814,14 +813,13 @@ static int w83977af_dma_receive_complete(struct w83977af_ir *self)
		} else {
			/* Check if we have transferred all data to memory */
			switch_bank(iobase, SET0);
			if (inb(iobase+USR) & USR_RDR) {
			if (inb(iobase + USR) & USR_RDR)
				udelay(80); /* Should be enough!? */
			}

			skb = dev_alloc_skb(len + 1);
			if (skb == NULL)  {
				printk(KERN_INFO
				       "%s(), memory squeeze, dropping frame.\n", __func__);
			if (!skb)  {
				pr_info("%s: memory squeeze, dropping frame\n",
					__func__);
				/* Restore set register */
				outb(set, iobase + SSR);

@@ -871,7 +869,7 @@ static void w83977af_pio_receive(struct w83977af_ir *self)
	__u8 byte = 0x00;
	int iobase;

	IRDA_ASSERT(self != NULL, return;);
	IRDA_ASSERT(self, return;);

	iobase = self->io.fir_base;

@@ -896,7 +894,7 @@ static __u8 w83977af_sir_interrupt(struct w83977af_ir *self, int isr)
	__u8 set;
	int iobase;

	pr_debug("%s(), isr=%#x\n", __func__ , isr);
	pr_debug("%s: isr=%#x\n", __func__, isr);

	iobase = self->io.fir_base;
	/* Transmit FIFO low on data */
@@ -932,7 +930,7 @@ static __u8 w83977af_sir_interrupt(struct w83977af_ir *self, int isr)
	if (isr & ISR_TXEMP_I) {
		/* Check if we need to change the 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);
			self->new_speed = 0;
		}
@@ -970,7 +968,6 @@ static __u8 w83977af_fir_interrupt(struct w83977af_ir *self, int isr)
	/* End of frame detected in FIFO */
	if (isr & (ISR_FEND_I | ISR_FSF_I)) {
		if (w83977af_dma_receive_complete(self)) {

			/* Wait for next status FIFO interrupt */
			new_icr |= ICR_EFSFI;
		} else {
@@ -1082,7 +1079,7 @@ static int w83977af_is_receiving(struct w83977af_ir *self)
	int iobase;
	__u8 set;

	IRDA_ASSERT(self != NULL, return FALSE;);
	IRDA_ASSERT(self, return FALSE;);

	if (self->io.speed > 115200) {
		iobase = self->io.fir_base;
@@ -1095,8 +1092,9 @@ static int w83977af_is_receiving(struct w83977af_ir *self)
			status =  TRUE;
		}
		outb(set, iobase + SSR);
	} else
	} else {
		status = (self->rx_buff.state != OUTSIDE_FRAME);
	}

	return status;
}
@@ -1114,11 +1112,10 @@ static int w83977af_net_open(struct net_device *dev)
	char hwname[32];
	__u8 set;


	IRDA_ASSERT(dev != NULL, return -1;);
	IRDA_ASSERT(dev, return -1;);
	self = netdev_priv(dev);

	IRDA_ASSERT(self != NULL, return 0;);
	IRDA_ASSERT(self, return 0;);

	iobase = self->io.fir_base;

@@ -1143,8 +1140,9 @@ static int w83977af_net_open(struct net_device *dev)
	if (self->io.speed > 115200) {
		outb(ICR_EFSFI, iobase + ICR);
		w83977af_dma_receive(self);
	} else
	} else {
		outb(ICR_ERBRI, iobase + ICR);
	}

	/* Restore bank register */
	outb(set, iobase + SSR);
@@ -1176,11 +1174,11 @@ static int w83977af_net_close(struct net_device *dev)
	int iobase;
	__u8 set;

	IRDA_ASSERT(dev != NULL, return -1;);
	IRDA_ASSERT(dev, return -1;);

	self = netdev_priv(dev);

	IRDA_ASSERT(self != NULL, return 0;);
	IRDA_ASSERT(self, return 0;);

	iobase = self->io.fir_base;

@@ -1223,13 +1221,13 @@ static int w83977af_net_ioctl(struct net_device *dev, struct ifreq *rq, int cmd)
	unsigned long flags;
	int ret = 0;

	IRDA_ASSERT(dev != NULL, return -1;);
	IRDA_ASSERT(dev, return -1;);

	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);

@@ -1263,7 +1261,6 @@ MODULE_AUTHOR("Dag Brattli <dagb@cs.uit.no>");
MODULE_DESCRIPTION("Winbond W83977AF IrDA Device Driver");
MODULE_LICENSE("GPL");


module_param(qos_mtt_bits, int, 0);
MODULE_PARM_DESC(qos_mtt_bits, "Mimimum Turn Time");
module_param_array(io, int, NULL, 0);