aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/pci
diff options
context:
space:
mode:
authorKenji Kaneshige <kaneshige.kenji@jp.fujitsu.com>2006-12-21 20:01:03 -0500
committerGreg Kroah-Hartman <gregkh@suse.de>2007-02-07 18:50:04 -0500
commit2410fa4eaec4133f9fa8968f277ddb28b89b92b3 (patch)
treed005980c5adbab8c612c2bf8c95a362b7375e7b6 /drivers/pci
parenta0b1725720d9a023a1dee129234f5972056038c6 (diff)
pciehp: cleanup slot list
This patch cleans up slot list handling (use list_head). This has no functional change. Signed-off-by: Kenji Kaneshige <kaneshige.kenji@jp.fujitsu.com> Signed-off-by: Kristen Carlson Accardi <kristen.c.accardi@intel.com> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Diffstat (limited to 'drivers/pci')
-rw-r--r--drivers/pci/hotplug/pciehp.h19
-rw-r--r--drivers/pci/hotplug/pciehp_core.c25
2 files changed, 17 insertions, 27 deletions
diff --git a/drivers/pci/hotplug/pciehp.h b/drivers/pci/hotplug/pciehp.h
index 6a2f427768ca..d07ac45f1272 100644
--- a/drivers/pci/hotplug/pciehp.h
+++ b/drivers/pci/hotplug/pciehp.h
@@ -52,7 +52,6 @@ extern int pciehp_force;
52 52
53#define SLOT_NAME_SIZE 10 53#define SLOT_NAME_SIZE 10
54struct slot { 54struct slot {
55 struct slot *next;
56 u8 bus; 55 u8 bus;
57 u8 device; 56 u8 device;
58 u32 number; 57 u32 number;
@@ -99,6 +98,7 @@ struct controller {
99 int slot_num_inc; /* 1 or -1 */ 98 int slot_num_inc; /* 1 or -1 */
100 struct pci_dev *pci_dev; 99 struct pci_dev *pci_dev;
101 struct pci_bus *pci_bus; 100 struct pci_bus *pci_bus;
101 struct list_head slot_list;
102 struct event_info event_queue[MAX_EVENTS]; 102 struct event_info event_queue[MAX_EVENTS];
103 struct slot *slot; 103 struct slot *slot;
104 struct hpc_ops *hpc_ops; 104 struct hpc_ops *hpc_ops;
@@ -198,20 +198,15 @@ extern struct controller *pciehp_ctrl_list;
198 198
199static inline struct slot *pciehp_find_slot(struct controller *ctrl, u8 device) 199static inline struct slot *pciehp_find_slot(struct controller *ctrl, u8 device)
200{ 200{
201 struct slot *p_slot, *tmp_slot = NULL; 201 struct slot *slot;
202
203 p_slot = ctrl->slot;
204 202
205 while (p_slot && (p_slot->device != device)) { 203 list_for_each_entry(slot, &ctrl->slot_list, slot_list) {
206 tmp_slot = p_slot; 204 if (slot->device == device)
207 p_slot = p_slot->next; 205 return slot;
208 }
209 if (p_slot == NULL) {
210 err("ERROR: pciehp_find_slot device=0x%x\n", device);
211 p_slot = tmp_slot;
212 } 206 }
213 207
214 return p_slot; 208 err("%s: slot (device=0x%x) not found\n", __FUNCTION__, device);
209 return NULL;
215} 210}
216 211
217static inline int wait_for_ctrl_irq(struct controller *ctrl) 212static inline int wait_for_ctrl_irq(struct controller *ctrl)
diff --git a/drivers/pci/hotplug/pciehp_core.c b/drivers/pci/hotplug/pciehp_core.c
index 051d228e634e..2ddde79e252c 100644
--- a/drivers/pci/hotplug/pciehp_core.c
+++ b/drivers/pci/hotplug/pciehp_core.c
@@ -160,8 +160,7 @@ static int init_slots(struct controller *ctrl)
160 goto error_info; 160 goto error_info;
161 } 161 }
162 162
163 slot->next = ctrl->slot; 163 list_add(&slot->slot_list, &ctrl->slot_list);
164 ctrl->slot = slot;
165 } 164 }
166 165
167 return 0; 166 return 0;
@@ -175,22 +174,17 @@ error:
175 return retval; 174 return retval;
176} 175}
177 176
178 177static void cleanup_slots(struct controller *ctrl)
179static int cleanup_slots (struct controller * ctrl)
180{ 178{
181 struct slot *old_slot, *next_slot; 179 struct list_head *tmp;
182 180 struct list_head *next;
183 old_slot = ctrl->slot; 181 struct slot *slot;
184 ctrl->slot = NULL;
185 182
186 while (old_slot) { 183 list_for_each_safe(tmp, next, &ctrl->slot_list) {
187 next_slot = old_slot->next; 184 slot = list_entry(tmp, struct slot, slot_list);
188 pci_hp_deregister (old_slot->hotplug_slot); 185 list_del(&slot->slot_list);
189 old_slot = next_slot; 186 pci_hp_deregister(slot->hotplug_slot);
190 } 187 }
191
192
193 return(0);
194} 188}
195 189
196static int get_ctlr_slot_config(struct controller *ctrl) 190static int get_ctlr_slot_config(struct controller *ctrl)
@@ -368,6 +362,7 @@ static int pciehp_probe(struct pcie_device *dev, const struct pcie_port_service_
368 err("%s : out of memory\n", __FUNCTION__); 362 err("%s : out of memory\n", __FUNCTION__);
369 goto err_out_none; 363 goto err_out_none;
370 } 364 }
365 INIT_LIST_HEAD(&ctrl->slot_list);
371 366
372 pdev = dev->port; 367 pdev = dev->port;
373 ctrl->pci_dev = pdev; 368 ctrl->pci_dev = pdev;