fedora core 6 1.2949 + vserver 2.2.0
[linux-2.6.git] / drivers / pci / hotplug / pciehp_core.c
index 4fb5690..f13f313 100644 (file)
@@ -69,6 +69,7 @@ static int get_power_status   (struct hotplug_slot *slot, u8 *value);
 static int get_attention_status        (struct hotplug_slot *slot, u8 *value);
 static int get_latch_status    (struct hotplug_slot *slot, u8 *value);
 static int get_adapter_status  (struct hotplug_slot *slot, u8 *value);
+static int get_address         (struct hotplug_slot *slot, u32 *value);
 static int get_max_bus_speed   (struct hotplug_slot *slot, enum pci_bus_speed *value);
 static int get_cur_bus_speed   (struct hotplug_slot *slot, enum pci_bus_speed *value);
 
@@ -81,6 +82,7 @@ static struct hotplug_slot_ops pciehp_hotplug_slot_ops = {
        .get_attention_status = get_attention_status,
        .get_latch_status =     get_latch_status,
        .get_adapter_status =   get_adapter_status,
+       .get_address =          get_address,
        .get_max_bus_speed =    get_max_bus_speed,
        .get_cur_bus_speed =    get_cur_bus_speed,
 };
@@ -117,27 +119,23 @@ static int init_slots(struct controller *ctrl)
        slot_number = ctrl->first_slot;
 
        while (number_of_slots) {
-               slot = kmalloc(sizeof(*slot), GFP_KERNEL);
+               slot = kzalloc(sizeof(*slot), GFP_KERNEL);
                if (!slot)
                        goto error;
 
-               memset(slot, 0, sizeof(struct slot));
                slot->hotplug_slot =
-                               kmalloc(sizeof(*(slot->hotplug_slot)),
+                               kzalloc(sizeof(*(slot->hotplug_slot)),
                                                GFP_KERNEL);
                if (!slot->hotplug_slot)
                        goto error_slot;
                hotplug_slot = slot->hotplug_slot;
-               memset(hotplug_slot, 0, sizeof(struct hotplug_slot));
 
                hotplug_slot->info =
-                       kmalloc(sizeof(*(hotplug_slot->info)),
+                       kzalloc(sizeof(*(hotplug_slot->info)),
                                                GFP_KERNEL);
                if (!hotplug_slot->info)
                        goto error_hpslot;
                hotplug_slot_info = hotplug_slot->info;
-               memset(hotplug_slot_info, 0,
-                                       sizeof(struct hotplug_slot_info));
                hotplug_slot->name = kmalloc(SLOT_NAME_SIZE, GFP_KERNEL);
                if (!hotplug_slot->name)
                        goto error_info;
@@ -335,6 +333,18 @@ static int get_adapter_status(struct hotplug_slot *hotplug_slot, u8 *value)
        return 0;
 }
 
+static int get_address(struct hotplug_slot *hotplug_slot, u32 *value)
+{
+       struct slot *slot = hotplug_slot->private;
+       struct pci_bus *bus = slot->ctrl->pci_dev->subordinate;
+
+       dbg("%s - physical_slot = %s\n", __FUNCTION__, hotplug_slot->name);
+
+       *value = (pci_domain_nr(bus) << 16) | (slot->bus << 8) | slot->device;
+
+       return 0;
+}
+
 static int get_max_bus_speed(struct hotplug_slot *hotplug_slot, enum pci_bus_speed *value)
 {
        struct slot *slot = hotplug_slot->private;
@@ -373,12 +383,11 @@ static int pciehp_probe(struct pcie_device *dev, const struct pcie_port_service_
        u8 value;
        struct pci_dev *pdev;
        
-       ctrl = kmalloc(sizeof(*ctrl), GFP_KERNEL);
+       ctrl = kzalloc(sizeof(*ctrl), GFP_KERNEL);
        if (!ctrl) {
                err("%s : out of memory\n", __FUNCTION__);
                goto err_out_none;
        }
-       memset(ctrl, 0, sizeof(struct controller));
 
        pdev = dev->port;
        ctrl->pci_dev = pdev;
@@ -439,7 +448,7 @@ static int pciehp_probe(struct pcie_device *dev, const struct pcie_port_service_
        }
 
        /* Wait for exclusive access to hardware */
-       down(&ctrl->crit_sect);
+       mutex_lock(&ctrl->ctrl_lock);
 
        t_slot->hpc_ops->get_adapter_status(t_slot, &value); /* Check if slot is occupied */
        
@@ -447,7 +456,7 @@ static int pciehp_probe(struct pcie_device *dev, const struct pcie_port_service_
                rc = t_slot->hpc_ops->power_off_slot(t_slot); /* Power off slot if not occupied*/
                if (rc) {
                        /* Done with exclusive hardware access */
-                       up(&ctrl->crit_sect);
+                       mutex_unlock(&ctrl->ctrl_lock);
                        goto err_out_free_ctrl_slot;
                } else
                        /* Wait for the command to complete */
@@ -455,7 +464,7 @@ static int pciehp_probe(struct pcie_device *dev, const struct pcie_port_service_
        }
 
        /* Done with exclusive hardware access */
-       up(&ctrl->crit_sect);
+       mutex_unlock(&ctrl->ctrl_lock);
 
        return 0;
 
@@ -512,14 +521,9 @@ static void __exit unload_pciehpd(void)
 
 }
 
-static int hpdriver_context = 0;
-
 static void pciehp_remove (struct pcie_device *device)
 {
-       printk("%s ENTRY\n", __FUNCTION__);     
-       printk("%s -> Call free_irq for irq = %d\n",  
-               __FUNCTION__, device->irq);
-       free_irq(device->irq, &hpdriver_context);
+       /* XXX - Needs to be adapted to device driver model */
 }
 
 #ifdef CONFIG_PM