diff options
author | Kenji Kaneshige <kaneshige.kenji@jp.fujitsu.com> | 2006-01-25 19:57:40 -0500 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@suse.de> | 2006-03-23 17:35:11 -0500 |
commit | 5b1a960d180e9660a87b0c661a754efabc1b1d3a (patch) | |
tree | f49931b000ff784c3267f134ff3734f640fcd5d7 /drivers | |
parent | dfcd5f68ec916414532e88583d1557b6ac0197f5 (diff) |
[PATCH] shpchp - cleanup slot list
This patch changes SHPCHP driver to use list_head structure for
managing slot list.
Signed-off-by: Kenji Kaneshige <kaneshige.kenji@jp.fujitsu.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/pci/hotplug/shpchp.h | 21 | ||||
-rw-r--r-- | drivers/pci/hotplug/shpchp_core.c | 19 |
2 files changed, 17 insertions, 23 deletions
diff --git a/drivers/pci/hotplug/shpchp.h b/drivers/pci/hotplug/shpchp.h index e03ee0826700..c0be7a1c3ff7 100644 --- a/drivers/pci/hotplug/shpchp.h +++ b/drivers/pci/hotplug/shpchp.h | |||
@@ -56,7 +56,6 @@ extern int shpchp_debug; | |||
56 | #define SLOT_MAGIC 0x67267321 | 56 | #define SLOT_MAGIC 0x67267321 |
57 | struct slot { | 57 | struct slot { |
58 | u32 magic; | 58 | u32 magic; |
59 | struct slot *next; | ||
60 | u8 bus; | 59 | u8 bus; |
61 | u8 device; | 60 | u8 device; |
62 | u16 status; | 61 | u16 status; |
@@ -87,7 +86,7 @@ struct controller { | |||
87 | struct pci_dev *pci_dev; | 86 | struct pci_dev *pci_dev; |
88 | struct pci_bus *pci_bus; | 87 | struct pci_bus *pci_bus; |
89 | struct event_info event_queue[10]; | 88 | struct event_info event_queue[10]; |
90 | struct slot *slot; | 89 | struct list_head slot_list; |
91 | struct hpc_ops *hpc_ops; | 90 | struct hpc_ops *hpc_ops; |
92 | wait_queue_head_t queue; /* sleep & wake process */ | 91 | wait_queue_head_t queue; /* sleep & wake process */ |
93 | u8 next_event; | 92 | u8 next_event; |
@@ -315,23 +314,19 @@ static inline struct slot *get_slot (struct hotplug_slot *hotplug_slot, const ch | |||
315 | 314 | ||
316 | static inline struct slot *shpchp_find_slot (struct controller *ctrl, u8 device) | 315 | static inline struct slot *shpchp_find_slot (struct controller *ctrl, u8 device) |
317 | { | 316 | { |
318 | struct slot *p_slot, *tmp_slot = NULL; | 317 | struct slot *slot; |
319 | 318 | ||
320 | if (!ctrl) | 319 | if (!ctrl) |
321 | return NULL; | 320 | return NULL; |
322 | 321 | ||
323 | p_slot = ctrl->slot; | 322 | list_for_each_entry(slot, &ctrl->slot_list, slot_list) { |
324 | 323 | if (slot->device == device) | |
325 | while (p_slot && (p_slot->device != device)) { | 324 | return slot; |
326 | tmp_slot = p_slot; | ||
327 | p_slot = p_slot->next; | ||
328 | } | ||
329 | if (p_slot == NULL) { | ||
330 | err("ERROR: shpchp_find_slot device=0x%x\n", device); | ||
331 | p_slot = tmp_slot; | ||
332 | } | 325 | } |
333 | 326 | ||
334 | return (p_slot); | 327 | err("%s: slot (device=0x%x) not found\n", __FUNCTION__, device); |
328 | |||
329 | return NULL; | ||
335 | } | 330 | } |
336 | 331 | ||
337 | static inline int wait_for_ctrl_irq (struct controller *ctrl) | 332 | static inline int wait_for_ctrl_irq (struct controller *ctrl) |
diff --git a/drivers/pci/hotplug/shpchp_core.c b/drivers/pci/hotplug/shpchp_core.c index 7f2e775534eb..547bf5d6fcca 100644 --- a/drivers/pci/hotplug/shpchp_core.c +++ b/drivers/pci/hotplug/shpchp_core.c | |||
@@ -173,8 +173,7 @@ static int init_slots(struct controller *ctrl) | |||
173 | goto error_name; | 173 | goto error_name; |
174 | } | 174 | } |
175 | 175 | ||
176 | slot->next = ctrl->slot; | 176 | list_add(&slot->slot_list, &ctrl->slot_list); |
177 | ctrl->slot = slot; | ||
178 | } | 177 | } |
179 | 178 | ||
180 | return 0; | 179 | return 0; |
@@ -192,15 +191,14 @@ error: | |||
192 | 191 | ||
193 | static void cleanup_slots(struct controller *ctrl) | 192 | static void cleanup_slots(struct controller *ctrl) |
194 | { | 193 | { |
195 | struct slot *old_slot, *next_slot; | 194 | struct list_head *tmp; |
196 | 195 | struct list_head *next; | |
197 | old_slot = ctrl->slot; | 196 | struct slot *slot; |
198 | ctrl->slot = NULL; | ||
199 | 197 | ||
200 | while (old_slot) { | 198 | list_for_each_safe(tmp, next, &ctrl->slot_list) { |
201 | next_slot = old_slot->next; | 199 | slot = list_entry(tmp, struct slot, slot_list); |
202 | pci_hp_deregister(old_slot->hotplug_slot); | 200 | list_del(&slot->slot_list); |
203 | old_slot = next_slot; | 201 | pci_hp_deregister(slot->hotplug_slot); |
204 | } | 202 | } |
205 | } | 203 | } |
206 | 204 | ||
@@ -391,6 +389,7 @@ static int shpc_probe(struct pci_dev *pdev, const struct pci_device_id *ent) | |||
391 | goto err_out_none; | 389 | goto err_out_none; |
392 | } | 390 | } |
393 | memset(ctrl, 0, sizeof(struct controller)); | 391 | memset(ctrl, 0, sizeof(struct controller)); |
392 | INIT_LIST_HEAD(&ctrl->slot_list); | ||
394 | 393 | ||
395 | rc = shpc_init(ctrl, pdev); | 394 | rc = shpc_init(ctrl, pdev); |
396 | if (rc) { | 395 | if (rc) { |