[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>
This commit is contained in:
parent
dfcd5f68ec
commit
5b1a960d18
@ -56,7 +56,6 @@ extern int shpchp_debug;
|
|||||||
#define SLOT_MAGIC 0x67267321
|
#define SLOT_MAGIC 0x67267321
|
||||||
struct slot {
|
struct slot {
|
||||||
u32 magic;
|
u32 magic;
|
||||||
struct slot *next;
|
|
||||||
u8 bus;
|
u8 bus;
|
||||||
u8 device;
|
u8 device;
|
||||||
u16 status;
|
u16 status;
|
||||||
@ -87,7 +86,7 @@ struct controller {
|
|||||||
struct pci_dev *pci_dev;
|
struct pci_dev *pci_dev;
|
||||||
struct pci_bus *pci_bus;
|
struct pci_bus *pci_bus;
|
||||||
struct event_info event_queue[10];
|
struct event_info event_queue[10];
|
||||||
struct slot *slot;
|
struct list_head slot_list;
|
||||||
struct hpc_ops *hpc_ops;
|
struct hpc_ops *hpc_ops;
|
||||||
wait_queue_head_t queue; /* sleep & wake process */
|
wait_queue_head_t queue; /* sleep & wake process */
|
||||||
u8 next_event;
|
u8 next_event;
|
||||||
@ -315,23 +314,19 @@ static inline struct slot *get_slot (struct hotplug_slot *hotplug_slot, const ch
|
|||||||
|
|
||||||
static inline struct slot *shpchp_find_slot (struct controller *ctrl, u8 device)
|
static inline struct slot *shpchp_find_slot (struct controller *ctrl, u8 device)
|
||||||
{
|
{
|
||||||
struct slot *p_slot, *tmp_slot = NULL;
|
struct slot *slot;
|
||||||
|
|
||||||
if (!ctrl)
|
if (!ctrl)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
p_slot = ctrl->slot;
|
list_for_each_entry(slot, &ctrl->slot_list, slot_list) {
|
||||||
|
if (slot->device == device)
|
||||||
while (p_slot && (p_slot->device != device)) {
|
return slot;
|
||||||
tmp_slot = p_slot;
|
|
||||||
p_slot = p_slot->next;
|
|
||||||
}
|
|
||||||
if (p_slot == NULL) {
|
|
||||||
err("ERROR: shpchp_find_slot device=0x%x\n", device);
|
|
||||||
p_slot = tmp_slot;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return (p_slot);
|
err("%s: slot (device=0x%x) not found\n", __FUNCTION__, device);
|
||||||
|
|
||||||
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline int wait_for_ctrl_irq (struct controller *ctrl)
|
static inline int wait_for_ctrl_irq (struct controller *ctrl)
|
||||||
|
@ -173,8 +173,7 @@ static int init_slots(struct controller *ctrl)
|
|||||||
goto error_name;
|
goto error_name;
|
||||||
}
|
}
|
||||||
|
|
||||||
slot->next = ctrl->slot;
|
list_add(&slot->slot_list, &ctrl->slot_list);
|
||||||
ctrl->slot = slot;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
@ -192,15 +191,14 @@ error:
|
|||||||
|
|
||||||
static void cleanup_slots(struct controller *ctrl)
|
static void cleanup_slots(struct controller *ctrl)
|
||||||
{
|
{
|
||||||
struct slot *old_slot, *next_slot;
|
struct list_head *tmp;
|
||||||
|
struct list_head *next;
|
||||||
|
struct slot *slot;
|
||||||
|
|
||||||
old_slot = ctrl->slot;
|
list_for_each_safe(tmp, next, &ctrl->slot_list) {
|
||||||
ctrl->slot = NULL;
|
slot = list_entry(tmp, struct slot, slot_list);
|
||||||
|
list_del(&slot->slot_list);
|
||||||
while (old_slot) {
|
pci_hp_deregister(slot->hotplug_slot);
|
||||||
next_slot = old_slot->next;
|
|
||||||
pci_hp_deregister(old_slot->hotplug_slot);
|
|
||||||
old_slot = next_slot;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -391,6 +389,7 @@ static int shpc_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
|
|||||||
goto err_out_none;
|
goto err_out_none;
|
||||||
}
|
}
|
||||||
memset(ctrl, 0, sizeof(struct controller));
|
memset(ctrl, 0, sizeof(struct controller));
|
||||||
|
INIT_LIST_HEAD(&ctrl->slot_list);
|
||||||
|
|
||||||
rc = shpc_init(ctrl, pdev);
|
rc = shpc_init(ctrl, pdev);
|
||||||
if (rc) {
|
if (rc) {
|
||||||
|
Loading…
Reference in New Issue
Block a user