vserver 1.9.5.x5
[linux-2.6.git] / drivers / char / ip2main.c
index ac97e61..fca9a97 100644 (file)
 #include <linux/cdk.h>
 #include <linux/comstats.h>
 #include <linux/delay.h>
+#include <linux/bitops.h>
 
 #include <asm/system.h>
 #include <asm/io.h>
 #include <asm/irq.h>
-#include <asm/bitops.h>
 
 #include <linux/vmalloc.h>
 #include <linux/init.h>
 #include <linux/proc_fs.h>
 
 static int ip2_read_procmem(char *, char **, off_t, int);
-int ip2_read_proc(char *, char **, off_t, int, int *, void * );
+static int ip2_read_proc(char *, char **, off_t, int, int *, void * );
 
 /********************/
 /* Type Definitions */
@@ -202,7 +202,6 @@ static void do_status(void *p);
 static void ip2_wait_until_sent(PTTY,int);
 
 static void set_params (i2ChanStrPtr, struct termios *);
-static int set_modem_info(i2ChanStrPtr, unsigned int, unsigned int *);
 static int get_serial_info(i2ChanStrPtr, struct serial_struct __user *);
 static int set_serial_info(i2ChanStrPtr, struct serial_struct __user *);
 
@@ -440,6 +439,12 @@ cleanup_module(void)
        // free memory
        for (i = 0; i < IP2_MAX_BOARDS; i++) {
                void *pB;
+#ifdef CONFIG_PCI
+               if (ip2config.type[i] == PCI && ip2config.pci_dev[i]) {
+                       pci_disable_device(ip2config.pci_dev[i]);
+                       ip2config.pci_dev[i] = NULL;
+               }
+#endif
                if ((pB = i2BoardPtrTable[i]) != 0 ) {
                        kfree ( pB );
                        i2BoardPtrTable[i] = NULL;
@@ -594,9 +599,14 @@ ip2_loadmain(int *iop, int *irqp, unsigned char *firmware, int firmsize)
                                                          PCI_DEVICE_ID_COMPUTONE_IP2EX, pci_dev_i);
                                if (pci_dev_i != NULL) {
                                        unsigned int addr;
-                                       unsigned char pci_irq;
 
+                                       if (pci_enable_device(pci_dev_i)) {
+                                               printk( KERN_ERR "IP2: can't enable PCI device at %s\n",
+                                                       pci_name(pci_dev_i));
+                                               break;
+                                       }
                                        ip2config.type[i] = PCI;
+                                       ip2config.pci_dev[i] = pci_dev_i;
                                        status =
                                        pci_read_config_dword(pci_dev_i, PCI_BASE_ADDRESS_1, &addr);
                                        if ( addr & 1 ) {
@@ -604,8 +614,6 @@ ip2_loadmain(int *iop, int *irqp, unsigned char *firmware, int firmsize)
                                        } else {
                                                printk( KERN_ERR "IP2: PCI I/O address error\n");
                                        }
-                                       status =
-                                       pci_read_config_byte(pci_dev_i, PCI_INTERRUPT_LINE, &pci_irq);
 
 //             If the PCI BIOS assigned it, lets try and use it.  If we
 //             can't acquire it or it screws up, deal with it then.
@@ -614,7 +622,7 @@ ip2_loadmain(int *iop, int *irqp, unsigned char *firmware, int firmsize)
 //                                             printk( KERN_ERR "IP2: Bad PCI BIOS IRQ(%d)\n",pci_irq);
 //                                             pci_irq = 0;
 //                                     }
-                                       ip2config.irq[i] = pci_irq;
+                                       ip2config.irq[i] = pci_dev_i->irq;
                                } else {        // ann error
                                        ip2config.addr[i] = 0;
                                        if (status == PCIBIOS_DEVICE_NOT_FOUND) {
@@ -1623,8 +1631,7 @@ ip2_close( PTTY tty, struct file *pFile )
 
        if (pCh->wopen) {
                if (pCh->ClosingDelay) {
-                       current->state = TASK_INTERRUPTIBLE;
-                       schedule_timeout(pCh->ClosingDelay);
+                       msleep_interruptible(jiffies_to_msecs(pCh->ClosingDelay));
                }
                wake_up_interruptible(&pCh->open_wait);
        }
@@ -3089,7 +3096,7 @@ ip2_read_procmem(char *buf, char **start, off_t offset, int len)
  * different sources including ip2mkdev.c and a couple of other drivers.
  * The bugs are all mine.  :-) =mhw=
  */
-int ip2_read_proc(char *page, char **start, off_t off,
+static int ip2_read_proc(char *page, char **start, off_t off,
                                int count, int *eof, void *data)
 {
        int     i, j, box;