[PATCH] PCI: Reduce nr of ptr derefs in drivers/pci/hotplug/rpaphp_pci.c
[powerpc.git] / drivers / pci / hotplug / shpchp_core.c
index 28ed2dc..a2b3f00 100644 (file)
@@ -65,6 +65,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);
 
@@ -77,6 +78,7 @@ static struct hotplug_slot_ops shpchp_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,
 };
@@ -105,8 +107,6 @@ static int init_slots(struct controller *ctrl)
        u32 slot_number, sun;
        int result = -ENOMEM;
 
-       dbg("%s\n",__FUNCTION__);
-
        number_of_slots = ctrl->num_slots;
        slot_device = ctrl->slot_device_offset;
        slot_number = ctrl->first_slot;
@@ -316,6 +316,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 = get_slot (hotplug_slot, __FUNCTION__);
+       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 = get_slot (hotplug_slot, __FUNCTION__);
@@ -373,17 +385,12 @@ static int shpc_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
        }
        memset(ctrl, 0, sizeof(struct controller));
 
-       dbg("DRV_thread pid = %d\n", current->pid);
-
        rc = shpc_init(ctrl, pdev);
        if (rc) {
                dbg("%s: controller initialization failed\n", SHPC_MODULE_NAME);
                goto err_out_free_ctrl;
        }
 
-       dbg("%s: controller initialization success\n", __FUNCTION__);
-       ctrl->pci_dev = pdev;  /* pci_dev of the P2P bridge */
-
        pci_set_drvdata(pdev, ctrl);
 
        ctrl->pci_bus = kmalloc (sizeof (*ctrl->pci_bus), GFP_KERNEL);
@@ -485,11 +492,10 @@ static void __exit unload_shpchpd(void)
        ctrl = shpchp_ctrl_list;
 
        while (ctrl) {
+               shpchp_remove_ctrl_files(ctrl);
                cleanup_slots(ctrl);
 
                kfree (ctrl->pci_bus);
-
-               dbg("%s: calling release_ctlr\n", __FUNCTION__);
                ctrl->hpc_ops->release_ctlr(ctrl);
 
                tctrl = ctrl;
@@ -558,7 +564,6 @@ static void __exit shpcd_cleanup(void)
        dbg("unload_shpchpd()\n");
        unload_shpchpd();
 
-       dbg("pci_unregister_driver\n");
        pci_unregister_driver(&shpc_driver);
 
        info(DRIVER_DESC " version: " DRIVER_VERSION " unloaded\n");