patch-2.4.5 linux/drivers/net/irda/toshoboe.c

Next file: linux/drivers/net/mace.c
Previous file: linux/drivers/net/irda/nsc-ircc.c
Back to the patch index
Back to the overall index

diff -u --recursive --new-file v2.4.4/linux/drivers/net/irda/toshoboe.c linux/drivers/net/irda/toshoboe.c
@@ -81,10 +81,18 @@
 
 #include <net/irda/toshoboe.h>
 
-static char *driver_name = "toshoboe";
+#define PCI_DEVICE_ID_FIR701b  0x0d01
 
-static struct toshoboe_cb *dev_self[NSELFS + 1] =
-{NULL, NULL, NULL, NULL, NULL};
+static struct pci_device_id toshoboe_pci_tbl[] __initdata = {
+	{ PCI_VENDOR_ID_TOSHIBA, PCI_DEVICE_ID_FIR701, PCI_ANY_ID, PCI_ANY_ID, },
+	{ PCI_VENDOR_ID_TOSHIBA, PCI_DEVICE_ID_FIR701b, PCI_ANY_ID, PCI_ANY_ID, },
+	{ }			/* Terminating entry */
+};
+MODULE_DEVICE_TABLE(pci, toshoboe_pci_tbl);
+
+static const char *driver_name = "toshoboe";
+
+static struct toshoboe_cb *dev_self[NSELFS + 1];
 
 static int max_baud = 4000000;
 
@@ -191,8 +199,8 @@
   outb_p (OBOE_NTR_VAL, OBOE_NTR);
   outb_p (0xf0, OBOE_REG_D);
   outb_p (0xff, OBOE_ISR);
-  outb_p (0x0f, OBOE_REG_1A);
-  outb_p (0xff, OBOE_REG_1B);
+  outb_p (0x0f, OBOE_REG_1B);
+  outb_p (0xff, OBOE_REG_1A);
 
 
   physaddr = virt_to_bus (self->taskfile);
@@ -608,18 +616,21 @@
 	/* Disable interrupts & save flags */
 	save_flags(flags);
 	cli();
-	
 	switch (cmd) {
 	case SIOCSBANDWIDTH: /* Set bandwidth */
-		if (!capable(CAP_NET_ADMIN))
-			return -EPERM;
+		if (!capable(CAP_NET_ADMIN)) {
+			ret = -EPERM;
+			goto out;
+		}
 		/* toshoboe_setbaud(self, irq->ifr_baudrate); */
                 /* Just change speed once - inserted by Paul Bristow */
 	        self->new_speed = irq->ifr_baudrate;
 		break;
 	case SIOCSMEDIABUSY: /* Set media busy */
-		if (!capable(CAP_NET_ADMIN))
-			return -EPERM;
+		if (!capable(CAP_NET_ADMIN)) {
+			ret = -EPERM;
+			goto out;
+		}
 		irda_device_set_media_busy(self->netdev, TRUE);
 		break;
 	case SIOCGRECEIVING: /* Check if we are receiving right now */
@@ -628,9 +639,8 @@
 	default:
 		ret = -EOPNOTSUPP;
 	}
-	
+out:
 	restore_flags(flags);
-	
 	return ret;
 }
 
@@ -712,6 +722,9 @@
       return -ENOMEM;
     }
 
+  if ((err=pci_enable_device(pci_dev)))
+	  return err;
+
   self = kmalloc (sizeof (struct toshoboe_cb), GFP_KERNEL);
 
   if (self == NULL)
@@ -898,7 +911,7 @@
 /*FIXME: can't sleep here wait one second */
 
   while ((i--) && (self->txpending))
-    mdelay (100);
+    udelay (100);
 
   toshoboe_stopchip (self);
   toshoboe_disablebm (self);
@@ -978,6 +991,24 @@
 
     }
   while (pci_dev);
+
+  if (!found) do
+    {
+      pci_dev = pci_find_device (PCI_VENDOR_ID_TOSHIBA,
+                                 PCI_DEVICE_ID_FIR701b, pci_dev);
+      if (pci_dev)
+        {
+          printk (KERN_WARNING "ToshOboe: Found 701b chip at 0x%0lx irq %d\n",
+		  pci_dev->resource[0].start,
+                  pci_dev->irq);
+
+          if (!toshoboe_open (pci_dev))
+	      found++;
+        }
+
+    }
+  while (pci_dev);
+
 
 
   if (found)

FUNET's LINUX-ADM group, linux-adm@nic.funet.fi
TCL-scripts by Sam Shen (who was at: slshen@lbl.gov)