linux 2.6.16.38 w/ vs2.0.3-rc1
[linux-2.6.git] / drivers / pci / hotplug / pciehp_core.c
index c67b7c3..4fb5690 100644 (file)
@@ -69,7 +69,6 @@ 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);
 
@@ -82,7 +81,6 @@ 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,
 };
@@ -119,23 +117,27 @@ static int init_slots(struct controller *ctrl)
        slot_number = ctrl->first_slot;
 
        while (number_of_slots) {
-               slot = kzalloc(sizeof(*slot), GFP_KERNEL);
+               slot = kmalloc(sizeof(*slot), GFP_KERNEL);
                if (!slot)
                        goto error;
 
+               memset(slot, 0, sizeof(struct slot));
                slot->hotplug_slot =
-                               kzalloc(sizeof(*(slot->hotplug_slot)),
+                               kmalloc(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 =
-                       kzalloc(sizeof(*(hotplug_slot->info)),
+                       kmalloc(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;
@@ -333,18 +335,6 @@ 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;
@@ -383,11 +373,12 @@ static int pciehp_probe(struct pcie_device *dev, const struct pcie_port_service_
        u8 value;
        struct pci_dev *pdev;
        
-       ctrl = kzalloc(sizeof(*ctrl), GFP_KERNEL);
+       ctrl = kmalloc(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;
@@ -448,7 +439,7 @@ static int pciehp_probe(struct pcie_device *dev, const struct pcie_port_service_
        }
 
        /* Wait for exclusive access to hardware */
-       mutex_lock(&ctrl->crit_sect);
+       down(&ctrl->crit_sect);
 
        t_slot->hpc_ops->get_adapter_status(t_slot, &value); /* Check if slot is occupied */
        
@@ -456,7 +447,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 */
-                       mutex_unlock(&ctrl->crit_sect);
+                       up(&ctrl->crit_sect);
                        goto err_out_free_ctrl_slot;
                } else
                        /* Wait for the command to complete */
@@ -464,7 +455,7 @@ static int pciehp_probe(struct pcie_device *dev, const struct pcie_port_service_
        }
 
        /* Done with exclusive hardware access */
-       mutex_unlock(&ctrl->crit_sect);
+       up(&ctrl->crit_sect);
 
        return 0;