vserver 1.9.5.x5
[linux-2.6.git] / drivers / pci / hotplug / shpchp_hpc.c
index 60331cc..38c5d90 100644 (file)
@@ -35,6 +35,7 @@
 #include <linux/vmalloc.h>
 #include <linux/interrupt.h>
 #include <linux/spinlock.h>
+#include <linux/delay.h>
 #include <linux/pci.h>
 #include <asm/system.h>
 #include "shpchp.h"
 static spinlock_t hpc_event_lock;
 
 DEFINE_DBG_BUFFER              /* Debug string buffer for entire HPC defined here */
-static struct php_ctlr_state_s *php_ctlr_list_head = 0;        /* HPC state linked list */
+static struct php_ctlr_state_s *php_ctlr_list_head;    /* HPC state linked list */
 static int ctlr_seq_num = 0;   /* Controller sequenc # */
 static spinlock_t list_lock;
 
@@ -300,8 +301,7 @@ static int shpc_write_cmd(struct slot *slot, u8 t_slot, u8 cmd)
                if (!(cmd_status & 0x1))
                        break;
                /*  Check every 0.1 sec for a total of 1 sec*/
-               set_current_state(TASK_INTERRUPTIBLE);
-               schedule_timeout(HZ/10);
+               msleep(100);
        }
 
        cmd_status = readw(php_ctlr->creg + CMD_STATUS);
@@ -792,6 +792,7 @@ static void hpc_release_ctlr(struct controller *ctrl)
                if (php_ctlr->irq) {
                        free_irq(php_ctlr->irq, ctrl);
                        php_ctlr->irq = 0;
+                       pci_disable_msi(php_ctlr->pci_dev);
                }
        }
        if (php_ctlr->pci_dev) {
@@ -799,7 +800,7 @@ static void hpc_release_ctlr(struct controller *ctrl)
                iounmap(php_ctlr->creg);
                release_mem_region(pci_resource_start(php_ctlr->pci_dev, 0), pci_resource_len(php_ctlr->pci_dev, 0));
                dbg("%s: before calling iounmap & release_mem_region\n", __FUNCTION__);
-               php_ctlr->pci_dev = 0;
+               php_ctlr->pci_dev = NULL;
        }
 
        spin_lock(&list_lock);
@@ -1158,7 +1159,7 @@ static irqreturn_t shpc_isr(int IRQ, void *dev_id, struct pt_regs *regs)
                                        hp_slot, php_ctlr->callback_instance_id);
                        
                        /* Clear all slot events */
-                       temp_dword = 0xe01fffff;
+                       temp_dword = 0xe01f3fff;
                        dbg("%s: Clearing slot events, temp_dword = %x\n",
                                __FUNCTION__, temp_dword); 
                        writel(temp_dword, php_ctlr->creg + SLOT1 + (4*hp_slot));
@@ -1486,14 +1487,16 @@ int shpc_init(struct controller * ctrl,
 
        info("HPC vendor_id %x device_id %x ss_vid %x ss_did %x\n", pdev->vendor, pdev->device, pdev->subsystem_vendor, 
                pdev->subsystem_device);
+       
+       if (pci_enable_device(pdev))
+               goto abort_free_ctlr;
 
        if (!request_mem_region(pci_resource_start(pdev, 0) + shpc_base_offset, pci_resource_len(pdev, 0), MY_NAME)) {
                err("%s: cannot reserve MMIO region\n", __FUNCTION__);
                goto abort_free_ctlr;
        }
 
-       php_ctlr->creg = (struct ctrl_reg *)
-               ioremap(pci_resource_start(pdev, 0) + shpc_base_offset, pci_resource_len(pdev, 0));
+       php_ctlr->creg = ioremap(pci_resource_start(pdev, 0) + shpc_base_offset, pci_resource_len(pdev, 0));
        if (!php_ctlr->creg) {
                err("%s: cannot remap MMIO region %lx @ %lx\n", __FUNCTION__, pci_resource_len(pdev, 0), 
                        pci_resource_start(pdev, 0) + shpc_base_offset);
@@ -1539,7 +1542,7 @@ int shpc_init(struct controller * ctrl,
                slot_reg = readl(php_ctlr->creg + SLOT1 + 4*hp_slot );
                dbg("%s: Default Logical Slot Register %d value %x\n", __FUNCTION__,
                        hp_slot, slot_reg);
-               tempdword = 0xffffffff;  
+               tempdword = 0xffff3fff;  
                writel(tempdword, php_ctlr->creg + SLOT1 + (4*hp_slot));
        }
        
@@ -1572,7 +1575,7 @@ int shpc_init(struct controller * ctrl,
        if (php_ctlr_list_head == 0) {
                php_ctlr_list_head = php_ctlr;
                p = php_ctlr_list_head;
-               p->pnext = 0;
+               p->pnext = NULL;
        } else {
                p = php_ctlr_list_head;
 
@@ -1592,7 +1595,7 @@ int shpc_init(struct controller * ctrl,
                slot_reg = readl(php_ctlr->creg + SLOT1 + 4*hp_slot );
                dbg("%s: Default Logical Slot Register %d value %x\n", __FUNCTION__,
                        hp_slot, slot_reg);
-               tempdword = 0xe01fffff;  
+               tempdword = 0xe01f3fff;  
                writel(tempdword, php_ctlr->creg + SLOT1 + (4*hp_slot));
        }
        if (!shpchp_poll_mode) {