]> err.no Git - linux-2.6/blobdiff - drivers/pci/hotplug/shpchp.h
[PATCH] shpchp - cleanup slot list
[linux-2.6] / drivers / pci / hotplug / shpchp.h
index 7d6f521d02ea128adf2fa0472f9afcd093186476..c0be7a1c3ff7af98ba9529cb41864d6cf28b1611 100644 (file)
@@ -33,6 +33,7 @@
 #include <linux/pci.h>
 #include <linux/delay.h>
 #include <linux/sched.h>       /* signal_pending(), struct timer_list */
+#include <linux/mutex.h>
 
 #include "pci_hotplug.h"
 
@@ -55,7 +56,6 @@ extern int shpchp_debug;
 #define SLOT_MAGIC     0x67267321
 struct slot {
        u32 magic;
-       struct slot *next;
        u8 bus;
        u8 device;
        u16 status;
@@ -79,14 +79,14 @@ struct event_info {
 
 struct controller {
        struct controller *next;
-       struct semaphore crit_sect;     /* critical section semaphore */
+       struct mutex crit_sect;         /* critical section mutex */
        struct php_ctlr_state_s *hpc_ctlr_handle; /* HPC controller handle */
        int num_slots;                  /* Number of slots on ctlr */
        int slot_num_inc;               /* 1 or -1 */
        struct pci_dev *pci_dev;
        struct pci_bus *pci_bus;
        struct event_info event_queue[10];
-       struct slot *slot;
+       struct list_head slot_list;
        struct hpc_ops *hpc_ops;
        wait_queue_head_t queue;        /* sleep & wake process */
        u8 next_event;
@@ -314,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)
 {
-       struct slot *p_slot, *tmp_slot = NULL;
+       struct slot *slot;
 
        if (!ctrl)
                return NULL;
 
-       p_slot = ctrl->slot;
-
-       while (p_slot && (p_slot->device != device)) {
-               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;
+       list_for_each_entry(slot, &ctrl->slot_list, slot_list) {
+               if (slot->device == device)
+                       return 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)
@@ -427,13 +423,6 @@ static inline void amd_pogo_errata_restore_misc_reg(struct slot *p_slot)
        pci_write_config_dword(p_slot->ctrl->pci_dev, PCIX_MISCII_OFFSET, pcix_misc2_temp);
 }
 
-#define SLOT_NAME_SIZE 10
-
-static inline void make_slot_name(char *buffer, int buffer_size, struct slot *slot)
-{
-       snprintf(buffer, buffer_size, "%04d_%04d", slot->bus, slot->number);
-}
-
 enum php_ctlr_type {
        PCI,
        ISA,