[PATCH] shpchp - move slot name into struct slot
[safe/jmp/linux-2.6] / drivers / pci / hotplug / shpchp.h
index 7d6f521..dc12b0d 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"
 
@@ -52,10 +53,8 @@ extern int shpchp_debug;
 #define info(format, arg...) printk(KERN_INFO "%s: " format, MY_NAME , ## arg)
 #define warn(format, arg...) printk(KERN_WARNING "%s: " format, MY_NAME , ## arg)
 
-#define SLOT_MAGIC     0x67267321
+#define SLOT_NAME_SIZE 10
 struct slot {
-       u32 magic;
-       struct slot *next;
        u8 bus;
        u8 device;
        u16 status;
@@ -70,6 +69,7 @@ struct slot {
        struct hpc_ops *hpc_ops;
        struct hotplug_slot *hotplug_slot;
        struct list_head        slot_list;
+       char name[SLOT_NAME_SIZE];
 };
 
 struct event_info {
@@ -78,15 +78,16 @@ struct event_info {
 };
 
 struct controller {
-       struct controller *next;
-       struct semaphore crit_sect;     /* critical section semaphore */
+       struct list_head ctrl_list;
+       struct mutex crit_sect;         /* critical section mutex */
+       struct mutex cmd_lock;          /* command lock */
        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;
@@ -204,7 +205,7 @@ extern void shpchp_remove_ctrl_files(struct controller *ctrl);
 
 
 /* Global variables */
-extern struct controller *shpchp_ctrl_list;
+extern struct list_head shpchp_ctrl_list;
 
 struct ctrl_reg {
        volatile u32 base_offset;
@@ -286,10 +287,6 @@ static inline int slot_paranoia_check (struct slot *slot, const char *function)
                dbg("%s - slot == NULL", function);
                return -1;
        }
-       if (slot->magic != SLOT_MAGIC) {
-               dbg("%s - bad magic number for slot", function);
-               return -1;
-       }
        if (!slot->hotplug_slot) {
                dbg("%s - slot->hotplug_slot == NULL!", function);
                return -1;
@@ -314,23 +311,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 +420,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,