[ltp] irda patch (revised) -- please test!
Thomas Hood
linux-thinkpad@www.bm-soft.com
Fri, 02 Mar 2001 20:52:51 -0500
This is a multi-part message in MIME format.
--------------003F627C7415E6009CB67025
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit
Here's an updated version of the patch. The change is
minor: formerly a variable was declared as an int instead
of as a pointer, resulting in a compiler warning.
Thomas
> On the linux-irda mailing list, one of the maintainers of the
> irda driver has said that he would like users of the nsc-ircc
> driver to test the patch I submitted before he forwards the
> changes to Linus. So I'd like to ask anyone who can do so
> to test the patch (attached to this message, or get the updated
> irda.o and nsc-ircc.o modules for 2.4.2 kernel at my website
> http://panopticon.csustan.edu/thood/tp600lnx.htm
> ), and report success or failure. The patch is an important
> one: I think that anyone who tried to get FIR working on a
> ThinkPad would have had trouble due to the bugs in the
> nsc-ircc driver. To me the changes in the patch seem
> "obviously correct", but testing is always a good idea.
>
> Thomas
>
--------------003F627C7415E6009CB67025
Content-Type: text/plain; charset=us-ascii;
name="irda.patch"
Content-Transfer-Encoding: 7bit
Content-Disposition: inline;
filename="irda.patch"
--- drivers/net/irda/nsc-ircc.c_2.4.2 Tue Feb 13 16:15:05 2001
+++ drivers/net/irda/nsc-ircc.c Fri Mar 2 20:01:23 2001
@@ -90,7 +90,7 @@
static nsc_chip_t chips[] = {
{ "PC87108", { 0x150, 0x398, 0xea }, 0x05, 0x10, 0xf0,
nsc_ircc_probe_108, nsc_ircc_init_108 },
- { "PC87338", { 0x398, 0x15c, 0x2e }, 0x08, 0xb0, 0xf0,
+ { "PC87338", { 0x398, 0x15c, 0x2e }, 0x08, 0xb0, 0xf8,
nsc_ircc_probe_338, nsc_ircc_init_338 },
{ NULL }
};
@@ -160,7 +160,7 @@
int i = 0;
/* Probe for all the NSC chipsets we know about */
- for (chip=chips; chip->name ; chip++,i++) {
+ for (chip=chips; chip->name ; chip++) {
IRDA_DEBUG(2, __FUNCTION__"(), Probing for %s ...\n",
chip->name);
@@ -180,7 +180,7 @@
reg = inb(cfg_base);
if (reg == 0xff) {
IRDA_DEBUG(2, __FUNCTION__
- "() no chip at 0x%03x\n", cfg_base);
+ "(), No chip seen at io address 0x%03x\n", cfg_base);
continue;
}
@@ -189,14 +189,14 @@
id = inb(cfg_base+1);
if ((id & chip->cid_mask) == chip->cid_value) {
IRDA_DEBUG(2, __FUNCTION__
- "() Found %s chip, revision=%d\n",
+ "(), Found %s chip, revision=%d\n",
chip->name, id & ~chip->cid_mask);
/*
* If the user supplies the base address, then
* we init the chip, if not we probe the values
* set by the BIOS
*/
- if (io[i] < 2000) {
+ if (io[i] < 0x2000) {
chip->init(chip, &info);
} else
chip->probe(chip, &info);
@@ -246,7 +246,6 @@
struct net_device *dev;
struct nsc_ircc_cb *self;
struct pm_dev *pmdev;
- int ret;
int err;
IRDA_DEBUG(2, __FUNCTION__ "()\n");
@@ -257,7 +256,7 @@
/* Allocate new instance of the driver */
self = kmalloc(sizeof(struct nsc_ircc_cb), GFP_KERNEL);
if (self == NULL) {
- ERROR(__FUNCTION__ "(), can't allocate memory for "
+ ERROR(__FUNCTION__ "(), Can't allocate memory for "
"control block!\n");
return -ENOMEM;
}
@@ -277,15 +276,13 @@
self->io.fifo_size = 32;
/* Reserve the ioports that we need */
- ret = check_region(self->io.fir_base, self->io.fir_ext);
- if (ret < 0) {
- WARNING(__FUNCTION__ "(), can't get iobase of 0x%03x\n",
+ if (request_region(self->io.fir_base, self->io.fir_ext, driver_name) == NULL) {
+ WARNING(__FUNCTION__ "(), Request for io region at 0x%03x was refused\n",
self->io.fir_base);
dev_self[i] = NULL;
kfree(self);
- return -ENODEV;
+ return -EBUSY;
}
- request_region(self->io.fir_base, self->io.fir_ext, driver_name);
/* Initialize QoS for this device */
irda_init_max_qos_capabilies(&self->qos);
@@ -350,7 +347,7 @@
err = register_netdevice(dev);
rtnl_unlock();
if (err) {
- ERROR(__FUNCTION__ "(), register_netdev() failed!\n");
+ ERROR(__FUNCTION__ "(), register_netdevice() failed!\n");
return -1;
}
MESSAGE("IrDA: Registered device %s\n", dev->name);
@@ -401,7 +398,7 @@
}
/* Release the PORT that this driver is using */
- IRDA_DEBUG(4, __FUNCTION__ "(), Releasing Region %03x\n",
+ IRDA_DEBUG(4, __FUNCTION__ "(), Releasing io region at %03x\n",
self->io.fir_base);
release_region(self->io.fir_base, self->io.fir_ext);
@@ -439,7 +436,7 @@
case 0x2e8: outb(0x15, cfg_base+1); break;
case 0x3f8: outb(0x16, cfg_base+1); break;
case 0x2f8: outb(0x17, cfg_base+1); break;
- default: ERROR(__FUNCTION__ "(), invalid base_address");
+ default: ERROR(__FUNCTION__ "(), Invalid base_address");
}
/* Control Signal Routing Register (CSRT) */
@@ -451,7 +448,7 @@
case 9: temp = 0x05; break;
case 11: temp = 0x06; break;
case 15: temp = 0x07; break;
- default: ERROR(__FUNCTION__ "(), invalid irq");
+ default: ERROR(__FUNCTION__ "(), Invalid irq");
}
outb(1, cfg_base);
@@ -459,7 +456,7 @@
case 0: outb(0x08+temp, cfg_base+1); break;
case 1: outb(0x10+temp, cfg_base+1); break;
case 3: outb(0x18+temp, cfg_base+1); break;
- default: ERROR(__FUNCTION__ "(), invalid dma");
+ default: ERROR(__FUNCTION__ "(), Invalid dma");
}
outb(2, cfg_base); /* Mode Control Register (MCTL) */
@@ -498,7 +495,7 @@
break;
}
info->sir_base = info->fir_base;
- IRDA_DEBUG(2, __FUNCTION__ "(), probing fir_base=0x%03x\n",
+ IRDA_DEBUG(2, __FUNCTION__ "(), Probing fir_base 0x%03x\n",
info->fir_base);
/* Read control signals routing register (CSRT) */
@@ -531,7 +528,7 @@
info->irq = 15;
break;
}
- IRDA_DEBUG(2, __FUNCTION__ "(), probing irq=%d\n", info->irq);
+ IRDA_DEBUG(2, __FUNCTION__ "(), Probing irq %d\n", info->irq);
/* Currently we only read Rx DMA but it will also be used for Tx */
switch ((reg >> 3) & 0x03) {
@@ -548,7 +545,7 @@
info->dma = 3;
break;
}
- IRDA_DEBUG(2, __FUNCTION__ "(), probing dma=%d\n", info->dma);
+ IRDA_DEBUG(2, __FUNCTION__ "(), Probing dma %d\n", info->dma);
/* Read mode control register (MCTL) */
outb(CFG_MCTL, cfg_base);
@@ -597,7 +594,7 @@
outb(CFG_PNP0, cfg_base);
reg = inb(cfg_base+1);
- pnp = (reg >> 4) & 0x01;
+ pnp = (reg >> 3) & 0x01;
if (pnp) {
IRDA_DEBUG(2, "(), Chip is in PnP mode\n");
outb(0x46, cfg_base);
@@ -696,10 +693,10 @@
/* Should be 0x2? */
if (0x20 != (version & 0xf0)) {
- ERROR("%s, Wrong chip version %02x\n", driver_name, version);
+ ERROR("%s, Incorrect module version=%02x\n", driver_name, version);
return -1;
}
- MESSAGE("%s, Found chip at base=0x%03x\n", driver_name,
+ MESSAGE("%s, Found chip at io base 0x%03x\n", driver_name,
info->cfg_base);
/* Switch to advanced mode */
@@ -729,7 +726,7 @@
outb(0x0d, iobase+2); /* Set SIR pulse width to 1.6us */
outb(0x2a, iobase+4); /* Set beginning frag, and preamble length */
- MESSAGE("%s, driver loaded (Dag Brattli)\n", driver_name);
+ MESSAGE("%s, Driver loaded (Dag Brattli)\n", driver_name);
/* Enable receive interrupts */
switch_bank(iobase, BANK0);
@@ -851,7 +848,7 @@
outb(0x62, iobase+MCR);
break;
default:
- IRDA_DEBUG(0, __FUNCTION__ "(), invalid dongle_id %#x",
+ IRDA_DEBUG(0, __FUNCTION__ "(), Invalid dongle_id=%#x",
dongle_id);
}
@@ -943,7 +940,7 @@
outb(0x62, iobase+MCR);
break;
default:
- IRDA_DEBUG(0, __FUNCTION__ "(), invalid data_rate\n");
+ IRDA_DEBUG(0, __FUNCTION__ "(), Invalid data_rate\n");
}
/* Restore bank register */
outb(bank, iobase+BSR);
@@ -995,19 +992,19 @@
outb(inb(iobase+4) | 0x04, iobase+4);
mcr = MCR_MIR;
- IRDA_DEBUG(0, __FUNCTION__ "(), handling baud of 576000\n");
+ IRDA_DEBUG(0, __FUNCTION__ "(), Handling 576000 baud\n");
break;
case 1152000:
mcr = MCR_MIR;
- IRDA_DEBUG(0, __FUNCTION__ "(), handling baud of 1152000\n");
+ IRDA_DEBUG(0, __FUNCTION__ "(), Handling 1152000 baud\n");
break;
case 4000000:
mcr = MCR_FIR;
- IRDA_DEBUG(0, __FUNCTION__ "(), handling baud of 4000000\n");
+ IRDA_DEBUG(0, __FUNCTION__ "(), Handling 4000000 baud\n");
break;
default:
mcr = MCR_FIR;
- IRDA_DEBUG(0, __FUNCTION__ "(), unknown baud rate of %d\n",
+ IRDA_DEBUG(0, __FUNCTION__ "(), Unknown baud rate=%d\n",
speed);
break;
}
@@ -1279,7 +1276,7 @@
switch_bank(iobase, BANK0);
if (!(inb_p(iobase+LSR) & LSR_TXEMP)) {
IRDA_DEBUG(4, __FUNCTION__
- "(), warning, FIFO not empty yet!\n");
+ "(), Warning: FIFO not empty yet!\n");
/* FIFO may still be filled to the Tx interrupt threshold */
fifo_size -= 17;
@@ -1291,7 +1288,7 @@
outb(buf[actual++], iobase+TXD);
}
- IRDA_DEBUG(4, __FUNCTION__ "(), fifo_size %d ; %d sent of %d\n",
+ IRDA_DEBUG(4, __FUNCTION__ "(), Fifo_size=%d ; %d of %d sent\n",
fifo_size, actual, len);
/* Restore bank */
@@ -1449,7 +1446,7 @@
len = inb(iobase+RFLFL) | ((inb(iobase+RFLFH) & 0x1f) << 8);
if (st_fifo->tail >= MAX_RX_WINDOW) {
- IRDA_DEBUG(0, __FUNCTION__ "(), window is full!\n");
+ IRDA_DEBUG(0, __FUNCTION__ "(), Window is full!\n");
continue;
}
@@ -1539,7 +1536,7 @@
skb = dev_alloc_skb(len+1);
if (skb == NULL) {
- WARNING(__FUNCTION__ "(), memory squeeze, "
+ WARNING(__FUNCTION__ "(), Memory squeeze, "
"dropping frame.\n");
self->stats.rx_dropped++;
@@ -1847,7 +1844,7 @@
iobase = self->io.fir_base;
if (request_irq(self->io.irq, nsc_ircc_interrupt, 0, dev->name, dev)) {
- WARNING("%s, unable to allocate irq=%d\n", driver_name,
+ WARNING("%s, Request for irq %d was refused\n", driver_name,
self->io.irq);
return -EAGAIN;
}
@@ -1856,7 +1853,7 @@
* failure.
*/
if (request_dma(self->io.dma, dev->name)) {
- WARNING("%s, unable to allocate dma=%d\n", driver_name,
+ WARNING("%s, Request for dma %d was refused\n", driver_name,
self->io.dma);
free_irq(self->io.irq, self);
return -EAGAIN;
--- net/irda/af_irda.c_2.4.2 Mon Jan 29 01:59:34 2001
+++ net/irda/af_irda.c Mon Feb 26 19:12:12 2001
@@ -2434,5 +2434,7 @@
MODULE_AUTHOR("Dag Brattli <dagb@cs.uit.no>");
MODULE_DESCRIPTION("The Linux IrDA Protocol Subsystem");
+#ifdef CONFIG_IRDA_DEBUG
MODULE_PARM(irda_debug, "1l");
+#endif
#endif /* MODULE */
--------------003F627C7415E6009CB67025--
----- The Linux ThinkPad mailing list -----
The linux-thinkpad mailing list home page is at:
http://www.bm-soft.com/~bm/tp_mailing.html