aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authorBjorn Helgaas <bhelgaas@google.com>2016-01-20 12:48:25 -0500
committerBjorn Helgaas <bhelgaas@google.com>2016-01-20 12:48:25 -0500
commit9662e32c810ad3e6ce49832d5f585a54f8fbdbdb (patch)
treefd9fd3f8cd44e231b8dc71c2e360eb19963972d5 /drivers
parent904f664b585cc9f3dc134a8c0dd08e9bce6c10bc (diff)
parentbd7900825a3db4c4916fafb400c1f669120039d2 (diff)
Merge branch 'pci/trivial' into next
* pci/trivial: PCI: shpchp: Constify hpc_ops structure PCI: Use kobj_to_dev() instead of open-coding it PCI: Use to_pci_dev() instead of open-coding it PCI: Fix all whitespace issues PCI/MSI: Fix typos in <linux/msi.h>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/pci/access.c8
-rw-r--r--drivers/pci/host/pci-imx6.c2
-rw-r--r--drivers/pci/hotplug/acpi_pcihp.c10
-rw-r--r--drivers/pci/hotplug/acpiphp.h2
-rw-r--r--drivers/pci/hotplug/acpiphp_core.c14
-rw-r--r--drivers/pci/hotplug/acpiphp_glue.c2
-rw-r--r--drivers/pci/hotplug/acpiphp_ibm.c2
-rw-r--r--drivers/pci/hotplug/cpci_hotplug.h14
-rw-r--r--drivers/pci/hotplug/cpci_hotplug_core.c16
-rw-r--r--drivers/pci/hotplug/cpci_hotplug_pci.c10
-rw-r--r--drivers/pci/hotplug/cpcihp_generic.c12
-rw-r--r--drivers/pci/hotplug/cpcihp_zt5550.c14
-rw-r--r--drivers/pci/hotplug/cpqphp.h14
-rw-r--r--drivers/pci/hotplug/cpqphp_core.c32
-rw-r--r--drivers/pci/hotplug/cpqphp_ctrl.c200
-rw-r--r--drivers/pci/hotplug/cpqphp_nvram.c92
-rw-r--r--drivers/pci/hotplug/cpqphp_pci.c84
-rw-r--r--drivers/pci/hotplug/cpqphp_sysfs.c6
-rw-r--r--drivers/pci/hotplug/ibmphp.h12
-rw-r--r--drivers/pci/hotplug/ibmphp_core.c30
-rw-r--r--drivers/pci/hotplug/ibmphp_ebda.c508
-rw-r--r--drivers/pci/hotplug/ibmphp_hpc.c370
-rw-r--r--drivers/pci/hotplug/ibmphp_pci.c728
-rw-r--r--drivers/pci/hotplug/ibmphp_res.c482
-rw-r--r--drivers/pci/hotplug/pci_hotplug_core.c10
-rw-r--r--drivers/pci/hotplug/pciehp.h8
-rw-r--r--drivers/pci/hotplug/pciehp_core.c16
-rw-r--r--drivers/pci/hotplug/pcihp_skeleton.c24
-rw-r--r--drivers/pci/hotplug/rpaphp.h8
-rw-r--r--drivers/pci/hotplug/rpaphp_core.c2
-rw-r--r--drivers/pci/hotplug/rpaphp_pci.c2
-rw-r--r--drivers/pci/hotplug/rpaphp_slot.c2
-rw-r--r--drivers/pci/hotplug/sgi_hotplug.c6
-rw-r--r--drivers/pci/hotplug/shpchp.h14
-rw-r--r--drivers/pci/hotplug/shpchp_core.c28
-rw-r--r--drivers/pci/hotplug/shpchp_hpc.c4
-rw-r--r--drivers/pci/hotplug/shpchp_sysfs.c10
-rw-r--r--drivers/pci/pci-label.c4
-rw-r--r--drivers/pci/pci-sysfs.c40
-rw-r--r--drivers/pci/pci.c4
-rw-r--r--drivers/pci/setup-bus.c2
41 files changed, 1419 insertions, 1429 deletions
diff --git a/drivers/pci/access.c b/drivers/pci/access.c
index 59ac36fe7c42..8c05b5ceeaec 100644
--- a/drivers/pci/access.c
+++ b/drivers/pci/access.c
@@ -25,7 +25,7 @@ DEFINE_RAW_SPINLOCK(pci_lock);
25#define PCI_word_BAD (pos & 1) 25#define PCI_word_BAD (pos & 1)
26#define PCI_dword_BAD (pos & 3) 26#define PCI_dword_BAD (pos & 3)
27 27
28#define PCI_OP_READ(size,type,len) \ 28#define PCI_OP_READ(size, type, len) \
29int pci_bus_read_config_##size \ 29int pci_bus_read_config_##size \
30 (struct pci_bus *bus, unsigned int devfn, int pos, type *value) \ 30 (struct pci_bus *bus, unsigned int devfn, int pos, type *value) \
31{ \ 31{ \
@@ -40,7 +40,7 @@ int pci_bus_read_config_##size \
40 return res; \ 40 return res; \
41} 41}
42 42
43#define PCI_OP_WRITE(size,type,len) \ 43#define PCI_OP_WRITE(size, type, len) \
44int pci_bus_write_config_##size \ 44int pci_bus_write_config_##size \
45 (struct pci_bus *bus, unsigned int devfn, int pos, type value) \ 45 (struct pci_bus *bus, unsigned int devfn, int pos, type value) \
46{ \ 46{ \
@@ -231,7 +231,7 @@ static noinline void pci_wait_cfg(struct pci_dev *dev)
231} 231}
232 232
233/* Returns 0 on success, negative values indicate error. */ 233/* Returns 0 on success, negative values indicate error. */
234#define PCI_USER_READ_CONFIG(size,type) \ 234#define PCI_USER_READ_CONFIG(size, type) \
235int pci_user_read_config_##size \ 235int pci_user_read_config_##size \
236 (struct pci_dev *dev, int pos, type *val) \ 236 (struct pci_dev *dev, int pos, type *val) \
237{ \ 237{ \
@@ -251,7 +251,7 @@ int pci_user_read_config_##size \
251EXPORT_SYMBOL_GPL(pci_user_read_config_##size); 251EXPORT_SYMBOL_GPL(pci_user_read_config_##size);
252 252
253/* Returns 0 on success, negative values indicate error. */ 253/* Returns 0 on success, negative values indicate error. */
254#define PCI_USER_WRITE_CONFIG(size,type) \ 254#define PCI_USER_WRITE_CONFIG(size, type) \
255int pci_user_write_config_##size \ 255int pci_user_write_config_##size \
256 (struct pci_dev *dev, int pos, type val) \ 256 (struct pci_dev *dev, int pos, type val) \
257{ \ 257{ \
diff --git a/drivers/pci/host/pci-imx6.c b/drivers/pci/host/pci-imx6.c
index b039f0c6c8ff..fe600964fa50 100644
--- a/drivers/pci/host/pci-imx6.c
+++ b/drivers/pci/host/pci-imx6.c
@@ -122,7 +122,7 @@ static int pcie_phy_wait_ack(void __iomem *dbi_base, int addr)
122} 122}
123 123
124/* Read from the 16-bit PCIe PHY control registers (not memory-mapped) */ 124/* Read from the 16-bit PCIe PHY control registers (not memory-mapped) */
125static int pcie_phy_read(void __iomem *dbi_base, int addr , int *data) 125static int pcie_phy_read(void __iomem *dbi_base, int addr, int *data)
126{ 126{
127 u32 val, phy_ctl; 127 u32 val, phy_ctl;
128 int ret; 128 int ret;
diff --git a/drivers/pci/hotplug/acpi_pcihp.c b/drivers/pci/hotplug/acpi_pcihp.c
index 876ccc620440..a5e66df4ad14 100644
--- a/drivers/pci/hotplug/acpi_pcihp.c
+++ b/drivers/pci/hotplug/acpi_pcihp.c
@@ -36,10 +36,10 @@
36 36
37#define MY_NAME "acpi_pcihp" 37#define MY_NAME "acpi_pcihp"
38 38
39#define dbg(fmt, arg...) do { if (debug_acpi) printk(KERN_DEBUG "%s: %s: " fmt , MY_NAME , __func__ , ## arg); } while (0) 39#define dbg(fmt, arg...) do { if (debug_acpi) printk(KERN_DEBUG "%s: %s: " fmt, MY_NAME, __func__, ## arg); } while (0)
40#define err(format, arg...) printk(KERN_ERR "%s: " format , MY_NAME , ## arg) 40#define err(format, arg...) printk(KERN_ERR "%s: " format, MY_NAME, ## arg)
41#define info(format, arg...) printk(KERN_INFO "%s: " format , MY_NAME , ## arg) 41#define info(format, arg...) printk(KERN_INFO "%s: " format, MY_NAME, ## arg)
42#define warn(format, arg...) printk(KERN_WARNING "%s: " format , MY_NAME , ## arg) 42#define warn(format, arg...) printk(KERN_WARNING "%s: " format, MY_NAME, ## arg)
43 43
44#define METHOD_NAME__SUN "_SUN" 44#define METHOD_NAME__SUN "_SUN"
45#define METHOD_NAME_OSHP "OSHP" 45#define METHOD_NAME_OSHP "OSHP"
@@ -132,7 +132,7 @@ int acpi_get_hp_hw_control_from_firmware(struct pci_dev *pdev, u32 flags)
132 132
133 while (handle) { 133 while (handle) {
134 acpi_get_name(handle, ACPI_FULL_PATHNAME, &string); 134 acpi_get_name(handle, ACPI_FULL_PATHNAME, &string);
135 dbg("Trying to get hotplug control for %s \n", 135 dbg("Trying to get hotplug control for %s\n",
136 (char *)string.pointer); 136 (char *)string.pointer);
137 status = acpi_run_oshp(handle); 137 status = acpi_run_oshp(handle);
138 if (ACPI_SUCCESS(status)) 138 if (ACPI_SUCCESS(status))
diff --git a/drivers/pci/hotplug/acpiphp.h b/drivers/pci/hotplug/acpiphp.h
index b0e61bf261a7..f0ebc8b9a15a 100644
--- a/drivers/pci/hotplug/acpiphp.h
+++ b/drivers/pci/hotplug/acpiphp.h
@@ -181,7 +181,7 @@ struct acpiphp_attention_info
181/* function prototypes */ 181/* function prototypes */
182 182
183/* acpiphp_core.c */ 183/* acpiphp_core.c */
184int acpiphp_register_attention(struct acpiphp_attention_info*info); 184int acpiphp_register_attention(struct acpiphp_attention_info *info);
185int acpiphp_unregister_attention(struct acpiphp_attention_info *info); 185int acpiphp_unregister_attention(struct acpiphp_attention_info *info);
186int acpiphp_register_hotplug_slot(struct acpiphp_slot *slot, unsigned int sun); 186int acpiphp_register_hotplug_slot(struct acpiphp_slot *slot, unsigned int sun);
187void acpiphp_unregister_hotplug_slot(struct acpiphp_slot *slot); 187void acpiphp_unregister_hotplug_slot(struct acpiphp_slot *slot);
diff --git a/drivers/pci/hotplug/acpiphp_core.c b/drivers/pci/hotplug/acpiphp_core.c
index e291efcd02a2..3c81fc8b0103 100644
--- a/drivers/pci/hotplug/acpiphp_core.c
+++ b/drivers/pci/hotplug/acpiphp_core.c
@@ -63,13 +63,13 @@ MODULE_LICENSE("GPL");
63MODULE_PARM_DESC(disable, "disable acpiphp driver"); 63MODULE_PARM_DESC(disable, "disable acpiphp driver");
64module_param_named(disable, acpiphp_disabled, bool, 0444); 64module_param_named(disable, acpiphp_disabled, bool, 0444);
65 65
66static int enable_slot (struct hotplug_slot *slot); 66static int enable_slot(struct hotplug_slot *slot);
67static int disable_slot (struct hotplug_slot *slot); 67static int disable_slot(struct hotplug_slot *slot);
68static int set_attention_status (struct hotplug_slot *slot, u8 value); 68static int set_attention_status(struct hotplug_slot *slot, u8 value);
69static int get_power_status (struct hotplug_slot *slot, u8 *value); 69static int get_power_status(struct hotplug_slot *slot, u8 *value);
70static int get_attention_status (struct hotplug_slot *slot, u8 *value); 70static int get_attention_status(struct hotplug_slot *slot, u8 *value);
71static int get_latch_status (struct hotplug_slot *slot, u8 *value); 71static int get_latch_status(struct hotplug_slot *slot, u8 *value);
72static int get_adapter_status (struct hotplug_slot *slot, u8 *value); 72static int get_adapter_status(struct hotplug_slot *slot, u8 *value);
73 73
74static struct hotplug_slot_ops acpi_hotplug_slot_ops = { 74static struct hotplug_slot_ops acpi_hotplug_slot_ops = {
75 .enable_slot = enable_slot, 75 .enable_slot = enable_slot,
diff --git a/drivers/pci/hotplug/acpiphp_glue.c b/drivers/pci/hotplug/acpiphp_glue.c
index ff538568a617..5f2fda12e006 100644
--- a/drivers/pci/hotplug/acpiphp_glue.c
+++ b/drivers/pci/hotplug/acpiphp_glue.c
@@ -707,7 +707,7 @@ static void acpiphp_sanitize_bus(struct pci_bus *bus)
707 unsigned long type_mask = IORESOURCE_IO | IORESOURCE_MEM; 707 unsigned long type_mask = IORESOURCE_IO | IORESOURCE_MEM;
708 708
709 list_for_each_entry_safe_reverse(dev, tmp, &bus->devices, bus_list) { 709 list_for_each_entry_safe_reverse(dev, tmp, &bus->devices, bus_list) {
710 for (i=0; i<PCI_BRIDGE_RESOURCES; i++) { 710 for (i = 0; i < PCI_BRIDGE_RESOURCES; i++) {
711 struct resource *res = &dev->resource[i]; 711 struct resource *res = &dev->resource[i];
712 if ((res->flags & type_mask) && !res->start && 712 if ((res->flags & type_mask) && !res->start &&
713 res->end) { 713 res->end) {
diff --git a/drivers/pci/hotplug/acpiphp_ibm.c b/drivers/pci/hotplug/acpiphp_ibm.c
index 9d16c9dbd76e..2f6d3a1c1726 100644
--- a/drivers/pci/hotplug/acpiphp_ibm.c
+++ b/drivers/pci/hotplug/acpiphp_ibm.c
@@ -336,7 +336,7 @@ static int ibm_get_table_from_acpi(char **bufp)
336 } 336 }
337 337
338 size = 0; 338 size = 0;
339 for (i=0; i<package->package.count; i++) { 339 for (i = 0; i < package->package.count; i++) {
340 memcpy(&lbuf[size], 340 memcpy(&lbuf[size],
341 package->package.elements[i].buffer.pointer, 341 package->package.elements[i].buffer.pointer,
342 package->package.elements[i].buffer.length); 342 package->package.elements[i].buffer.length);
diff --git a/drivers/pci/hotplug/cpci_hotplug.h b/drivers/pci/hotplug/cpci_hotplug.h
index 6a0ddf757349..555bcde3b196 100644
--- a/drivers/pci/hotplug/cpci_hotplug.h
+++ b/drivers/pci/hotplug/cpci_hotplug.h
@@ -52,13 +52,13 @@ struct slot {
52}; 52};
53 53
54struct cpci_hp_controller_ops { 54struct cpci_hp_controller_ops {
55 int (*query_enum) (void); 55 int (*query_enum)(void);
56 int (*enable_irq) (void); 56 int (*enable_irq)(void);
57 int (*disable_irq) (void); 57 int (*disable_irq)(void);
58 int (*check_irq) (void *dev_id); 58 int (*check_irq)(void *dev_id);
59 int (*hardware_test) (struct slot *slot, u32 value); 59 int (*hardware_test)(struct slot *slot, u32 value);
60 u8 (*get_power) (struct slot *slot); 60 u8 (*get_power)(struct slot *slot);
61 int (*set_power) (struct slot *slot, int value); 61 int (*set_power)(struct slot *slot, int value);
62}; 62};
63 63
64struct cpci_hp_controller { 64struct cpci_hp_controller {
diff --git a/drivers/pci/hotplug/cpci_hotplug_core.c b/drivers/pci/hotplug/cpci_hotplug_core.c
index 46db29395a62..7d3866c47312 100644
--- a/drivers/pci/hotplug/cpci_hotplug_core.c
+++ b/drivers/pci/hotplug/cpci_hotplug_core.c
@@ -45,12 +45,12 @@
45#define dbg(format, arg...) \ 45#define dbg(format, arg...) \
46 do { \ 46 do { \
47 if (cpci_debug) \ 47 if (cpci_debug) \
48 printk (KERN_DEBUG "%s: " format "\n", \ 48 printk(KERN_DEBUG "%s: " format "\n", \
49 MY_NAME , ## arg); \ 49 MY_NAME, ## arg); \
50 } while (0) 50 } while (0)
51#define err(format, arg...) printk(KERN_ERR "%s: " format "\n", MY_NAME , ## arg) 51#define err(format, arg...) printk(KERN_ERR "%s: " format "\n", MY_NAME, ## arg)
52#define info(format, arg...) printk(KERN_INFO "%s: " format "\n", MY_NAME , ## arg) 52#define info(format, arg...) printk(KERN_INFO "%s: " format "\n", MY_NAME, ## arg)
53#define warn(format, arg...) printk(KERN_WARNING "%s: " format "\n", MY_NAME , ## arg) 53#define warn(format, arg...) printk(KERN_WARNING "%s: " format "\n", MY_NAME, ## arg)
54 54
55/* local variables */ 55/* local variables */
56static DECLARE_RWSEM(list_rwsem); 56static DECLARE_RWSEM(list_rwsem);
@@ -238,21 +238,21 @@ cpci_hp_register_bus(struct pci_bus *bus, u8 first, u8 last)
238 * with the pci_hotplug subsystem. 238 * with the pci_hotplug subsystem.
239 */ 239 */
240 for (i = first; i <= last; ++i) { 240 for (i = first; i <= last; ++i) {
241 slot = kzalloc(sizeof (struct slot), GFP_KERNEL); 241 slot = kzalloc(sizeof(struct slot), GFP_KERNEL);
242 if (!slot) { 242 if (!slot) {
243 status = -ENOMEM; 243 status = -ENOMEM;
244 goto error; 244 goto error;
245 } 245 }
246 246
247 hotplug_slot = 247 hotplug_slot =
248 kzalloc(sizeof (struct hotplug_slot), GFP_KERNEL); 248 kzalloc(sizeof(struct hotplug_slot), GFP_KERNEL);
249 if (!hotplug_slot) { 249 if (!hotplug_slot) {
250 status = -ENOMEM; 250 status = -ENOMEM;
251 goto error_slot; 251 goto error_slot;
252 } 252 }
253 slot->hotplug_slot = hotplug_slot; 253 slot->hotplug_slot = hotplug_slot;
254 254
255 info = kzalloc(sizeof (struct hotplug_slot_info), GFP_KERNEL); 255 info = kzalloc(sizeof(struct hotplug_slot_info), GFP_KERNEL);
256 if (!info) { 256 if (!info) {
257 status = -ENOMEM; 257 status = -ENOMEM;
258 goto error_hpslot; 258 goto error_hpslot;
diff --git a/drivers/pci/hotplug/cpci_hotplug_pci.c b/drivers/pci/hotplug/cpci_hotplug_pci.c
index 788db48dbbad..80c80017197d 100644
--- a/drivers/pci/hotplug/cpci_hotplug_pci.c
+++ b/drivers/pci/hotplug/cpci_hotplug_pci.c
@@ -38,12 +38,12 @@ extern int cpci_debug;
38#define dbg(format, arg...) \ 38#define dbg(format, arg...) \
39 do { \ 39 do { \
40 if (cpci_debug) \ 40 if (cpci_debug) \
41 printk (KERN_DEBUG "%s: " format "\n", \ 41 printk(KERN_DEBUG "%s: " format "\n", \
42 MY_NAME , ## arg); \ 42 MY_NAME, ## arg); \
43 } while (0) 43 } while (0)
44#define err(format, arg...) printk(KERN_ERR "%s: " format "\n", MY_NAME , ## arg) 44#define err(format, arg...) printk(KERN_ERR "%s: " format "\n", MY_NAME, ## arg)
45#define info(format, arg...) printk(KERN_INFO "%s: " format "\n", MY_NAME , ## arg) 45#define info(format, arg...) printk(KERN_INFO "%s: " format "\n", MY_NAME, ## arg)
46#define warn(format, arg...) printk(KERN_WARNING "%s: " format "\n", MY_NAME , ## arg) 46#define warn(format, arg...) printk(KERN_WARNING "%s: " format "\n", MY_NAME, ## arg)
47 47
48 48
49u8 cpci_get_attention_status(struct slot *slot) 49u8 cpci_get_attention_status(struct slot *slot)
diff --git a/drivers/pci/hotplug/cpcihp_generic.c b/drivers/pci/hotplug/cpcihp_generic.c
index 66b7bbebe493..88a44a707b96 100644
--- a/drivers/pci/hotplug/cpcihp_generic.c
+++ b/drivers/pci/hotplug/cpcihp_generic.c
@@ -54,12 +54,12 @@
54#define dbg(format, arg...) \ 54#define dbg(format, arg...) \
55 do { \ 55 do { \
56 if (debug) \ 56 if (debug) \
57 printk (KERN_DEBUG "%s: " format "\n", \ 57 printk(KERN_DEBUG "%s: " format "\n", \
58 MY_NAME , ## arg); \ 58 MY_NAME, ## arg); \
59 } while (0) 59 } while (0)
60#define err(format, arg...) printk(KERN_ERR "%s: " format "\n", MY_NAME , ## arg) 60#define err(format, arg...) printk(KERN_ERR "%s: " format "\n", MY_NAME, ## arg)
61#define info(format, arg...) printk(KERN_INFO "%s: " format "\n", MY_NAME , ## arg) 61#define info(format, arg...) printk(KERN_INFO "%s: " format "\n", MY_NAME, ## arg)
62#define warn(format, arg...) printk(KERN_WARNING "%s: " format "\n", MY_NAME , ## arg) 62#define warn(format, arg...) printk(KERN_WARNING "%s: " format "\n", MY_NAME, ## arg)
63 63
64/* local variables */ 64/* local variables */
65static bool debug; 65static bool debug;
@@ -164,7 +164,7 @@ static int __init cpcihp_generic_init(void)
164 bus = dev->subordinate; 164 bus = dev->subordinate;
165 pci_dev_put(dev); 165 pci_dev_put(dev);
166 166
167 memset(&generic_hpc, 0, sizeof (struct cpci_hp_controller)); 167 memset(&generic_hpc, 0, sizeof(struct cpci_hp_controller));
168 generic_hpc_ops.query_enum = query_enum; 168 generic_hpc_ops.query_enum = query_enum;
169 generic_hpc.ops = &generic_hpc_ops; 169 generic_hpc.ops = &generic_hpc_ops;
170 170
diff --git a/drivers/pci/hotplug/cpcihp_zt5550.c b/drivers/pci/hotplug/cpcihp_zt5550.c
index 7ecf34e76a61..5f49c3fd736a 100644
--- a/drivers/pci/hotplug/cpcihp_zt5550.c
+++ b/drivers/pci/hotplug/cpcihp_zt5550.c
@@ -49,12 +49,12 @@
49#define dbg(format, arg...) \ 49#define dbg(format, arg...) \
50 do { \ 50 do { \
51 if (debug) \ 51 if (debug) \
52 printk (KERN_DEBUG "%s: " format "\n", \ 52 printk(KERN_DEBUG "%s: " format "\n", \
53 MY_NAME , ## arg); \ 53 MY_NAME, ## arg); \
54 } while (0) 54 } while (0)
55#define err(format, arg...) printk(KERN_ERR "%s: " format "\n", MY_NAME , ## arg) 55#define err(format, arg...) printk(KERN_ERR "%s: " format "\n", MY_NAME, ## arg)
56#define info(format, arg...) printk(KERN_INFO "%s: " format "\n", MY_NAME , ## arg) 56#define info(format, arg...) printk(KERN_INFO "%s: " format "\n", MY_NAME, ## arg)
57#define warn(format, arg...) printk(KERN_WARNING "%s: " format "\n", MY_NAME , ## arg) 57#define warn(format, arg...) printk(KERN_WARNING "%s: " format "\n", MY_NAME, ## arg)
58 58
59/* local variables */ 59/* local variables */
60static bool debug; 60static bool debug;
@@ -204,7 +204,7 @@ static int zt5550_hc_disable_irq(void)
204 return 0; 204 return 0;
205} 205}
206 206
207static int zt5550_hc_init_one (struct pci_dev *pdev, const struct pci_device_id *ent) 207static int zt5550_hc_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
208{ 208{
209 int status; 209 int status;
210 210
@@ -214,7 +214,7 @@ static int zt5550_hc_init_one (struct pci_dev *pdev, const struct pci_device_id
214 214
215 dbg("returned from zt5550_hc_config"); 215 dbg("returned from zt5550_hc_config");
216 216
217 memset(&zt5550_hpc, 0, sizeof (struct cpci_hp_controller)); 217 memset(&zt5550_hpc, 0, sizeof(struct cpci_hp_controller));
218 zt5550_hpc_ops.query_enum = zt5550_hc_query_enum; 218 zt5550_hpc_ops.query_enum = zt5550_hc_query_enum;
219 zt5550_hpc.ops = &zt5550_hpc_ops; 219 zt5550_hpc.ops = &zt5550_hpc_ops;
220 if (!poll) { 220 if (!poll) {
diff --git a/drivers/pci/hotplug/cpqphp.h b/drivers/pci/hotplug/cpqphp.h
index b28b2d2184cd..9103a7b9f3b9 100644
--- a/drivers/pci/hotplug/cpqphp.h
+++ b/drivers/pci/hotplug/cpqphp.h
@@ -36,10 +36,10 @@
36 36
37#define MY_NAME "cpqphp" 37#define MY_NAME "cpqphp"
38 38
39#define dbg(fmt, arg...) do { if (cpqhp_debug) printk(KERN_DEBUG "%s: " fmt , MY_NAME , ## arg); } while (0) 39#define dbg(fmt, arg...) do { if (cpqhp_debug) printk(KERN_DEBUG "%s: " fmt, MY_NAME, ## arg); } while (0)
40#define err(format, arg...) printk(KERN_ERR "%s: " format , MY_NAME , ## arg) 40#define err(format, arg...) printk(KERN_ERR "%s: " format, MY_NAME, ## arg)
41#define info(format, arg...) printk(KERN_INFO "%s: " format , MY_NAME , ## arg) 41#define info(format, arg...) printk(KERN_INFO "%s: " format, MY_NAME, ## arg)
42#define warn(format, arg...) printk(KERN_WARNING "%s: " format , MY_NAME , ## arg) 42#define warn(format, arg...) printk(KERN_WARNING "%s: " format, MY_NAME, ## arg)
43 43
44 44
45 45
@@ -424,7 +424,7 @@ int cpqhp_process_SS(struct controller *ctrl, struct pci_func *func);
424int cpqhp_hardware_test(struct controller *ctrl, int test_num); 424int cpqhp_hardware_test(struct controller *ctrl, int test_num);
425 425
426/* resource functions */ 426/* resource functions */
427int cpqhp_resource_sort_and_combine (struct pci_resource **head); 427int cpqhp_resource_sort_and_combine(struct pci_resource **head);
428 428
429/* pci functions */ 429/* pci functions */
430int cpqhp_set_irq(u8 bus_num, u8 dev_num, u8 int_pin, u8 irq_num); 430int cpqhp_set_irq(u8 bus_num, u8 dev_num, u8 int_pin, u8 irq_num);
@@ -685,7 +685,7 @@ static inline int cpq_get_latch_status(struct controller *ctrl,
685 u8 hp_slot; 685 u8 hp_slot;
686 686
687 hp_slot = slot->device - ctrl->slot_device_offset; 687 hp_slot = slot->device - ctrl->slot_device_offset;
688 dbg("%s: slot->device = %d, ctrl->slot_device_offset = %d \n", 688 dbg("%s: slot->device = %d, ctrl->slot_device_offset = %d\n",
689 __func__, slot->device, ctrl->slot_device_offset); 689 __func__, slot->device, ctrl->slot_device_offset);
690 690
691 status = (readl(ctrl->hpc_reg + INT_INPUT_CLEAR) & (0x01L << hp_slot)); 691 status = (readl(ctrl->hpc_reg + INT_INPUT_CLEAR) & (0x01L << hp_slot));
@@ -712,7 +712,7 @@ static inline int get_presence_status(struct controller *ctrl,
712 712
713static inline int wait_for_ctrl_irq(struct controller *ctrl) 713static inline int wait_for_ctrl_irq(struct controller *ctrl)
714{ 714{
715 DECLARE_WAITQUEUE(wait, current); 715 DECLARE_WAITQUEUE(wait, current);
716 int retval = 0; 716 int retval = 0;
717 717
718 dbg("%s - start\n", __func__); 718 dbg("%s - start\n", __func__);
diff --git a/drivers/pci/hotplug/cpqphp_core.c b/drivers/pci/hotplug/cpqphp_core.c
index a53084ddc118..74f3a0695b43 100644
--- a/drivers/pci/hotplug/cpqphp_core.c
+++ b/drivers/pci/hotplug/cpqphp_core.c
@@ -291,7 +291,7 @@ static void release_slot(struct hotplug_slot *hotplug_slot)
291 kfree(slot); 291 kfree(slot);
292} 292}
293 293
294static int ctrl_slot_cleanup (struct controller *ctrl) 294static int ctrl_slot_cleanup(struct controller *ctrl)
295{ 295{
296 struct slot *old_slot, *next_slot; 296 struct slot *old_slot, *next_slot;
297 297
@@ -301,7 +301,7 @@ static int ctrl_slot_cleanup (struct controller *ctrl)
301 while (old_slot) { 301 while (old_slot) {
302 /* memory will be freed by the release_slot callback */ 302 /* memory will be freed by the release_slot callback */
303 next_slot = old_slot->next; 303 next_slot = old_slot->next;
304 pci_hp_deregister (old_slot->hotplug_slot); 304 pci_hp_deregister(old_slot->hotplug_slot);
305 old_slot = next_slot; 305 old_slot = next_slot;
306 } 306 }
307 307
@@ -413,9 +413,9 @@ cpqhp_set_attention_status(struct controller *ctrl, struct pci_func *func,
413 mutex_lock(&ctrl->crit_sect); 413 mutex_lock(&ctrl->crit_sect);
414 414
415 if (status == 1) 415 if (status == 1)
416 amber_LED_on (ctrl, hp_slot); 416 amber_LED_on(ctrl, hp_slot);
417 else if (status == 0) 417 else if (status == 0)
418 amber_LED_off (ctrl, hp_slot); 418 amber_LED_off(ctrl, hp_slot);
419 else { 419 else {
420 /* Done with exclusive hardware access */ 420 /* Done with exclusive hardware access */
421 mutex_unlock(&ctrl->crit_sect); 421 mutex_unlock(&ctrl->crit_sect);
@@ -425,7 +425,7 @@ cpqhp_set_attention_status(struct controller *ctrl, struct pci_func *func,
425 set_SOGO(ctrl); 425 set_SOGO(ctrl);
426 426
427 /* Wait for SOBS to be unset */ 427 /* Wait for SOBS to be unset */
428 wait_for_ctrl_irq (ctrl); 428 wait_for_ctrl_irq(ctrl);
429 429
430 /* Done with exclusive hardware access */ 430 /* Done with exclusive hardware access */
431 mutex_unlock(&ctrl->crit_sect); 431 mutex_unlock(&ctrl->crit_sect);
@@ -439,7 +439,7 @@ cpqhp_set_attention_status(struct controller *ctrl, struct pci_func *func,
439 * @hotplug_slot: slot to change LED on 439 * @hotplug_slot: slot to change LED on
440 * @status: LED control flag 440 * @status: LED control flag
441 */ 441 */
442static int set_attention_status (struct hotplug_slot *hotplug_slot, u8 status) 442static int set_attention_status(struct hotplug_slot *hotplug_slot, u8 status)
443{ 443{
444 struct pci_func *slot_func; 444 struct pci_func *slot_func;
445 struct slot *slot = hotplug_slot->private; 445 struct slot *slot = hotplug_slot->private;
@@ -610,7 +610,7 @@ static int ctrl_slot_setup(struct controller *ctrl,
610 u8 ctrl_slot; 610 u8 ctrl_slot;
611 u32 tempdword; 611 u32 tempdword;
612 char name[SLOT_NAME_SIZE]; 612 char name[SLOT_NAME_SIZE];
613 void __iomem *slot_entry= NULL; 613 void __iomem *slot_entry = NULL;
614 int result; 614 int result;
615 615
616 dbg("%s\n", __func__); 616 dbg("%s\n", __func__);
@@ -755,7 +755,7 @@ static int one_time_init(void)
755 if (cpqhp_debug) 755 if (cpqhp_debug)
756 pci_print_IRQ_route(); 756 pci_print_IRQ_route();
757 757
758 dbg("Initialize + Start the notification mechanism \n"); 758 dbg("Initialize + Start the notification mechanism\n");
759 759
760 retval = cpqhp_event_start_thread(); 760 retval = cpqhp_event_start_thread();
761 if (retval) 761 if (retval)
@@ -772,7 +772,7 @@ static int one_time_init(void)
772 /* Map rom address */ 772 /* Map rom address */
773 cpqhp_rom_start = ioremap(ROM_PHY_ADDR, ROM_PHY_LEN); 773 cpqhp_rom_start = ioremap(ROM_PHY_ADDR, ROM_PHY_LEN);
774 if (!cpqhp_rom_start) { 774 if (!cpqhp_rom_start) {
775 err ("Could not ioremap memory region for ROM\n"); 775 err("Could not ioremap memory region for ROM\n");
776 retval = -EIO; 776 retval = -EIO;
777 goto error; 777 goto error;
778 } 778 }
@@ -786,7 +786,7 @@ static int one_time_init(void)
786 smbios_table = detect_SMBIOS_pointer(cpqhp_rom_start, 786 smbios_table = detect_SMBIOS_pointer(cpqhp_rom_start,
787 cpqhp_rom_start + ROM_PHY_LEN); 787 cpqhp_rom_start + ROM_PHY_LEN);
788 if (!smbios_table) { 788 if (!smbios_table) {
789 err ("Could not find the SMBIOS pointer in memory\n"); 789 err("Could not find the SMBIOS pointer in memory\n");
790 retval = -EIO; 790 retval = -EIO;
791 goto error_rom_start; 791 goto error_rom_start;
792 } 792 }
@@ -794,7 +794,7 @@ static int one_time_init(void)
794 smbios_start = ioremap(readl(smbios_table + ST_ADDRESS), 794 smbios_start = ioremap(readl(smbios_table + ST_ADDRESS),
795 readw(smbios_table + ST_LENGTH)); 795 readw(smbios_table + ST_LENGTH));
796 if (!smbios_start) { 796 if (!smbios_start) {
797 err ("Could not ioremap memory region taken from SMBIOS values\n"); 797 err("Could not ioremap memory region taken from SMBIOS values\n");
798 retval = -EIO; 798 retval = -EIO;
799 goto error_smbios_start; 799 goto error_smbios_start;
800 } 800 }
@@ -1181,7 +1181,7 @@ static int cpqhpc_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
1181 * Finish setting up the hot plug ctrl device 1181 * Finish setting up the hot plug ctrl device
1182 */ 1182 */
1183 ctrl->slot_device_offset = readb(ctrl->hpc_reg + SLOT_MASK) >> 4; 1183 ctrl->slot_device_offset = readb(ctrl->hpc_reg + SLOT_MASK) >> 4;
1184 dbg("NumSlots %d \n", ctrl->slot_device_offset); 1184 dbg("NumSlots %d\n", ctrl->slot_device_offset);
1185 1185
1186 ctrl->next_event = 0; 1186 ctrl->next_event = 0;
1187 1187
@@ -1198,7 +1198,7 @@ static int cpqhpc_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
1198 writel(0xFFFFFFFFL, ctrl->hpc_reg + INT_MASK); 1198 writel(0xFFFFFFFFL, ctrl->hpc_reg + INT_MASK);
1199 1199
1200 /* set up the interrupt */ 1200 /* set up the interrupt */
1201 dbg("HPC interrupt = %d \n", ctrl->interrupt); 1201 dbg("HPC interrupt = %d\n", ctrl->interrupt);
1202 if (request_irq(ctrl->interrupt, cpqhp_ctrl_intr, 1202 if (request_irq(ctrl->interrupt, cpqhp_ctrl_intr,
1203 IRQF_SHARED, MY_NAME, ctrl)) { 1203 IRQF_SHARED, MY_NAME, ctrl)) {
1204 err("Can't get irq %d for the hotplug pci controller\n", 1204 err("Can't get irq %d for the hotplug pci controller\n",
@@ -1321,7 +1321,7 @@ static void __exit unload_cpqphpd(void)
1321 while (ctrl) { 1321 while (ctrl) {
1322 if (ctrl->hpc_reg) { 1322 if (ctrl->hpc_reg) {
1323 u16 misc; 1323 u16 misc;
1324 rc = read_slot_enable (ctrl); 1324 rc = read_slot_enable(ctrl);
1325 1325
1326 writeb(0, ctrl->hpc_reg + SLOT_SERR); 1326 writeb(0, ctrl->hpc_reg + SLOT_SERR);
1327 writel(0xFFFFFFC0L | ~rc, ctrl->hpc_reg + INT_MASK); 1327 writel(0xFFFFFFC0L | ~rc, ctrl->hpc_reg + INT_MASK);
@@ -1361,7 +1361,7 @@ static void __exit unload_cpqphpd(void)
1361 kfree(tres); 1361 kfree(tres);
1362 } 1362 }
1363 1363
1364 kfree (ctrl->pci_bus); 1364 kfree(ctrl->pci_bus);
1365 1365
1366 tctrl = ctrl; 1366 tctrl = ctrl;
1367 ctrl = ctrl->next; 1367 ctrl = ctrl->next;
@@ -1446,7 +1446,7 @@ static int __init cpqhpc_init(void)
1446 1446
1447 cpqhp_debug = debug; 1447 cpqhp_debug = debug;
1448 1448
1449 info (DRIVER_DESC " version: " DRIVER_VERSION "\n"); 1449 info(DRIVER_DESC " version: " DRIVER_VERSION "\n");
1450 cpqhp_initialize_debugfs(); 1450 cpqhp_initialize_debugfs();
1451 result = pci_register_driver(&cpqhpc_driver); 1451 result = pci_register_driver(&cpqhpc_driver);
1452 dbg("pci_register_driver = %d\n", result); 1452 dbg("pci_register_driver = %d\n", result);
diff --git a/drivers/pci/hotplug/cpqphp_ctrl.c b/drivers/pci/hotplug/cpqphp_ctrl.c
index c5cbefee5236..a55653b54eed 100644
--- a/drivers/pci/hotplug/cpqphp_ctrl.c
+++ b/drivers/pci/hotplug/cpqphp_ctrl.c
@@ -155,7 +155,7 @@ static u8 handle_presence_change(u16 change, struct controller *ctrl)
155 * Presence Change 155 * Presence Change
156 */ 156 */
157 dbg("cpqsbd: Presence/Notify input change.\n"); 157 dbg("cpqsbd: Presence/Notify input change.\n");
158 dbg(" Changed bits are 0x%4.4x\n", change ); 158 dbg(" Changed bits are 0x%4.4x\n", change);
159 159
160 for (hp_slot = 0; hp_slot < 6; hp_slot++) { 160 for (hp_slot = 0; hp_slot < 6; hp_slot++) {
161 if (change & (0x0101 << hp_slot)) { 161 if (change & (0x0101 << hp_slot)) {
@@ -276,9 +276,9 @@ static u8 handle_power_fault(u8 change, struct controller *ctrl)
276 taskInfo->event_type = INT_POWER_FAULT; 276 taskInfo->event_type = INT_POWER_FAULT;
277 277
278 if (ctrl->rev < 4) { 278 if (ctrl->rev < 4) {
279 amber_LED_on (ctrl, hp_slot); 279 amber_LED_on(ctrl, hp_slot);
280 green_LED_off (ctrl, hp_slot); 280 green_LED_off(ctrl, hp_slot);
281 set_SOGO (ctrl); 281 set_SOGO(ctrl);
282 282
283 /* this is a fatal condition, we want 283 /* this is a fatal condition, we want
284 * to crash the machine to protect from 284 * to crash the machine to protect from
@@ -438,7 +438,7 @@ static struct pci_resource *do_pre_bridge_resource_split(struct pci_resource **h
438 438
439 node = *head; 439 node = *head;
440 440
441 if (node->length & (alignment -1)) { 441 if (node->length & (alignment - 1)) {
442 /* this one isn't an aligned length, so we'll make a new entry 442 /* this one isn't an aligned length, so we'll make a new entry
443 * and split it up. 443 * and split it up.
444 */ 444 */
@@ -835,13 +835,13 @@ int cpqhp_resource_sort_and_combine(struct pci_resource **head)
835 if (!(*head)) 835 if (!(*head))
836 return 1; 836 return 1;
837 837
838 dbg("*head->next = %p\n",(*head)->next); 838 dbg("*head->next = %p\n", (*head)->next);
839 839
840 if (!(*head)->next) 840 if (!(*head)->next)
841 return 0; /* only one item on the list, already sorted! */ 841 return 0; /* only one item on the list, already sorted! */
842 842
843 dbg("*head->base = 0x%x\n",(*head)->base); 843 dbg("*head->base = 0x%x\n", (*head)->base);
844 dbg("*head->next->base = 0x%x\n",(*head)->next->base); 844 dbg("*head->next->base = 0x%x\n", (*head)->next->base);
845 while (out_of_order) { 845 while (out_of_order) {
846 out_of_order = 0; 846 out_of_order = 0;
847 847
@@ -917,7 +917,7 @@ irqreturn_t cpqhp_ctrl_intr(int IRQ, void *data)
917 /* Read to clear posted writes */ 917 /* Read to clear posted writes */
918 misc = readw(ctrl->hpc_reg + MISC); 918 misc = readw(ctrl->hpc_reg + MISC);
919 919
920 dbg ("%s - waking up\n", __func__); 920 dbg("%s - waking up\n", __func__);
921 wake_up_interruptible(&ctrl->queue); 921 wake_up_interruptible(&ctrl->queue);
922 } 922 }
923 923
@@ -1285,18 +1285,18 @@ static u32 board_replaced(struct pci_func *func, struct controller *ctrl)
1285 /* 1285 /*
1286 * The board is already on 1286 * The board is already on
1287 */ 1287 */
1288 else if (is_slot_enabled (ctrl, hp_slot)) 1288 else if (is_slot_enabled(ctrl, hp_slot))
1289 rc = CARD_FUNCTIONING; 1289 rc = CARD_FUNCTIONING;
1290 else { 1290 else {
1291 mutex_lock(&ctrl->crit_sect); 1291 mutex_lock(&ctrl->crit_sect);
1292 1292
1293 /* turn on board without attaching to the bus */ 1293 /* turn on board without attaching to the bus */
1294 enable_slot_power (ctrl, hp_slot); 1294 enable_slot_power(ctrl, hp_slot);
1295 1295
1296 set_SOGO(ctrl); 1296 set_SOGO(ctrl);
1297 1297
1298 /* Wait for SOBS to be unset */ 1298 /* Wait for SOBS to be unset */
1299 wait_for_ctrl_irq (ctrl); 1299 wait_for_ctrl_irq(ctrl);
1300 1300
1301 /* Change bits in slot power register to force another shift out 1301 /* Change bits in slot power register to force another shift out
1302 * NOTE: this is to work around the timer bug */ 1302 * NOTE: this is to work around the timer bug */
@@ -1307,7 +1307,7 @@ static u32 board_replaced(struct pci_func *func, struct controller *ctrl)
1307 set_SOGO(ctrl); 1307 set_SOGO(ctrl);
1308 1308
1309 /* Wait for SOBS to be unset */ 1309 /* Wait for SOBS to be unset */
1310 wait_for_ctrl_irq (ctrl); 1310 wait_for_ctrl_irq(ctrl);
1311 1311
1312 adapter_speed = get_adapter_speed(ctrl, hp_slot); 1312 adapter_speed = get_adapter_speed(ctrl, hp_slot);
1313 if (bus->cur_bus_speed != adapter_speed) 1313 if (bus->cur_bus_speed != adapter_speed)
@@ -1315,12 +1315,12 @@ static u32 board_replaced(struct pci_func *func, struct controller *ctrl)
1315 rc = WRONG_BUS_FREQUENCY; 1315 rc = WRONG_BUS_FREQUENCY;
1316 1316
1317 /* turn off board without attaching to the bus */ 1317 /* turn off board without attaching to the bus */
1318 disable_slot_power (ctrl, hp_slot); 1318 disable_slot_power(ctrl, hp_slot);
1319 1319
1320 set_SOGO(ctrl); 1320 set_SOGO(ctrl);
1321 1321
1322 /* Wait for SOBS to be unset */ 1322 /* Wait for SOBS to be unset */
1323 wait_for_ctrl_irq (ctrl); 1323 wait_for_ctrl_irq(ctrl);
1324 1324
1325 mutex_unlock(&ctrl->crit_sect); 1325 mutex_unlock(&ctrl->crit_sect);
1326 1326
@@ -1329,15 +1329,15 @@ static u32 board_replaced(struct pci_func *func, struct controller *ctrl)
1329 1329
1330 mutex_lock(&ctrl->crit_sect); 1330 mutex_lock(&ctrl->crit_sect);
1331 1331
1332 slot_enable (ctrl, hp_slot); 1332 slot_enable(ctrl, hp_slot);
1333 green_LED_blink (ctrl, hp_slot); 1333 green_LED_blink(ctrl, hp_slot);
1334 1334
1335 amber_LED_off (ctrl, hp_slot); 1335 amber_LED_off(ctrl, hp_slot);
1336 1336
1337 set_SOGO(ctrl); 1337 set_SOGO(ctrl);
1338 1338
1339 /* Wait for SOBS to be unset */ 1339 /* Wait for SOBS to be unset */
1340 wait_for_ctrl_irq (ctrl); 1340 wait_for_ctrl_irq(ctrl);
1341 1341
1342 mutex_unlock(&ctrl->crit_sect); 1342 mutex_unlock(&ctrl->crit_sect);
1343 1343
@@ -1366,14 +1366,14 @@ static u32 board_replaced(struct pci_func *func, struct controller *ctrl)
1366 1366
1367 mutex_lock(&ctrl->crit_sect); 1367 mutex_lock(&ctrl->crit_sect);
1368 1368
1369 amber_LED_on (ctrl, hp_slot); 1369 amber_LED_on(ctrl, hp_slot);
1370 green_LED_off (ctrl, hp_slot); 1370 green_LED_off(ctrl, hp_slot);
1371 slot_disable (ctrl, hp_slot); 1371 slot_disable(ctrl, hp_slot);
1372 1372
1373 set_SOGO(ctrl); 1373 set_SOGO(ctrl);
1374 1374
1375 /* Wait for SOBS to be unset */ 1375 /* Wait for SOBS to be unset */
1376 wait_for_ctrl_irq (ctrl); 1376 wait_for_ctrl_irq(ctrl);
1377 1377
1378 mutex_unlock(&ctrl->crit_sect); 1378 mutex_unlock(&ctrl->crit_sect);
1379 1379
@@ -1392,14 +1392,14 @@ static u32 board_replaced(struct pci_func *func, struct controller *ctrl)
1392 1392
1393 mutex_lock(&ctrl->crit_sect); 1393 mutex_lock(&ctrl->crit_sect);
1394 1394
1395 amber_LED_on (ctrl, hp_slot); 1395 amber_LED_on(ctrl, hp_slot);
1396 green_LED_off (ctrl, hp_slot); 1396 green_LED_off(ctrl, hp_slot);
1397 slot_disable (ctrl, hp_slot); 1397 slot_disable(ctrl, hp_slot);
1398 1398
1399 set_SOGO(ctrl); 1399 set_SOGO(ctrl);
1400 1400
1401 /* Wait for SOBS to be unset */ 1401 /* Wait for SOBS to be unset */
1402 wait_for_ctrl_irq (ctrl); 1402 wait_for_ctrl_irq(ctrl);
1403 1403
1404 mutex_unlock(&ctrl->crit_sect); 1404 mutex_unlock(&ctrl->crit_sect);
1405 } 1405 }
@@ -1443,7 +1443,7 @@ static u32 board_added(struct pci_func *func, struct controller *ctrl)
1443 set_SOGO(ctrl); 1443 set_SOGO(ctrl);
1444 1444
1445 /* Wait for SOBS to be unset */ 1445 /* Wait for SOBS to be unset */
1446 wait_for_ctrl_irq (ctrl); 1446 wait_for_ctrl_irq(ctrl);
1447 1447
1448 /* Change bits in slot power register to force another shift out 1448 /* Change bits in slot power register to force another shift out
1449 * NOTE: this is to work around the timer bug 1449 * NOTE: this is to work around the timer bug
@@ -1455,7 +1455,7 @@ static u32 board_added(struct pci_func *func, struct controller *ctrl)
1455 set_SOGO(ctrl); 1455 set_SOGO(ctrl);
1456 1456
1457 /* Wait for SOBS to be unset */ 1457 /* Wait for SOBS to be unset */
1458 wait_for_ctrl_irq (ctrl); 1458 wait_for_ctrl_irq(ctrl);
1459 1459
1460 adapter_speed = get_adapter_speed(ctrl, hp_slot); 1460 adapter_speed = get_adapter_speed(ctrl, hp_slot);
1461 if (bus->cur_bus_speed != adapter_speed) 1461 if (bus->cur_bus_speed != adapter_speed)
@@ -1463,7 +1463,7 @@ static u32 board_added(struct pci_func *func, struct controller *ctrl)
1463 rc = WRONG_BUS_FREQUENCY; 1463 rc = WRONG_BUS_FREQUENCY;
1464 1464
1465 /* turn off board without attaching to the bus */ 1465 /* turn off board without attaching to the bus */
1466 disable_slot_power (ctrl, hp_slot); 1466 disable_slot_power(ctrl, hp_slot);
1467 1467
1468 set_SOGO(ctrl); 1468 set_SOGO(ctrl);
1469 1469
@@ -1484,20 +1484,20 @@ static u32 board_added(struct pci_func *func, struct controller *ctrl)
1484 dbg("%s: after down\n", __func__); 1484 dbg("%s: after down\n", __func__);
1485 1485
1486 dbg("%s: before slot_enable\n", __func__); 1486 dbg("%s: before slot_enable\n", __func__);
1487 slot_enable (ctrl, hp_slot); 1487 slot_enable(ctrl, hp_slot);
1488 1488
1489 dbg("%s: before green_LED_blink\n", __func__); 1489 dbg("%s: before green_LED_blink\n", __func__);
1490 green_LED_blink (ctrl, hp_slot); 1490 green_LED_blink(ctrl, hp_slot);
1491 1491
1492 dbg("%s: before amber_LED_blink\n", __func__); 1492 dbg("%s: before amber_LED_blink\n", __func__);
1493 amber_LED_off (ctrl, hp_slot); 1493 amber_LED_off(ctrl, hp_slot);
1494 1494
1495 dbg("%s: before set_SOGO\n", __func__); 1495 dbg("%s: before set_SOGO\n", __func__);
1496 set_SOGO(ctrl); 1496 set_SOGO(ctrl);
1497 1497
1498 /* Wait for SOBS to be unset */ 1498 /* Wait for SOBS to be unset */
1499 dbg("%s: before wait_for_ctrl_irq\n", __func__); 1499 dbg("%s: before wait_for_ctrl_irq\n", __func__);
1500 wait_for_ctrl_irq (ctrl); 1500 wait_for_ctrl_irq(ctrl);
1501 dbg("%s: after wait_for_ctrl_irq\n", __func__); 1501 dbg("%s: after wait_for_ctrl_irq\n", __func__);
1502 1502
1503 dbg("%s: before up\n", __func__); 1503 dbg("%s: before up\n", __func__);
@@ -1520,7 +1520,7 @@ static u32 board_added(struct pci_func *func, struct controller *ctrl)
1520 } else { 1520 } else {
1521 /* Get vendor/device ID u32 */ 1521 /* Get vendor/device ID u32 */
1522 ctrl->pci_bus->number = func->bus; 1522 ctrl->pci_bus->number = func->bus;
1523 rc = pci_bus_read_config_dword (ctrl->pci_bus, PCI_DEVFN(func->device, func->function), PCI_VENDOR_ID, &temp_register); 1523 rc = pci_bus_read_config_dword(ctrl->pci_bus, PCI_DEVFN(func->device, func->function), PCI_VENDOR_ID, &temp_register);
1524 dbg("%s: pci_read_config_dword returns %d\n", __func__, rc); 1524 dbg("%s: pci_read_config_dword returns %d\n", __func__, rc);
1525 dbg("%s: temp_register is %x\n", __func__, temp_register); 1525 dbg("%s: temp_register is %x\n", __func__, temp_register);
1526 1526
@@ -1557,14 +1557,14 @@ static u32 board_added(struct pci_func *func, struct controller *ctrl)
1557 if (rc) { 1557 if (rc) {
1558 mutex_lock(&ctrl->crit_sect); 1558 mutex_lock(&ctrl->crit_sect);
1559 1559
1560 amber_LED_on (ctrl, hp_slot); 1560 amber_LED_on(ctrl, hp_slot);
1561 green_LED_off (ctrl, hp_slot); 1561 green_LED_off(ctrl, hp_slot);
1562 slot_disable (ctrl, hp_slot); 1562 slot_disable(ctrl, hp_slot);
1563 1563
1564 set_SOGO(ctrl); 1564 set_SOGO(ctrl);
1565 1565
1566 /* Wait for SOBS to be unset */ 1566 /* Wait for SOBS to be unset */
1567 wait_for_ctrl_irq (ctrl); 1567 wait_for_ctrl_irq(ctrl);
1568 1568
1569 mutex_unlock(&ctrl->crit_sect); 1569 mutex_unlock(&ctrl->crit_sect);
1570 return rc; 1570 return rc;
@@ -1589,25 +1589,25 @@ static u32 board_added(struct pci_func *func, struct controller *ctrl)
1589 1589
1590 mutex_lock(&ctrl->crit_sect); 1590 mutex_lock(&ctrl->crit_sect);
1591 1591
1592 green_LED_on (ctrl, hp_slot); 1592 green_LED_on(ctrl, hp_slot);
1593 1593
1594 set_SOGO(ctrl); 1594 set_SOGO(ctrl);
1595 1595
1596 /* Wait for SOBS to be unset */ 1596 /* Wait for SOBS to be unset */
1597 wait_for_ctrl_irq (ctrl); 1597 wait_for_ctrl_irq(ctrl);
1598 1598
1599 mutex_unlock(&ctrl->crit_sect); 1599 mutex_unlock(&ctrl->crit_sect);
1600 } else { 1600 } else {
1601 mutex_lock(&ctrl->crit_sect); 1601 mutex_lock(&ctrl->crit_sect);
1602 1602
1603 amber_LED_on (ctrl, hp_slot); 1603 amber_LED_on(ctrl, hp_slot);
1604 green_LED_off (ctrl, hp_slot); 1604 green_LED_off(ctrl, hp_slot);
1605 slot_disable (ctrl, hp_slot); 1605 slot_disable(ctrl, hp_slot);
1606 1606
1607 set_SOGO(ctrl); 1607 set_SOGO(ctrl);
1608 1608
1609 /* Wait for SOBS to be unset */ 1609 /* Wait for SOBS to be unset */
1610 wait_for_ctrl_irq (ctrl); 1610 wait_for_ctrl_irq(ctrl);
1611 1611
1612 mutex_unlock(&ctrl->crit_sect); 1612 mutex_unlock(&ctrl->crit_sect);
1613 1613
@@ -1672,8 +1672,8 @@ static u32 remove_board(struct pci_func *func, u32 replace_flag, struct controll
1672 1672
1673 mutex_lock(&ctrl->crit_sect); 1673 mutex_lock(&ctrl->crit_sect);
1674 1674
1675 green_LED_off (ctrl, hp_slot); 1675 green_LED_off(ctrl, hp_slot);
1676 slot_disable (ctrl, hp_slot); 1676 slot_disable(ctrl, hp_slot);
1677 1677
1678 set_SOGO(ctrl); 1678 set_SOGO(ctrl);
1679 1679
@@ -1683,7 +1683,7 @@ static u32 remove_board(struct pci_func *func, u32 replace_flag, struct controll
1683 writeb(temp_byte, ctrl->hpc_reg + SLOT_SERR); 1683 writeb(temp_byte, ctrl->hpc_reg + SLOT_SERR);
1684 1684
1685 /* Wait for SOBS to be unset */ 1685 /* Wait for SOBS to be unset */
1686 wait_for_ctrl_irq (ctrl); 1686 wait_for_ctrl_irq(ctrl);
1687 1687
1688 mutex_unlock(&ctrl->crit_sect); 1688 mutex_unlock(&ctrl->crit_sect);
1689 1689
@@ -1755,7 +1755,7 @@ static int event_thread(void *data)
1755 if (pushbutton_pending) 1755 if (pushbutton_pending)
1756 cpqhp_pushbutton_thread(pushbutton_pending); 1756 cpqhp_pushbutton_thread(pushbutton_pending);
1757 else 1757 else
1758 for (ctrl = cpqhp_ctrl_list; ctrl; ctrl=ctrl->next) 1758 for (ctrl = cpqhp_ctrl_list; ctrl; ctrl = ctrl->next)
1759 interrupt_event_handler(ctrl); 1759 interrupt_event_handler(ctrl);
1760 } 1760 }
1761 dbg("event_thread signals exit\n"); 1761 dbg("event_thread signals exit\n");
@@ -1766,7 +1766,7 @@ int cpqhp_event_start_thread(void)
1766{ 1766{
1767 cpqhp_event_thread = kthread_run(event_thread, NULL, "phpd_event"); 1767 cpqhp_event_thread = kthread_run(event_thread, NULL, "phpd_event");
1768 if (IS_ERR(cpqhp_event_thread)) { 1768 if (IS_ERR(cpqhp_event_thread)) {
1769 err ("Can't start up our event thread\n"); 1769 err("Can't start up our event thread\n");
1770 return PTR_ERR(cpqhp_event_thread); 1770 return PTR_ERR(cpqhp_event_thread);
1771 } 1771 }
1772 1772
@@ -1794,7 +1794,7 @@ static int update_slot_info(struct controller *ctrl, struct slot *slot)
1794 info->latch_status = cpq_get_latch_status(ctrl, slot); 1794 info->latch_status = cpq_get_latch_status(ctrl, slot);
1795 info->adapter_status = get_presence_status(ctrl, slot); 1795 info->adapter_status = get_presence_status(ctrl, slot);
1796 result = pci_hp_change_slot_info(slot->hotplug_slot, info); 1796 result = pci_hp_change_slot_info(slot->hotplug_slot, info);
1797 kfree (info); 1797 kfree(info);
1798 return result; 1798 return result;
1799} 1799}
1800 1800
@@ -1837,23 +1837,23 @@ static void interrupt_event_handler(struct controller *ctrl)
1837 if (p_slot->state == BLINKINGOFF_STATE) { 1837 if (p_slot->state == BLINKINGOFF_STATE) {
1838 /* slot is on */ 1838 /* slot is on */
1839 dbg("turn on green LED\n"); 1839 dbg("turn on green LED\n");
1840 green_LED_on (ctrl, hp_slot); 1840 green_LED_on(ctrl, hp_slot);
1841 } else if (p_slot->state == BLINKINGON_STATE) { 1841 } else if (p_slot->state == BLINKINGON_STATE) {
1842 /* slot is off */ 1842 /* slot is off */
1843 dbg("turn off green LED\n"); 1843 dbg("turn off green LED\n");
1844 green_LED_off (ctrl, hp_slot); 1844 green_LED_off(ctrl, hp_slot);
1845 } 1845 }
1846 1846
1847 info(msg_button_cancel, p_slot->number); 1847 info(msg_button_cancel, p_slot->number);
1848 1848
1849 p_slot->state = STATIC_STATE; 1849 p_slot->state = STATIC_STATE;
1850 1850
1851 amber_LED_off (ctrl, hp_slot); 1851 amber_LED_off(ctrl, hp_slot);
1852 1852
1853 set_SOGO(ctrl); 1853 set_SOGO(ctrl);
1854 1854
1855 /* Wait for SOBS to be unset */ 1855 /* Wait for SOBS to be unset */
1856 wait_for_ctrl_irq (ctrl); 1856 wait_for_ctrl_irq(ctrl);
1857 1857
1858 mutex_unlock(&ctrl->crit_sect); 1858 mutex_unlock(&ctrl->crit_sect);
1859 } 1859 }
@@ -1861,7 +1861,7 @@ static void interrupt_event_handler(struct controller *ctrl)
1861 else if (ctrl->event_queue[loop].event_type == INT_BUTTON_RELEASE) { 1861 else if (ctrl->event_queue[loop].event_type == INT_BUTTON_RELEASE) {
1862 dbg("button release\n"); 1862 dbg("button release\n");
1863 1863
1864 if (is_slot_enabled (ctrl, hp_slot)) { 1864 if (is_slot_enabled(ctrl, hp_slot)) {
1865 dbg("slot is on\n"); 1865 dbg("slot is on\n");
1866 p_slot->state = BLINKINGOFF_STATE; 1866 p_slot->state = BLINKINGOFF_STATE;
1867 info(msg_button_off, p_slot->number); 1867 info(msg_button_off, p_slot->number);
@@ -1874,13 +1874,13 @@ static void interrupt_event_handler(struct controller *ctrl)
1874 1874
1875 dbg("blink green LED and turn off amber\n"); 1875 dbg("blink green LED and turn off amber\n");
1876 1876
1877 amber_LED_off (ctrl, hp_slot); 1877 amber_LED_off(ctrl, hp_slot);
1878 green_LED_blink (ctrl, hp_slot); 1878 green_LED_blink(ctrl, hp_slot);
1879 1879
1880 set_SOGO(ctrl); 1880 set_SOGO(ctrl);
1881 1881
1882 /* Wait for SOBS to be unset */ 1882 /* Wait for SOBS to be unset */
1883 wait_for_ctrl_irq (ctrl); 1883 wait_for_ctrl_irq(ctrl);
1884 1884
1885 mutex_unlock(&ctrl->crit_sect); 1885 mutex_unlock(&ctrl->crit_sect);
1886 init_timer(&p_slot->task_event); 1886 init_timer(&p_slot->task_event);
@@ -1940,7 +1940,7 @@ void cpqhp_pushbutton_thread(unsigned long slot)
1940 dbg("In power_down_board, func = %p, ctrl = %p\n", func, ctrl); 1940 dbg("In power_down_board, func = %p, ctrl = %p\n", func, ctrl);
1941 if (!func) { 1941 if (!func) {
1942 dbg("Error! func NULL in %s\n", __func__); 1942 dbg("Error! func NULL in %s\n", __func__);
1943 return ; 1943 return;
1944 } 1944 }
1945 1945
1946 if (cpqhp_process_SS(ctrl, func) != 0) { 1946 if (cpqhp_process_SS(ctrl, func) != 0) {
@@ -1962,7 +1962,7 @@ void cpqhp_pushbutton_thread(unsigned long slot)
1962 dbg("In add_board, func = %p, ctrl = %p\n", func, ctrl); 1962 dbg("In add_board, func = %p, ctrl = %p\n", func, ctrl);
1963 if (!func) { 1963 if (!func) {
1964 dbg("Error! func NULL in %s\n", __func__); 1964 dbg("Error! func NULL in %s\n", __func__);
1965 return ; 1965 return;
1966 } 1966 }
1967 1967
1968 if (ctrl != NULL) { 1968 if (ctrl != NULL) {
@@ -1973,7 +1973,7 @@ void cpqhp_pushbutton_thread(unsigned long slot)
1973 set_SOGO(ctrl); 1973 set_SOGO(ctrl);
1974 1974
1975 /* Wait for SOBS to be unset */ 1975 /* Wait for SOBS to be unset */
1976 wait_for_ctrl_irq (ctrl); 1976 wait_for_ctrl_irq(ctrl);
1977 } 1977 }
1978 } 1978 }
1979 1979
@@ -2086,7 +2086,7 @@ int cpqhp_process_SS(struct controller *ctrl, struct pci_func *func)
2086 unsigned int devfn; 2086 unsigned int devfn;
2087 struct slot *p_slot; 2087 struct slot *p_slot;
2088 struct pci_bus *pci_bus = ctrl->pci_bus; 2088 struct pci_bus *pci_bus = ctrl->pci_bus;
2089 int physical_slot=0; 2089 int physical_slot = 0;
2090 2090
2091 device = func->device; 2091 device = func->device;
2092 func = cpqhp_slot_find(ctrl->bus, device, index++); 2092 func = cpqhp_slot_find(ctrl->bus, device, index++);
@@ -2100,7 +2100,7 @@ int cpqhp_process_SS(struct controller *ctrl, struct pci_func *func)
2100 devfn = PCI_DEVFN(func->device, func->function); 2100 devfn = PCI_DEVFN(func->device, func->function);
2101 2101
2102 /* Check the Class Code */ 2102 /* Check the Class Code */
2103 rc = pci_bus_read_config_byte (pci_bus, devfn, 0x0B, &class_code); 2103 rc = pci_bus_read_config_byte(pci_bus, devfn, 0x0B, &class_code);
2104 if (rc) 2104 if (rc)
2105 return rc; 2105 return rc;
2106 2106
@@ -2109,13 +2109,13 @@ int cpqhp_process_SS(struct controller *ctrl, struct pci_func *func)
2109 rc = REMOVE_NOT_SUPPORTED; 2109 rc = REMOVE_NOT_SUPPORTED;
2110 } else { 2110 } else {
2111 /* See if it's a bridge */ 2111 /* See if it's a bridge */
2112 rc = pci_bus_read_config_byte (pci_bus, devfn, PCI_HEADER_TYPE, &header_type); 2112 rc = pci_bus_read_config_byte(pci_bus, devfn, PCI_HEADER_TYPE, &header_type);
2113 if (rc) 2113 if (rc)
2114 return rc; 2114 return rc;
2115 2115
2116 /* If it's a bridge, check the VGA Enable bit */ 2116 /* If it's a bridge, check the VGA Enable bit */
2117 if ((header_type & 0x7F) == PCI_HEADER_TYPE_BRIDGE) { 2117 if ((header_type & 0x7F) == PCI_HEADER_TYPE_BRIDGE) {
2118 rc = pci_bus_read_config_byte (pci_bus, devfn, PCI_BRIDGE_CONTROL, &BCR); 2118 rc = pci_bus_read_config_byte(pci_bus, devfn, PCI_BRIDGE_CONTROL, &BCR);
2119 if (rc) 2119 if (rc)
2120 return rc; 2120 return rc;
2121 2121
@@ -2217,7 +2217,7 @@ int cpqhp_hardware_test(struct controller *ctrl, int test_num)
2217 set_SOGO(ctrl); 2217 set_SOGO(ctrl);
2218 2218
2219 /* Wait for SOGO interrupt */ 2219 /* Wait for SOGO interrupt */
2220 wait_for_ctrl_irq (ctrl); 2220 wait_for_ctrl_irq(ctrl);
2221 2221
2222 /* Get ready for next iteration */ 2222 /* Get ready for next iteration */
2223 long_delay((3*HZ)/10); 2223 long_delay((3*HZ)/10);
@@ -2227,7 +2227,7 @@ int cpqhp_hardware_test(struct controller *ctrl, int test_num)
2227 set_SOGO(ctrl); 2227 set_SOGO(ctrl);
2228 2228
2229 /* Wait for SOGO interrupt */ 2229 /* Wait for SOGO interrupt */
2230 wait_for_ctrl_irq (ctrl); 2230 wait_for_ctrl_irq(ctrl);
2231 2231
2232 /* Get ready for next iteration */ 2232 /* Get ready for next iteration */
2233 long_delay((3*HZ)/10); 2233 long_delay((3*HZ)/10);
@@ -2243,7 +2243,7 @@ int cpqhp_hardware_test(struct controller *ctrl, int test_num)
2243 set_SOGO(ctrl); 2243 set_SOGO(ctrl);
2244 2244
2245 /* Wait for SOBS to be unset */ 2245 /* Wait for SOBS to be unset */
2246 wait_for_ctrl_irq (ctrl); 2246 wait_for_ctrl_irq(ctrl);
2247 break; 2247 break;
2248 case 2: 2248 case 2:
2249 /* Do other stuff here! */ 2249 /* Do other stuff here! */
@@ -2279,7 +2279,7 @@ static u32 configure_new_device(struct controller *ctrl, struct pci_func *func
2279 dbg("%s\n", __func__); 2279 dbg("%s\n", __func__);
2280 /* Check for Multi-function device */ 2280 /* Check for Multi-function device */
2281 ctrl->pci_bus->number = func->bus; 2281 ctrl->pci_bus->number = func->bus;
2282 rc = pci_bus_read_config_byte (ctrl->pci_bus, PCI_DEVFN(func->device, func->function), 0x0E, &temp_byte); 2282 rc = pci_bus_read_config_byte(ctrl->pci_bus, PCI_DEVFN(func->device, func->function), 0x0E, &temp_byte);
2283 if (rc) { 2283 if (rc) {
2284 dbg("%s: rc = %d\n", __func__, rc); 2284 dbg("%s: rc = %d\n", __func__, rc);
2285 return rc; 2285 return rc;
@@ -2296,7 +2296,7 @@ static u32 configure_new_device(struct controller *ctrl, struct pci_func *func
2296 rc = configure_new_function(ctrl, new_slot, behind_bridge, resources); 2296 rc = configure_new_function(ctrl, new_slot, behind_bridge, resources);
2297 2297
2298 if (rc) { 2298 if (rc) {
2299 dbg("configure_new_function failed %d\n",rc); 2299 dbg("configure_new_function failed %d\n", rc);
2300 index = 0; 2300 index = 0;
2301 2301
2302 while (new_slot) { 2302 while (new_slot) {
@@ -2317,7 +2317,7 @@ static u32 configure_new_device(struct controller *ctrl, struct pci_func *func
2317 * and creates a board structure */ 2317 * and creates a board structure */
2318 2318
2319 while ((function < max_functions) && (!stop_it)) { 2319 while ((function < max_functions) && (!stop_it)) {
2320 pci_bus_read_config_dword (ctrl->pci_bus, PCI_DEVFN(func->device, function), 0x00, &ID); 2320 pci_bus_read_config_dword(ctrl->pci_bus, PCI_DEVFN(func->device, function), 0x00, &ID);
2321 2321
2322 if (ID == 0xFFFFFFFF) { 2322 if (ID == 0xFFFFFFFF) {
2323 function++; 2323 function++;
@@ -2543,10 +2543,10 @@ static int configure_new_function(struct controller *ctrl, struct pci_func *func
2543 2543
2544 /* set Pre Mem base and Limit registers */ 2544 /* set Pre Mem base and Limit registers */
2545 temp_word = p_mem_node->base >> 16; 2545 temp_word = p_mem_node->base >> 16;
2546 rc = pci_bus_write_config_word (pci_bus, devfn, PCI_PREF_MEMORY_BASE, temp_word); 2546 rc = pci_bus_write_config_word(pci_bus, devfn, PCI_PREF_MEMORY_BASE, temp_word);
2547 2547
2548 temp_word = (p_mem_node->base + p_mem_node->length - 1) >> 16; 2548 temp_word = (p_mem_node->base + p_mem_node->length - 1) >> 16;
2549 rc = pci_bus_write_config_word (pci_bus, devfn, PCI_PREF_MEMORY_LIMIT, temp_word); 2549 rc = pci_bus_write_config_word(pci_bus, devfn, PCI_PREF_MEMORY_LIMIT, temp_word);
2550 2550
2551 /* Adjust this to compensate for extra adjustment in first loop 2551 /* Adjust this to compensate for extra adjustment in first loop
2552 */ 2552 */
@@ -2560,7 +2560,7 @@ static int configure_new_function(struct controller *ctrl, struct pci_func *func
2560 2560
2561 ID = 0xFFFFFFFF; 2561 ID = 0xFFFFFFFF;
2562 pci_bus->number = hold_bus_node->base; 2562 pci_bus->number = hold_bus_node->base;
2563 pci_bus_read_config_dword (pci_bus, PCI_DEVFN(device, 0), 0x00, &ID); 2563 pci_bus_read_config_dword(pci_bus, PCI_DEVFN(device, 0), 0x00, &ID);
2564 pci_bus->number = func->bus; 2564 pci_bus->number = func->bus;
2565 2565
2566 if (ID != 0xFFFFFFFF) { /* device present */ 2566 if (ID != 0xFFFFFFFF) { /* device present */
@@ -2579,7 +2579,7 @@ static int configure_new_function(struct controller *ctrl, struct pci_func *func
2579 new_slot->status = 0; 2579 new_slot->status = 0;
2580 2580
2581 rc = configure_new_device(ctrl, new_slot, 1, &temp_resources); 2581 rc = configure_new_device(ctrl, new_slot, 1, &temp_resources);
2582 dbg("configure_new_device rc=0x%x\n",rc); 2582 dbg("configure_new_device rc=0x%x\n", rc);
2583 } /* End of IF (device in slot?) */ 2583 } /* End of IF (device in slot?) */
2584 } /* End of FOR loop */ 2584 } /* End of FOR loop */
2585 2585
@@ -2615,7 +2615,7 @@ static int configure_new_function(struct controller *ctrl, struct pci_func *func
2615 temp_byte = temp_resources.bus_head->base - 1; 2615 temp_byte = temp_resources.bus_head->base - 1;
2616 2616
2617 /* set subordinate bus */ 2617 /* set subordinate bus */
2618 rc = pci_bus_write_config_byte (pci_bus, devfn, PCI_SUBORDINATE_BUS, temp_byte); 2618 rc = pci_bus_write_config_byte(pci_bus, devfn, PCI_SUBORDINATE_BUS, temp_byte);
2619 2619
2620 if (temp_resources.bus_head->length == 0) { 2620 if (temp_resources.bus_head->length == 0) {
2621 kfree(temp_resources.bus_head); 2621 kfree(temp_resources.bus_head);
@@ -2636,7 +2636,7 @@ static int configure_new_function(struct controller *ctrl, struct pci_func *func
2636 hold_IO_node->base = io_node->base + io_node->length; 2636 hold_IO_node->base = io_node->base + io_node->length;
2637 2637
2638 temp_byte = (hold_IO_node->base) >> 8; 2638 temp_byte = (hold_IO_node->base) >> 8;
2639 rc = pci_bus_write_config_word (pci_bus, devfn, PCI_IO_BASE, temp_byte); 2639 rc = pci_bus_write_config_word(pci_bus, devfn, PCI_IO_BASE, temp_byte);
2640 2640
2641 return_resource(&(resources->io_head), io_node); 2641 return_resource(&(resources->io_head), io_node);
2642 } 2642 }
@@ -2655,13 +2655,13 @@ static int configure_new_function(struct controller *ctrl, struct pci_func *func
2655 func->io_head = hold_IO_node; 2655 func->io_head = hold_IO_node;
2656 2656
2657 temp_byte = (io_node->base - 1) >> 8; 2657 temp_byte = (io_node->base - 1) >> 8;
2658 rc = pci_bus_write_config_byte (pci_bus, devfn, PCI_IO_LIMIT, temp_byte); 2658 rc = pci_bus_write_config_byte(pci_bus, devfn, PCI_IO_LIMIT, temp_byte);
2659 2659
2660 return_resource(&(resources->io_head), io_node); 2660 return_resource(&(resources->io_head), io_node);
2661 } else { 2661 } else {
2662 /* it doesn't need any IO */ 2662 /* it doesn't need any IO */
2663 temp_word = 0x0000; 2663 temp_word = 0x0000;
2664 rc = pci_bus_write_config_word (pci_bus, devfn, PCI_IO_LIMIT, temp_word); 2664 rc = pci_bus_write_config_word(pci_bus, devfn, PCI_IO_LIMIT, temp_word);
2665 2665
2666 return_resource(&(resources->io_head), io_node); 2666 return_resource(&(resources->io_head), io_node);
2667 kfree(hold_IO_node); 2667 kfree(hold_IO_node);
@@ -2687,7 +2687,7 @@ static int configure_new_function(struct controller *ctrl, struct pci_func *func
2687 hold_mem_node->base = mem_node->base + mem_node->length; 2687 hold_mem_node->base = mem_node->base + mem_node->length;
2688 2688
2689 temp_word = (hold_mem_node->base) >> 16; 2689 temp_word = (hold_mem_node->base) >> 16;
2690 rc = pci_bus_write_config_word (pci_bus, devfn, PCI_MEMORY_BASE, temp_word); 2690 rc = pci_bus_write_config_word(pci_bus, devfn, PCI_MEMORY_BASE, temp_word);
2691 2691
2692 return_resource(&(resources->mem_head), mem_node); 2692 return_resource(&(resources->mem_head), mem_node);
2693 } 2693 }
@@ -2706,14 +2706,14 @@ static int configure_new_function(struct controller *ctrl, struct pci_func *func
2706 2706
2707 /* configure end address */ 2707 /* configure end address */
2708 temp_word = (mem_node->base - 1) >> 16; 2708 temp_word = (mem_node->base - 1) >> 16;
2709 rc = pci_bus_write_config_word (pci_bus, devfn, PCI_MEMORY_LIMIT, temp_word); 2709 rc = pci_bus_write_config_word(pci_bus, devfn, PCI_MEMORY_LIMIT, temp_word);
2710 2710
2711 /* Return unused resources to the pool */ 2711 /* Return unused resources to the pool */
2712 return_resource(&(resources->mem_head), mem_node); 2712 return_resource(&(resources->mem_head), mem_node);
2713 } else { 2713 } else {
2714 /* it doesn't need any Mem */ 2714 /* it doesn't need any Mem */
2715 temp_word = 0x0000; 2715 temp_word = 0x0000;
2716 rc = pci_bus_write_config_word (pci_bus, devfn, PCI_MEMORY_LIMIT, temp_word); 2716 rc = pci_bus_write_config_word(pci_bus, devfn, PCI_MEMORY_LIMIT, temp_word);
2717 2717
2718 return_resource(&(resources->mem_head), mem_node); 2718 return_resource(&(resources->mem_head), mem_node);
2719 kfree(hold_mem_node); 2719 kfree(hold_mem_node);
@@ -2739,7 +2739,7 @@ static int configure_new_function(struct controller *ctrl, struct pci_func *func
2739 hold_p_mem_node->base = p_mem_node->base + p_mem_node->length; 2739 hold_p_mem_node->base = p_mem_node->base + p_mem_node->length;
2740 2740
2741 temp_word = (hold_p_mem_node->base) >> 16; 2741 temp_word = (hold_p_mem_node->base) >> 16;
2742 rc = pci_bus_write_config_word (pci_bus, devfn, PCI_PREF_MEMORY_BASE, temp_word); 2742 rc = pci_bus_write_config_word(pci_bus, devfn, PCI_PREF_MEMORY_BASE, temp_word);
2743 2743
2744 return_resource(&(resources->p_mem_head), p_mem_node); 2744 return_resource(&(resources->p_mem_head), p_mem_node);
2745 } 2745 }
@@ -2758,13 +2758,13 @@ static int configure_new_function(struct controller *ctrl, struct pci_func *func
2758 func->p_mem_head = hold_p_mem_node; 2758 func->p_mem_head = hold_p_mem_node;
2759 2759
2760 temp_word = (p_mem_node->base - 1) >> 16; 2760 temp_word = (p_mem_node->base - 1) >> 16;
2761 rc = pci_bus_write_config_word (pci_bus, devfn, PCI_PREF_MEMORY_LIMIT, temp_word); 2761 rc = pci_bus_write_config_word(pci_bus, devfn, PCI_PREF_MEMORY_LIMIT, temp_word);
2762 2762
2763 return_resource(&(resources->p_mem_head), p_mem_node); 2763 return_resource(&(resources->p_mem_head), p_mem_node);
2764 } else { 2764 } else {
2765 /* it doesn't need any PMem */ 2765 /* it doesn't need any PMem */
2766 temp_word = 0x0000; 2766 temp_word = 0x0000;
2767 rc = pci_bus_write_config_word (pci_bus, devfn, PCI_PREF_MEMORY_LIMIT, temp_word); 2767 rc = pci_bus_write_config_word(pci_bus, devfn, PCI_PREF_MEMORY_LIMIT, temp_word);
2768 2768
2769 return_resource(&(resources->p_mem_head), p_mem_node); 2769 return_resource(&(resources->p_mem_head), p_mem_node);
2770 kfree(hold_p_mem_node); 2770 kfree(hold_p_mem_node);
@@ -2790,16 +2790,16 @@ static int configure_new_function(struct controller *ctrl, struct pci_func *func
2790 * PCI_COMMAND_INVALIDATE | 2790 * PCI_COMMAND_INVALIDATE |
2791 * PCI_COMMAND_PARITY | 2791 * PCI_COMMAND_PARITY |
2792 * PCI_COMMAND_SERR */ 2792 * PCI_COMMAND_SERR */
2793 rc = pci_bus_write_config_word (pci_bus, devfn, PCI_COMMAND, command); 2793 rc = pci_bus_write_config_word(pci_bus, devfn, PCI_COMMAND, command);
2794 2794
2795 /* set Bridge Control Register */ 2795 /* set Bridge Control Register */
2796 command = 0x07; /* = PCI_BRIDGE_CTL_PARITY | 2796 command = 0x07; /* = PCI_BRIDGE_CTL_PARITY |
2797 * PCI_BRIDGE_CTL_SERR | 2797 * PCI_BRIDGE_CTL_SERR |
2798 * PCI_BRIDGE_CTL_NO_ISA */ 2798 * PCI_BRIDGE_CTL_NO_ISA */
2799 rc = pci_bus_write_config_word (pci_bus, devfn, PCI_BRIDGE_CONTROL, command); 2799 rc = pci_bus_write_config_word(pci_bus, devfn, PCI_BRIDGE_CONTROL, command);
2800 } else if ((temp_byte & 0x7F) == PCI_HEADER_TYPE_NORMAL) { 2800 } else if ((temp_byte & 0x7F) == PCI_HEADER_TYPE_NORMAL) {
2801 /* Standard device */ 2801 /* Standard device */
2802 rc = pci_bus_read_config_byte (pci_bus, devfn, 0x0B, &class_code); 2802 rc = pci_bus_read_config_byte(pci_bus, devfn, 0x0B, &class_code);
2803 2803
2804 if (class_code == PCI_BASE_CLASS_DISPLAY) { 2804 if (class_code == PCI_BASE_CLASS_DISPLAY) {
2805 /* Display (video) adapter (not supported) */ 2805 /* Display (video) adapter (not supported) */
@@ -2810,9 +2810,9 @@ static int configure_new_function(struct controller *ctrl, struct pci_func *func
2810 temp_register = 0xFFFFFFFF; 2810 temp_register = 0xFFFFFFFF;
2811 2811
2812 dbg("CND: bus=%d, devfn=%d, offset=%d\n", pci_bus->number, devfn, cloop); 2812 dbg("CND: bus=%d, devfn=%d, offset=%d\n", pci_bus->number, devfn, cloop);
2813 rc = pci_bus_write_config_dword (pci_bus, devfn, cloop, temp_register); 2813 rc = pci_bus_write_config_dword(pci_bus, devfn, cloop, temp_register);
2814 2814
2815 rc = pci_bus_read_config_dword (pci_bus, devfn, cloop, &temp_register); 2815 rc = pci_bus_read_config_dword(pci_bus, devfn, cloop, &temp_register);
2816 dbg("CND: base = 0x%x\n", temp_register); 2816 dbg("CND: base = 0x%x\n", temp_register);
2817 2817
2818 if (temp_register) { /* If this register is implemented */ 2818 if (temp_register) { /* If this register is implemented */
@@ -2891,7 +2891,7 @@ static int configure_new_function(struct controller *ctrl, struct pci_func *func
2891 } /* End of base register loop */ 2891 } /* End of base register loop */
2892 if (cpqhp_legacy_mode) { 2892 if (cpqhp_legacy_mode) {
2893 /* Figure out which interrupt pin this function uses */ 2893 /* Figure out which interrupt pin this function uses */
2894 rc = pci_bus_read_config_byte (pci_bus, devfn, 2894 rc = pci_bus_read_config_byte(pci_bus, devfn,
2895 PCI_INTERRUPT_PIN, &temp_byte); 2895 PCI_INTERRUPT_PIN, &temp_byte);
2896 2896
2897 /* If this function needs an interrupt and we are behind 2897 /* If this function needs an interrupt and we are behind
@@ -2905,7 +2905,7 @@ static int configure_new_function(struct controller *ctrl, struct pci_func *func
2905 resources->irqs->barber_pole - 1) & 0x03]; 2905 resources->irqs->barber_pole - 1) & 0x03];
2906 } else { 2906 } else {
2907 /* Program IRQ based on card type */ 2907 /* Program IRQ based on card type */
2908 rc = pci_bus_read_config_byte (pci_bus, devfn, 0x0B, &class_code); 2908 rc = pci_bus_read_config_byte(pci_bus, devfn, 0x0B, &class_code);
2909 2909
2910 if (class_code == PCI_BASE_CLASS_STORAGE) 2910 if (class_code == PCI_BASE_CLASS_STORAGE)
2911 IRQ = cpqhp_disk_irq; 2911 IRQ = cpqhp_disk_irq;
@@ -2914,7 +2914,7 @@ static int configure_new_function(struct controller *ctrl, struct pci_func *func
2914 } 2914 }
2915 2915
2916 /* IRQ Line */ 2916 /* IRQ Line */
2917 rc = pci_bus_write_config_byte (pci_bus, devfn, PCI_INTERRUPT_LINE, IRQ); 2917 rc = pci_bus_write_config_byte(pci_bus, devfn, PCI_INTERRUPT_LINE, IRQ);
2918 } 2918 }
2919 2919
2920 if (!behind_bridge) { 2920 if (!behind_bridge) {
@@ -2950,7 +2950,7 @@ static int configure_new_function(struct controller *ctrl, struct pci_func *func
2950 * PCI_COMMAND_INVALIDATE | 2950 * PCI_COMMAND_INVALIDATE |
2951 * PCI_COMMAND_PARITY | 2951 * PCI_COMMAND_PARITY |
2952 * PCI_COMMAND_SERR */ 2952 * PCI_COMMAND_SERR */
2953 rc = pci_bus_write_config_word (pci_bus, devfn, 2953 rc = pci_bus_write_config_word(pci_bus, devfn,
2954 PCI_COMMAND, temp_word); 2954 PCI_COMMAND, temp_word);
2955 } else { /* End of Not-A-Bridge else */ 2955 } else { /* End of Not-A-Bridge else */
2956 /* It's some strange type of PCI adapter (Cardbus?) */ 2956 /* It's some strange type of PCI adapter (Cardbus?) */
@@ -2961,11 +2961,11 @@ static int configure_new_function(struct controller *ctrl, struct pci_func *func
2961 2961
2962 return 0; 2962 return 0;
2963free_and_out: 2963free_and_out:
2964 cpqhp_destroy_resource_list (&temp_resources); 2964 cpqhp_destroy_resource_list(&temp_resources);
2965 2965
2966 return_resource(&(resources-> bus_head), hold_bus_node); 2966 return_resource(&(resources->bus_head), hold_bus_node);
2967 return_resource(&(resources-> io_head), hold_IO_node); 2967 return_resource(&(resources->io_head), hold_IO_node);
2968 return_resource(&(resources-> mem_head), hold_mem_node); 2968 return_resource(&(resources->mem_head), hold_mem_node);
2969 return_resource(&(resources-> p_mem_head), hold_p_mem_node); 2969 return_resource(&(resources->p_mem_head), hold_p_mem_node);
2970 return rc; 2970 return rc;
2971} 2971}
diff --git a/drivers/pci/hotplug/cpqphp_nvram.c b/drivers/pci/hotplug/cpqphp_nvram.c
index 1e08ff8c229c..c25fc9061059 100644
--- a/drivers/pci/hotplug/cpqphp_nvram.c
+++ b/drivers/pci/hotplug/cpqphp_nvram.c
@@ -114,10 +114,10 @@ static u32 add_byte(u32 **p_buffer, u8 value, u32 *used, u32 *avail)
114 if ((*used + 1) > *avail) 114 if ((*used + 1) > *avail)
115 return(1); 115 return(1);
116 116
117 *((u8*)*p_buffer) = value; 117 *((u8 *)*p_buffer) = value;
118 tByte = (u8**)p_buffer; 118 tByte = (u8 **)p_buffer;
119 (*tByte)++; 119 (*tByte)++;
120 *used+=1; 120 *used += 1;
121 return(0); 121 return(0);
122} 122}
123 123
@@ -129,7 +129,7 @@ static u32 add_dword(u32 **p_buffer, u32 value, u32 *used, u32 *avail)
129 129
130 **p_buffer = value; 130 **p_buffer = value;
131 (*p_buffer)++; 131 (*p_buffer)++;
132 *used+=4; 132 *used += 4;
133 return(0); 133 return(0);
134} 134}
135 135
@@ -141,7 +141,7 @@ static u32 add_dword(u32 **p_buffer, u32 value, u32 *used, u32 *avail)
141 * 141 *
142 * returns 0 for non-Compaq ROM, 1 for Compaq ROM 142 * returns 0 for non-Compaq ROM, 1 for Compaq ROM
143 */ 143 */
144static int check_for_compaq_ROM (void __iomem *rom_start) 144static int check_for_compaq_ROM(void __iomem *rom_start)
145{ 145{
146 u8 temp1, temp2, temp3, temp4, temp5, temp6; 146 u8 temp1, temp2, temp3, temp4, temp5, temp6;
147 int result = 0; 147 int result = 0;
@@ -160,12 +160,12 @@ static int check_for_compaq_ROM (void __iomem *rom_start)
160 (temp6 == 'Q')) { 160 (temp6 == 'Q')) {
161 result = 1; 161 result = 1;
162 } 162 }
163 dbg ("%s - returned %d\n", __func__, result); 163 dbg("%s - returned %d\n", __func__, result);
164 return result; 164 return result;
165} 165}
166 166
167 167
168static u32 access_EV (u16 operation, u8 *ev_name, u8 *buffer, u32 *buf_size) 168static u32 access_EV(u16 operation, u8 *ev_name, u8 *buffer, u32 *buf_size)
169{ 169{
170 unsigned long flags; 170 unsigned long flags;
171 int op = operation; 171 int op = operation;
@@ -197,7 +197,7 @@ static u32 access_EV (u16 operation, u8 *ev_name, u8 *buffer, u32 *buf_size)
197 * 197 *
198 * Read the hot plug Resource Table from NVRAM 198 * Read the hot plug Resource Table from NVRAM
199 */ 199 */
200static int load_HRT (void __iomem *rom_start) 200static int load_HRT(void __iomem *rom_start)
201{ 201{
202 u32 available; 202 u32 available;
203 u32 temp_dword; 203 u32 temp_dword;
@@ -232,7 +232,7 @@ static int load_HRT (void __iomem *rom_start)
232 * 232 *
233 * Save the hot plug Resource Table in NVRAM 233 * Save the hot plug Resource Table in NVRAM
234 */ 234 */
235static u32 store_HRT (void __iomem *rom_start) 235static u32 store_HRT(void __iomem *rom_start)
236{ 236{
237 u32 *buffer; 237 u32 *buffer;
238 u32 *pFill; 238 u32 *pFill;
@@ -252,7 +252,7 @@ static u32 store_HRT (void __iomem *rom_start)
252 if (!check_for_compaq_ROM(rom_start)) 252 if (!check_for_compaq_ROM(rom_start))
253 return(1); 253 return(1);
254 254
255 buffer = (u32*) evbuffer; 255 buffer = (u32 *) evbuffer;
256 256
257 if (!buffer) 257 if (!buffer)
258 return(1); 258 return(1);
@@ -306,7 +306,7 @@ static u32 store_HRT (void __iomem *rom_start)
306 loop = 0; 306 loop = 0;
307 307
308 while (resNode) { 308 while (resNode) {
309 loop ++; 309 loop++;
310 310
311 /* base */ 311 /* base */
312 rc = add_dword(&pFill, resNode->base, &usedbytes, &available); 312 rc = add_dword(&pFill, resNode->base, &usedbytes, &available);
@@ -331,7 +331,7 @@ static u32 store_HRT (void __iomem *rom_start)
331 loop = 0; 331 loop = 0;
332 332
333 while (resNode) { 333 while (resNode) {
334 loop ++; 334 loop++;
335 335
336 /* base */ 336 /* base */
337 rc = add_dword(&pFill, resNode->base, &usedbytes, &available); 337 rc = add_dword(&pFill, resNode->base, &usedbytes, &available);
@@ -356,7 +356,7 @@ static u32 store_HRT (void __iomem *rom_start)
356 loop = 0; 356 loop = 0;
357 357
358 while (resNode) { 358 while (resNode) {
359 loop ++; 359 loop++;
360 360
361 /* base */ 361 /* base */
362 rc = add_dword(&pFill, resNode->base, &usedbytes, &available); 362 rc = add_dword(&pFill, resNode->base, &usedbytes, &available);
@@ -381,7 +381,7 @@ static u32 store_HRT (void __iomem *rom_start)
381 loop = 0; 381 loop = 0;
382 382
383 while (resNode) { 383 while (resNode) {
384 loop ++; 384 loop++;
385 385
386 /* base */ 386 /* base */
387 rc = add_dword(&pFill, resNode->base, &usedbytes, &available); 387 rc = add_dword(&pFill, resNode->base, &usedbytes, &available);
@@ -408,7 +408,7 @@ static u32 store_HRT (void __iomem *rom_start)
408 408
409 temp_dword = usedbytes; 409 temp_dword = usedbytes;
410 410
411 rc = access_EV(WRITE_EV, "CQTHPS", (u8*) buffer, &temp_dword); 411 rc = access_EV(WRITE_EV, "CQTHPS", (u8 *) buffer, &temp_dword);
412 412
413 dbg("usedbytes = 0x%x, length = 0x%x\n", usedbytes, temp_dword); 413 dbg("usedbytes = 0x%x, length = 0x%x\n", usedbytes, temp_dword);
414 414
@@ -423,7 +423,7 @@ static u32 store_HRT (void __iomem *rom_start)
423} 423}
424 424
425 425
426void compaq_nvram_init (void __iomem *rom_start) 426void compaq_nvram_init(void __iomem *rom_start)
427{ 427{
428 if (rom_start) 428 if (rom_start)
429 compaq_int15_entry_point = (rom_start + ROM_INT15_PHY_ADDR - ROM_PHY_ADDR); 429 compaq_int15_entry_point = (rom_start + ROM_INT15_PHY_ADDR - ROM_PHY_ADDR);
@@ -435,7 +435,7 @@ void compaq_nvram_init (void __iomem *rom_start)
435} 435}
436 436
437 437
438int compaq_nvram_load (void __iomem *rom_start, struct controller *ctrl) 438int compaq_nvram_load(void __iomem *rom_start, struct controller *ctrl)
439{ 439{
440 u8 bus, device, function; 440 u8 bus, device, function;
441 u8 nummem, numpmem, numio, numbus; 441 u8 nummem, numpmem, numio, numbus;
@@ -451,7 +451,7 @@ int compaq_nvram_load (void __iomem *rom_start, struct controller *ctrl)
451 if (!evbuffer_init) { 451 if (!evbuffer_init) {
452 /* Read the resource list information in from NVRAM */ 452 /* Read the resource list information in from NVRAM */
453 if (load_HRT(rom_start)) 453 if (load_HRT(rom_start))
454 memset (evbuffer, 0, 1024); 454 memset(evbuffer, 0, 1024);
455 455
456 evbuffer_init = 1; 456 evbuffer_init = 1;
457 } 457 }
@@ -472,7 +472,7 @@ int compaq_nvram_load (void __iomem *rom_start, struct controller *ctrl)
472 472
473 p_byte += 3; 473 p_byte += 3;
474 474
475 if (p_byte > ((u8*)p_EV_header + evbuffer_length)) 475 if (p_byte > ((u8 *)p_EV_header + evbuffer_length))
476 return 2; 476 return 2;
477 477
478 bus = p_ev_ctrl->bus; 478 bus = p_ev_ctrl->bus;
@@ -489,20 +489,20 @@ int compaq_nvram_load (void __iomem *rom_start, struct controller *ctrl)
489 489
490 p_byte += 4; 490 p_byte += 4;
491 491
492 if (p_byte > ((u8*)p_EV_header + evbuffer_length)) 492 if (p_byte > ((u8 *)p_EV_header + evbuffer_length))
493 return 2; 493 return 2;
494 494
495 /* Skip forward to the next entry */ 495 /* Skip forward to the next entry */
496 p_byte += (nummem + numpmem + numio + numbus) * 8; 496 p_byte += (nummem + numpmem + numio + numbus) * 8;
497 497
498 if (p_byte > ((u8*)p_EV_header + evbuffer_length)) 498 if (p_byte > ((u8 *)p_EV_header + evbuffer_length))
499 return 2; 499 return 2;
500 500
501 p_ev_ctrl = (struct ev_hrt_ctrl *) p_byte; 501 p_ev_ctrl = (struct ev_hrt_ctrl *) p_byte;
502 502
503 p_byte += 3; 503 p_byte += 3;
504 504
505 if (p_byte > ((u8*)p_EV_header + evbuffer_length)) 505 if (p_byte > ((u8 *)p_EV_header + evbuffer_length))
506 return 2; 506 return 2;
507 507
508 bus = p_ev_ctrl->bus; 508 bus = p_ev_ctrl->bus;
@@ -517,7 +517,7 @@ int compaq_nvram_load (void __iomem *rom_start, struct controller *ctrl)
517 517
518 p_byte += 4; 518 p_byte += 4;
519 519
520 if (p_byte > ((u8*)p_EV_header + evbuffer_length)) 520 if (p_byte > ((u8 *)p_EV_header + evbuffer_length))
521 return 2; 521 return 2;
522 522
523 while (nummem--) { 523 while (nummem--) {
@@ -526,20 +526,20 @@ int compaq_nvram_load (void __iomem *rom_start, struct controller *ctrl)
526 if (!mem_node) 526 if (!mem_node)
527 break; 527 break;
528 528
529 mem_node->base = *(u32*)p_byte; 529 mem_node->base = *(u32 *)p_byte;
530 dbg("mem base = %8.8x\n",mem_node->base); 530 dbg("mem base = %8.8x\n", mem_node->base);
531 p_byte += 4; 531 p_byte += 4;
532 532
533 if (p_byte > ((u8*)p_EV_header + evbuffer_length)) { 533 if (p_byte > ((u8 *)p_EV_header + evbuffer_length)) {
534 kfree(mem_node); 534 kfree(mem_node);
535 return 2; 535 return 2;
536 } 536 }
537 537
538 mem_node->length = *(u32*)p_byte; 538 mem_node->length = *(u32 *)p_byte;
539 dbg("mem length = %8.8x\n",mem_node->length); 539 dbg("mem length = %8.8x\n", mem_node->length);
540 p_byte += 4; 540 p_byte += 4;
541 541
542 if (p_byte > ((u8*)p_EV_header + evbuffer_length)) { 542 if (p_byte > ((u8 *)p_EV_header + evbuffer_length)) {
543 kfree(mem_node); 543 kfree(mem_node);
544 return 2; 544 return 2;
545 } 545 }
@@ -554,20 +554,20 @@ int compaq_nvram_load (void __iomem *rom_start, struct controller *ctrl)
554 if (!p_mem_node) 554 if (!p_mem_node)
555 break; 555 break;
556 556
557 p_mem_node->base = *(u32*)p_byte; 557 p_mem_node->base = *(u32 *)p_byte;
558 dbg("pre-mem base = %8.8x\n",p_mem_node->base); 558 dbg("pre-mem base = %8.8x\n", p_mem_node->base);
559 p_byte += 4; 559 p_byte += 4;
560 560
561 if (p_byte > ((u8*)p_EV_header + evbuffer_length)) { 561 if (p_byte > ((u8 *)p_EV_header + evbuffer_length)) {
562 kfree(p_mem_node); 562 kfree(p_mem_node);
563 return 2; 563 return 2;
564 } 564 }
565 565
566 p_mem_node->length = *(u32*)p_byte; 566 p_mem_node->length = *(u32 *)p_byte;
567 dbg("pre-mem length = %8.8x\n",p_mem_node->length); 567 dbg("pre-mem length = %8.8x\n", p_mem_node->length);
568 p_byte += 4; 568 p_byte += 4;
569 569
570 if (p_byte > ((u8*)p_EV_header + evbuffer_length)) { 570 if (p_byte > ((u8 *)p_EV_header + evbuffer_length)) {
571 kfree(p_mem_node); 571 kfree(p_mem_node);
572 return 2; 572 return 2;
573 } 573 }
@@ -582,20 +582,20 @@ int compaq_nvram_load (void __iomem *rom_start, struct controller *ctrl)
582 if (!io_node) 582 if (!io_node)
583 break; 583 break;
584 584
585 io_node->base = *(u32*)p_byte; 585 io_node->base = *(u32 *)p_byte;
586 dbg("io base = %8.8x\n",io_node->base); 586 dbg("io base = %8.8x\n", io_node->base);
587 p_byte += 4; 587 p_byte += 4;
588 588
589 if (p_byte > ((u8*)p_EV_header + evbuffer_length)) { 589 if (p_byte > ((u8 *)p_EV_header + evbuffer_length)) {
590 kfree(io_node); 590 kfree(io_node);
591 return 2; 591 return 2;
592 } 592 }
593 593
594 io_node->length = *(u32*)p_byte; 594 io_node->length = *(u32 *)p_byte;
595 dbg("io length = %8.8x\n",io_node->length); 595 dbg("io length = %8.8x\n", io_node->length);
596 p_byte += 4; 596 p_byte += 4;
597 597
598 if (p_byte > ((u8*)p_EV_header + evbuffer_length)) { 598 if (p_byte > ((u8 *)p_EV_header + evbuffer_length)) {
599 kfree(io_node); 599 kfree(io_node);
600 return 2; 600 return 2;
601 } 601 }
@@ -610,18 +610,18 @@ int compaq_nvram_load (void __iomem *rom_start, struct controller *ctrl)
610 if (!bus_node) 610 if (!bus_node)
611 break; 611 break;
612 612
613 bus_node->base = *(u32*)p_byte; 613 bus_node->base = *(u32 *)p_byte;
614 p_byte += 4; 614 p_byte += 4;
615 615
616 if (p_byte > ((u8*)p_EV_header + evbuffer_length)) { 616 if (p_byte > ((u8 *)p_EV_header + evbuffer_length)) {
617 kfree(bus_node); 617 kfree(bus_node);
618 return 2; 618 return 2;
619 } 619 }
620 620
621 bus_node->length = *(u32*)p_byte; 621 bus_node->length = *(u32 *)p_byte;
622 p_byte += 4; 622 p_byte += 4;
623 623
624 if (p_byte > ((u8*)p_EV_header + evbuffer_length)) { 624 if (p_byte > ((u8 *)p_EV_header + evbuffer_length)) {
625 kfree(bus_node); 625 kfree(bus_node);
626 return 2; 626 return 2;
627 } 627 }
@@ -650,7 +650,7 @@ int compaq_nvram_load (void __iomem *rom_start, struct controller *ctrl)
650} 650}
651 651
652 652
653int compaq_nvram_store (void __iomem *rom_start) 653int compaq_nvram_store(void __iomem *rom_start)
654{ 654{
655 int rc = 1; 655 int rc = 1;
656 656
diff --git a/drivers/pci/hotplug/cpqphp_pci.c b/drivers/pci/hotplug/cpqphp_pci.c
index 1c8c2f130d31..e220d49307bd 100644
--- a/drivers/pci/hotplug/cpqphp_pci.c
+++ b/drivers/pci/hotplug/cpqphp_pci.c
@@ -81,7 +81,7 @@ static void __iomem *detect_HRT_floating_pointer(void __iomem *begin, void __iom
81} 81}
82 82
83 83
84int cpqhp_configure_device (struct controller *ctrl, struct pci_func *func) 84int cpqhp_configure_device(struct controller *ctrl, struct pci_func *func)
85{ 85{
86 struct pci_bus *child; 86 struct pci_bus *child;
87 int num; 87 int num;
@@ -89,7 +89,7 @@ int cpqhp_configure_device (struct controller *ctrl, struct pci_func *func)
89 pci_lock_rescan_remove(); 89 pci_lock_rescan_remove();
90 90
91 if (func->pci_dev == NULL) 91 if (func->pci_dev == NULL)
92 func->pci_dev = pci_get_bus_and_slot(func->bus,PCI_DEVFN(func->device, func->function)); 92 func->pci_dev = pci_get_bus_and_slot(func->bus, PCI_DEVFN(func->device, func->function));
93 93
94 /* No pci device, we need to create it then */ 94 /* No pci device, we need to create it then */
95 if (func->pci_dev == NULL) { 95 if (func->pci_dev == NULL) {
@@ -128,7 +128,7 @@ int cpqhp_unconfigure_device(struct pci_func *func)
128 dbg("%s: bus/dev/func = %x/%x/%x\n", __func__, func->bus, func->device, func->function); 128 dbg("%s: bus/dev/func = %x/%x/%x\n", __func__, func->bus, func->device, func->function);
129 129
130 pci_lock_rescan_remove(); 130 pci_lock_rescan_remove();
131 for (j=0; j<8 ; j++) { 131 for (j = 0; j < 8 ; j++) {
132 struct pci_dev *temp = pci_get_bus_and_slot(func->bus, PCI_DEVFN(func->device, j)); 132 struct pci_dev *temp = pci_get_bus_and_slot(func->bus, PCI_DEVFN(func->device, j));
133 if (temp) { 133 if (temp) {
134 pci_dev_put(temp); 134 pci_dev_put(temp);
@@ -143,11 +143,11 @@ static int PCI_RefinedAccessConfig(struct pci_bus *bus, unsigned int devfn, u8 o
143{ 143{
144 u32 vendID = 0; 144 u32 vendID = 0;
145 145
146 if (pci_bus_read_config_dword (bus, devfn, PCI_VENDOR_ID, &vendID) == -1) 146 if (pci_bus_read_config_dword(bus, devfn, PCI_VENDOR_ID, &vendID) == -1)
147 return -1; 147 return -1;
148 if (vendID == 0xffffffff) 148 if (vendID == 0xffffffff)
149 return -1; 149 return -1;
150 return pci_bus_read_config_dword (bus, devfn, offset, value); 150 return pci_bus_read_config_dword(bus, devfn, offset, value);
151} 151}
152 152
153 153
@@ -158,7 +158,7 @@ static int PCI_RefinedAccessConfig(struct pci_bus *bus, unsigned int devfn, u8 o
158 * @dev_num: device number of PCI device 158 * @dev_num: device number of PCI device
159 * @slot: pointer to u8 where slot number will be returned 159 * @slot: pointer to u8 where slot number will be returned
160 */ 160 */
161int cpqhp_set_irq (u8 bus_num, u8 dev_num, u8 int_pin, u8 irq_num) 161int cpqhp_set_irq(u8 bus_num, u8 dev_num, u8 int_pin, u8 irq_num)
162{ 162{
163 int rc = 0; 163 int rc = 0;
164 164
@@ -230,7 +230,7 @@ static int PCI_ScanBusForNonBridge(struct controller *ctrl, u8 bus_num, u8 *dev_
230 dbg("Looking for bridge bus_num %d dev_num %d\n", bus_num, tdevice); 230 dbg("Looking for bridge bus_num %d dev_num %d\n", bus_num, tdevice);
231 /* Yep we got one. bridge ? */ 231 /* Yep we got one. bridge ? */
232 if ((work >> 8) == PCI_TO_PCI_BRIDGE_CLASS) { 232 if ((work >> 8) == PCI_TO_PCI_BRIDGE_CLASS) {
233 pci_bus_read_config_byte (ctrl->pci_bus, PCI_DEVFN(tdevice, 0), PCI_SECONDARY_BUS, &tbus); 233 pci_bus_read_config_byte(ctrl->pci_bus, PCI_DEVFN(tdevice, 0), PCI_SECONDARY_BUS, &tbus);
234 /* XXX: no recursion, wtf? */ 234 /* XXX: no recursion, wtf? */
235 dbg("Recurse on bus_num %d tdevice %d\n", tbus, tdevice); 235 dbg("Recurse on bus_num %d tdevice %d\n", tbus, tdevice);
236 return 0; 236 return 0;
@@ -257,16 +257,16 @@ static int PCI_GetBusDevHelper(struct controller *ctrl, u8 *bus_num, u8 *dev_num
257 *bus_num = tbus; 257 *bus_num = tbus;
258 *dev_num = tdevice; 258 *dev_num = tdevice;
259 ctrl->pci_bus->number = tbus; 259 ctrl->pci_bus->number = tbus;
260 pci_bus_read_config_dword (ctrl->pci_bus, *dev_num, PCI_VENDOR_ID, &work); 260 pci_bus_read_config_dword(ctrl->pci_bus, *dev_num, PCI_VENDOR_ID, &work);
261 if (!nobridge || (work == 0xffffffff)) 261 if (!nobridge || (work == 0xffffffff))
262 return 0; 262 return 0;
263 263
264 dbg("bus_num %d devfn %d\n", *bus_num, *dev_num); 264 dbg("bus_num %d devfn %d\n", *bus_num, *dev_num);
265 pci_bus_read_config_dword (ctrl->pci_bus, *dev_num, PCI_CLASS_REVISION, &work); 265 pci_bus_read_config_dword(ctrl->pci_bus, *dev_num, PCI_CLASS_REVISION, &work);
266 dbg("work >> 8 (%x) = BRIDGE (%x)\n", work >> 8, PCI_TO_PCI_BRIDGE_CLASS); 266 dbg("work >> 8 (%x) = BRIDGE (%x)\n", work >> 8, PCI_TO_PCI_BRIDGE_CLASS);
267 267
268 if ((work >> 8) == PCI_TO_PCI_BRIDGE_CLASS) { 268 if ((work >> 8) == PCI_TO_PCI_BRIDGE_CLASS) {
269 pci_bus_read_config_byte (ctrl->pci_bus, *dev_num, PCI_SECONDARY_BUS, &tbus); 269 pci_bus_read_config_byte(ctrl->pci_bus, *dev_num, PCI_SECONDARY_BUS, &tbus);
270 dbg("Scan bus for Non Bridge: bus %d\n", tbus); 270 dbg("Scan bus for Non Bridge: bus %d\n", tbus);
271 if (PCI_ScanBusForNonBridge(ctrl, tbus, dev_num) == 0) { 271 if (PCI_ScanBusForNonBridge(ctrl, tbus, dev_num) == 0) {
272 *bus_num = tbus; 272 *bus_num = tbus;
@@ -280,7 +280,7 @@ static int PCI_GetBusDevHelper(struct controller *ctrl, u8 *bus_num, u8 *dev_num
280} 280}
281 281
282 282
283int cpqhp_get_bus_dev (struct controller *ctrl, u8 *bus_num, u8 *dev_num, u8 slot) 283int cpqhp_get_bus_dev(struct controller *ctrl, u8 *bus_num, u8 *dev_num, u8 slot)
284{ 284{
285 /* plain (bridges allowed) */ 285 /* plain (bridges allowed) */
286 return PCI_GetBusDevHelper(ctrl, bus_num, dev_num, slot, 0); 286 return PCI_GetBusDevHelper(ctrl, bus_num, dev_num, slot, 0);
@@ -419,7 +419,7 @@ int cpqhp_save_config(struct controller *ctrl, int busnumber, int is_hot_plug)
419 new_slot->pci_dev = pci_get_bus_and_slot(new_slot->bus, (new_slot->device << 3) | new_slot->function); 419 new_slot->pci_dev = pci_get_bus_and_slot(new_slot->bus, (new_slot->device << 3) | new_slot->function);
420 420
421 for (cloop = 0; cloop < 0x20; cloop++) { 421 for (cloop = 0; cloop < 0x20; cloop++) {
422 rc = pci_bus_read_config_dword(ctrl->pci_bus, PCI_DEVFN(device, function), cloop << 2, (u32 *) & (new_slot-> config_space [cloop])); 422 rc = pci_bus_read_config_dword(ctrl->pci_bus, PCI_DEVFN(device, function), cloop << 2, (u32 *) &(new_slot->config_space[cloop]));
423 if (rc) 423 if (rc)
424 return rc; 424 return rc;
425 } 425 }
@@ -465,7 +465,7 @@ int cpqhp_save_config(struct controller *ctrl, int busnumber, int is_hot_plug)
465 * 465 *
466 * returns 0 if success 466 * returns 0 if success
467 */ 467 */
468int cpqhp_save_slot_config (struct controller *ctrl, struct pci_func *new_slot) 468int cpqhp_save_slot_config(struct controller *ctrl, struct pci_func *new_slot)
469{ 469{
470 long rc; 470 long rc;
471 u8 class_code; 471 u8 class_code;
@@ -481,7 +481,7 @@ int cpqhp_save_slot_config (struct controller *ctrl, struct pci_func *new_slot)
481 ID = 0xFFFFFFFF; 481 ID = 0xFFFFFFFF;
482 482
483 ctrl->pci_bus->number = new_slot->bus; 483 ctrl->pci_bus->number = new_slot->bus;
484 pci_bus_read_config_dword (ctrl->pci_bus, PCI_DEVFN(new_slot->device, 0), PCI_VENDOR_ID, &ID); 484 pci_bus_read_config_dword(ctrl->pci_bus, PCI_DEVFN(new_slot->device, 0), PCI_VENDOR_ID, &ID);
485 485
486 if (ID == 0xFFFFFFFF) 486 if (ID == 0xFFFFFFFF)
487 return 2; 487 return 2;
@@ -497,7 +497,7 @@ int cpqhp_save_slot_config (struct controller *ctrl, struct pci_func *new_slot)
497 while (function < max_functions) { 497 while (function < max_functions) {
498 if ((header_type & 0x7F) == PCI_HEADER_TYPE_BRIDGE) { 498 if ((header_type & 0x7F) == PCI_HEADER_TYPE_BRIDGE) {
499 /* Recurse the subordinate bus */ 499 /* Recurse the subordinate bus */
500 pci_bus_read_config_byte (ctrl->pci_bus, PCI_DEVFN(new_slot->device, function), PCI_SECONDARY_BUS, &secondary_bus); 500 pci_bus_read_config_byte(ctrl->pci_bus, PCI_DEVFN(new_slot->device, function), PCI_SECONDARY_BUS, &secondary_bus);
501 501
502 sub_bus = (int) secondary_bus; 502 sub_bus = (int) secondary_bus;
503 503
@@ -514,7 +514,7 @@ int cpqhp_save_slot_config (struct controller *ctrl, struct pci_func *new_slot)
514 new_slot->status = 0; 514 new_slot->status = 0;
515 515
516 for (cloop = 0; cloop < 0x20; cloop++) 516 for (cloop = 0; cloop < 0x20; cloop++)
517 pci_bus_read_config_dword(ctrl->pci_bus, PCI_DEVFN(new_slot->device, function), cloop << 2, (u32 *) & (new_slot-> config_space [cloop])); 517 pci_bus_read_config_dword(ctrl->pci_bus, PCI_DEVFN(new_slot->device, function), cloop << 2, (u32 *) &(new_slot->config_space[cloop]));
518 518
519 function++; 519 function++;
520 520
@@ -571,10 +571,10 @@ int cpqhp_save_base_addr_length(struct controller *ctrl, struct pci_func *func)
571 devfn = PCI_DEVFN(func->device, func->function); 571 devfn = PCI_DEVFN(func->device, func->function);
572 572
573 /* Check for Bridge */ 573 /* Check for Bridge */
574 pci_bus_read_config_byte (pci_bus, devfn, PCI_HEADER_TYPE, &header_type); 574 pci_bus_read_config_byte(pci_bus, devfn, PCI_HEADER_TYPE, &header_type);
575 575
576 if ((header_type & 0x7F) == PCI_HEADER_TYPE_BRIDGE) { 576 if ((header_type & 0x7F) == PCI_HEADER_TYPE_BRIDGE) {
577 pci_bus_read_config_byte (pci_bus, devfn, PCI_SECONDARY_BUS, &secondary_bus); 577 pci_bus_read_config_byte(pci_bus, devfn, PCI_SECONDARY_BUS, &secondary_bus);
578 578
579 sub_bus = (int) secondary_bus; 579 sub_bus = (int) secondary_bus;
580 580
@@ -595,8 +595,8 @@ int cpqhp_save_base_addr_length(struct controller *ctrl, struct pci_func *func)
595 */ 595 */
596 for (cloop = 0x10; cloop <= 0x14; cloop += 4) { 596 for (cloop = 0x10; cloop <= 0x14; cloop += 4) {
597 temp_register = 0xFFFFFFFF; 597 temp_register = 0xFFFFFFFF;
598 pci_bus_write_config_dword (pci_bus, devfn, cloop, temp_register); 598 pci_bus_write_config_dword(pci_bus, devfn, cloop, temp_register);
599 pci_bus_read_config_dword (pci_bus, devfn, cloop, &base); 599 pci_bus_read_config_dword(pci_bus, devfn, cloop, &base);
600 /* If this register is implemented */ 600 /* If this register is implemented */
601 if (base) { 601 if (base) {
602 if (base & 0x01L) { 602 if (base & 0x01L) {
@@ -631,8 +631,8 @@ int cpqhp_save_base_addr_length(struct controller *ctrl, struct pci_func *func)
631 /* Figure out IO and memory base lengths */ 631 /* Figure out IO and memory base lengths */
632 for (cloop = 0x10; cloop <= 0x24; cloop += 4) { 632 for (cloop = 0x10; cloop <= 0x24; cloop += 4) {
633 temp_register = 0xFFFFFFFF; 633 temp_register = 0xFFFFFFFF;
634 pci_bus_write_config_dword (pci_bus, devfn, cloop, temp_register); 634 pci_bus_write_config_dword(pci_bus, devfn, cloop, temp_register);
635 pci_bus_read_config_dword (pci_bus, devfn, cloop, &base); 635 pci_bus_read_config_dword(pci_bus, devfn, cloop, &base);
636 636
637 /* If this register is implemented */ 637 /* If this register is implemented */
638 if (base) { 638 if (base) {
@@ -686,7 +686,7 @@ int cpqhp_save_base_addr_length(struct controller *ctrl, struct pci_func *func)
686 * 686 *
687 * returns 0 if success 687 * returns 0 if success
688 */ 688 */
689int cpqhp_save_used_resources (struct controller *ctrl, struct pci_func *func) 689int cpqhp_save_used_resources(struct controller *ctrl, struct pci_func *func)
690{ 690{
691 u8 cloop; 691 u8 cloop;
692 u8 header_type; 692 u8 header_type;
@@ -791,7 +791,7 @@ int cpqhp_save_used_resources (struct controller *ctrl, struct pci_func *func)
791 } 791 }
792 /* Figure out IO and memory base lengths */ 792 /* Figure out IO and memory base lengths */
793 for (cloop = 0x10; cloop <= 0x14; cloop += 4) { 793 for (cloop = 0x10; cloop <= 0x14; cloop += 4) {
794 pci_bus_read_config_dword (pci_bus, devfn, cloop, &save_base); 794 pci_bus_read_config_dword(pci_bus, devfn, cloop, &save_base);
795 795
796 temp_register = 0xFFFFFFFF; 796 temp_register = 0xFFFFFFFF;
797 pci_bus_write_config_dword(pci_bus, devfn, cloop, temp_register); 797 pci_bus_write_config_dword(pci_bus, devfn, cloop, temp_register);
@@ -972,13 +972,13 @@ int cpqhp_configure_board(struct controller *ctrl, struct pci_func *func)
972 * registers are programmed last 972 * registers are programmed last
973 */ 973 */
974 for (cloop = 0x3C; cloop > 0; cloop -= 4) 974 for (cloop = 0x3C; cloop > 0; cloop -= 4)
975 pci_bus_write_config_dword (pci_bus, devfn, cloop, func->config_space[cloop >> 2]); 975 pci_bus_write_config_dword(pci_bus, devfn, cloop, func->config_space[cloop >> 2]);
976 976
977 pci_bus_read_config_byte (pci_bus, devfn, PCI_HEADER_TYPE, &header_type); 977 pci_bus_read_config_byte(pci_bus, devfn, PCI_HEADER_TYPE, &header_type);
978 978
979 /* If this is a bridge device, restore subordinate devices */ 979 /* If this is a bridge device, restore subordinate devices */
980 if ((header_type & 0x7F) == PCI_HEADER_TYPE_BRIDGE) { 980 if ((header_type & 0x7F) == PCI_HEADER_TYPE_BRIDGE) {
981 pci_bus_read_config_byte (pci_bus, devfn, PCI_SECONDARY_BUS, &secondary_bus); 981 pci_bus_read_config_byte(pci_bus, devfn, PCI_SECONDARY_BUS, &secondary_bus);
982 982
983 sub_bus = (int) secondary_bus; 983 sub_bus = (int) secondary_bus;
984 984
@@ -998,7 +998,7 @@ int cpqhp_configure_board(struct controller *ctrl, struct pci_func *func)
998 */ 998 */
999 999
1000 for (cloop = 16; cloop < 40; cloop += 4) { 1000 for (cloop = 16; cloop < 40; cloop += 4) {
1001 pci_bus_read_config_dword (pci_bus, devfn, cloop, &temp); 1001 pci_bus_read_config_dword(pci_bus, devfn, cloop, &temp);
1002 1002
1003 if (temp != func->config_space[cloop >> 2]) { 1003 if (temp != func->config_space[cloop >> 2]) {
1004 dbg("Config space compare failure!!! offset = %x\n", cloop); 1004 dbg("Config space compare failure!!! offset = %x\n", cloop);
@@ -1050,7 +1050,7 @@ int cpqhp_valid_replace(struct controller *ctrl, struct pci_func *func)
1050 pci_bus->number = func->bus; 1050 pci_bus->number = func->bus;
1051 devfn = PCI_DEVFN(func->device, func->function); 1051 devfn = PCI_DEVFN(func->device, func->function);
1052 1052
1053 pci_bus_read_config_dword (pci_bus, devfn, PCI_VENDOR_ID, &temp_register); 1053 pci_bus_read_config_dword(pci_bus, devfn, PCI_VENDOR_ID, &temp_register);
1054 1054
1055 /* No adapter present */ 1055 /* No adapter present */
1056 if (temp_register == 0xFFFFFFFF) 1056 if (temp_register == 0xFFFFFFFF)
@@ -1060,14 +1060,14 @@ int cpqhp_valid_replace(struct controller *ctrl, struct pci_func *func)
1060 return(ADAPTER_NOT_SAME); 1060 return(ADAPTER_NOT_SAME);
1061 1061
1062 /* Check for same revision number and class code */ 1062 /* Check for same revision number and class code */
1063 pci_bus_read_config_dword (pci_bus, devfn, PCI_CLASS_REVISION, &temp_register); 1063 pci_bus_read_config_dword(pci_bus, devfn, PCI_CLASS_REVISION, &temp_register);
1064 1064
1065 /* Adapter not the same */ 1065 /* Adapter not the same */
1066 if (temp_register != func->config_space[0x08 >> 2]) 1066 if (temp_register != func->config_space[0x08 >> 2])
1067 return(ADAPTER_NOT_SAME); 1067 return(ADAPTER_NOT_SAME);
1068 1068
1069 /* Check for Bridge */ 1069 /* Check for Bridge */
1070 pci_bus_read_config_byte (pci_bus, devfn, PCI_HEADER_TYPE, &header_type); 1070 pci_bus_read_config_byte(pci_bus, devfn, PCI_HEADER_TYPE, &header_type);
1071 1071
1072 if ((header_type & 0x7F) == PCI_HEADER_TYPE_BRIDGE) { 1072 if ((header_type & 0x7F) == PCI_HEADER_TYPE_BRIDGE) {
1073 /* In order to continue checking, we must program the 1073 /* In order to continue checking, we must program the
@@ -1076,7 +1076,7 @@ int cpqhp_valid_replace(struct controller *ctrl, struct pci_func *func)
1076 */ 1076 */
1077 1077
1078 temp_register = func->config_space[0x18 >> 2]; 1078 temp_register = func->config_space[0x18 >> 2];
1079 pci_bus_write_config_dword (pci_bus, devfn, PCI_PRIMARY_BUS, temp_register); 1079 pci_bus_write_config_dword(pci_bus, devfn, PCI_PRIMARY_BUS, temp_register);
1080 1080
1081 secondary_bus = (temp_register >> 8) & 0xFF; 1081 secondary_bus = (temp_register >> 8) & 0xFF;
1082 1082
@@ -1094,7 +1094,7 @@ int cpqhp_valid_replace(struct controller *ctrl, struct pci_func *func)
1094 /* Check to see if it is a standard config header */ 1094 /* Check to see if it is a standard config header */
1095 else if ((header_type & 0x7F) == PCI_HEADER_TYPE_NORMAL) { 1095 else if ((header_type & 0x7F) == PCI_HEADER_TYPE_NORMAL) {
1096 /* Check subsystem vendor and ID */ 1096 /* Check subsystem vendor and ID */
1097 pci_bus_read_config_dword (pci_bus, devfn, PCI_SUBSYSTEM_VENDOR_ID, &temp_register); 1097 pci_bus_read_config_dword(pci_bus, devfn, PCI_SUBSYSTEM_VENDOR_ID, &temp_register);
1098 1098
1099 if (temp_register != func->config_space[0x2C >> 2]) { 1099 if (temp_register != func->config_space[0x2C >> 2]) {
1100 /* If it's a SMART-2 and the register isn't 1100 /* If it's a SMART-2 and the register isn't
@@ -1108,8 +1108,8 @@ int cpqhp_valid_replace(struct controller *ctrl, struct pci_func *func)
1108 /* Figure out IO and memory base lengths */ 1108 /* Figure out IO and memory base lengths */
1109 for (cloop = 0x10; cloop <= 0x24; cloop += 4) { 1109 for (cloop = 0x10; cloop <= 0x24; cloop += 4) {
1110 temp_register = 0xFFFFFFFF; 1110 temp_register = 0xFFFFFFFF;
1111 pci_bus_write_config_dword (pci_bus, devfn, cloop, temp_register); 1111 pci_bus_write_config_dword(pci_bus, devfn, cloop, temp_register);
1112 pci_bus_read_config_dword (pci_bus, devfn, cloop, &base); 1112 pci_bus_read_config_dword(pci_bus, devfn, cloop, &base);
1113 1113
1114 /* If this register is implemented */ 1114 /* If this register is implemented */
1115 if (base) { 1115 if (base) {
@@ -1234,7 +1234,7 @@ int cpqhp_find_available_resources(struct controller *ctrl, void __iomem *rom_st
1234 if (rc) 1234 if (rc)
1235 return rc; 1235 return rc;
1236 1236
1237 one_slot = rom_resource_table + sizeof (struct hrt); 1237 one_slot = rom_resource_table + sizeof(struct hrt);
1238 1238
1239 i = readb(rom_resource_table + NUMBER_OF_ENTRIES); 1239 i = readb(rom_resource_table + NUMBER_OF_ENTRIES);
1240 dbg("number_of_entries = %d\n", i); 1240 dbg("number_of_entries = %d\n", i);
@@ -1263,12 +1263,12 @@ int cpqhp_find_available_resources(struct controller *ctrl, void __iomem *rom_st
1263 /* If this entry isn't for our controller's bus, ignore it */ 1263 /* If this entry isn't for our controller's bus, ignore it */
1264 if (primary_bus != ctrl->bus) { 1264 if (primary_bus != ctrl->bus) {
1265 i--; 1265 i--;
1266 one_slot += sizeof (struct slot_rt); 1266 one_slot += sizeof(struct slot_rt);
1267 continue; 1267 continue;
1268 } 1268 }
1269 /* find out if this entry is for an occupied slot */ 1269 /* find out if this entry is for an occupied slot */
1270 ctrl->pci_bus->number = primary_bus; 1270 ctrl->pci_bus->number = primary_bus;
1271 pci_bus_read_config_dword (ctrl->pci_bus, dev_func, PCI_VENDOR_ID, &temp_dword); 1271 pci_bus_read_config_dword(ctrl->pci_bus, dev_func, PCI_VENDOR_ID, &temp_dword);
1272 dbg("temp_D_word = %x\n", temp_dword); 1272 dbg("temp_D_word = %x\n", temp_dword);
1273 1273
1274 if (temp_dword != 0xFFFFFFFF) { 1274 if (temp_dword != 0xFFFFFFFF) {
@@ -1283,7 +1283,7 @@ int cpqhp_find_available_resources(struct controller *ctrl, void __iomem *rom_st
1283 /* If we can't find a match, skip this table entry */ 1283 /* If we can't find a match, skip this table entry */
1284 if (!func) { 1284 if (!func) {
1285 i--; 1285 i--;
1286 one_slot += sizeof (struct slot_rt); 1286 one_slot += sizeof(struct slot_rt);
1287 continue; 1287 continue;
1288 } 1288 }
1289 /* this may not work and shouldn't be used */ 1289 /* this may not work and shouldn't be used */
@@ -1395,7 +1395,7 @@ int cpqhp_find_available_resources(struct controller *ctrl, void __iomem *rom_st
1395 } 1395 }
1396 1396
1397 i--; 1397 i--;
1398 one_slot += sizeof (struct slot_rt); 1398 one_slot += sizeof(struct slot_rt);
1399 } 1399 }
1400 1400
1401 /* If all of the following fail, we don't have any resources for 1401 /* If all of the following fail, we don't have any resources for
@@ -1475,7 +1475,7 @@ int cpqhp_return_board_resources(struct pci_func *func, struct resource_lists *r
1475 * 1475 *
1476 * Puts node back in the resource list pointed to by head 1476 * Puts node back in the resource list pointed to by head
1477 */ 1477 */
1478void cpqhp_destroy_resource_list (struct resource_lists *resources) 1478void cpqhp_destroy_resource_list(struct resource_lists *resources)
1479{ 1479{
1480 struct pci_resource *res, *tres; 1480 struct pci_resource *res, *tres;
1481 1481
@@ -1522,7 +1522,7 @@ void cpqhp_destroy_resource_list (struct resource_lists *resources)
1522 * 1522 *
1523 * Puts node back in the resource list pointed to by head 1523 * Puts node back in the resource list pointed to by head
1524 */ 1524 */
1525void cpqhp_destroy_board_resources (struct pci_func *func) 1525void cpqhp_destroy_board_resources(struct pci_func *func)
1526{ 1526{
1527 struct pci_resource *res, *tres; 1527 struct pci_resource *res, *tres;
1528 1528
diff --git a/drivers/pci/hotplug/cpqphp_sysfs.c b/drivers/pci/hotplug/cpqphp_sysfs.c
index d81648f71425..775974deda74 100644
--- a/drivers/pci/hotplug/cpqphp_sysfs.c
+++ b/drivers/pci/hotplug/cpqphp_sysfs.c
@@ -39,7 +39,7 @@
39#include "cpqphp.h" 39#include "cpqphp.h"
40 40
41static DEFINE_MUTEX(cpqphp_mutex); 41static DEFINE_MUTEX(cpqphp_mutex);
42static int show_ctrl (struct controller *ctrl, char *buf) 42static int show_ctrl(struct controller *ctrl, char *buf)
43{ 43{
44 char *out = buf; 44 char *out = buf;
45 int index; 45 int index;
@@ -77,7 +77,7 @@ static int show_ctrl (struct controller *ctrl, char *buf)
77 return out - buf; 77 return out - buf;
78} 78}
79 79
80static int show_dev (struct controller *ctrl, char *buf) 80static int show_dev(struct controller *ctrl, char *buf)
81{ 81{
82 char *out = buf; 82 char *out = buf;
83 int index; 83 int index;
@@ -119,7 +119,7 @@ static int show_dev (struct controller *ctrl, char *buf)
119 out += sprintf(out, "start = %8.8x, length = %8.8x\n", res->base, res->length); 119 out += sprintf(out, "start = %8.8x, length = %8.8x\n", res->base, res->length);
120 res = res->next; 120 res = res->next;
121 } 121 }
122 slot=slot->next; 122 slot = slot->next;
123 } 123 }
124 124
125 return out - buf; 125 return out - buf;
diff --git a/drivers/pci/hotplug/ibmphp.h b/drivers/pci/hotplug/ibmphp.h
index e3e46a7b3ee7..d3256838cb05 100644
--- a/drivers/pci/hotplug/ibmphp.h
+++ b/drivers/pci/hotplug/ibmphp.h
@@ -39,11 +39,11 @@ extern int ibmphp_debug;
39#else 39#else
40 #define MY_NAME THIS_MODULE->name 40 #define MY_NAME THIS_MODULE->name
41#endif 41#endif
42#define debug(fmt, arg...) do { if (ibmphp_debug == 1) printk(KERN_DEBUG "%s: " fmt , MY_NAME , ## arg); } while (0) 42#define debug(fmt, arg...) do { if (ibmphp_debug == 1) printk(KERN_DEBUG "%s: " fmt, MY_NAME, ## arg); } while (0)
43#define debug_pci(fmt, arg...) do { if (ibmphp_debug) printk(KERN_DEBUG "%s: " fmt , MY_NAME , ## arg); } while (0) 43#define debug_pci(fmt, arg...) do { if (ibmphp_debug) printk(KERN_DEBUG "%s: " fmt, MY_NAME, ## arg); } while (0)
44#define err(format, arg...) printk(KERN_ERR "%s: " format , MY_NAME , ## arg) 44#define err(format, arg...) printk(KERN_ERR "%s: " format, MY_NAME, ## arg)
45#define info(format, arg...) printk(KERN_INFO "%s: " format , MY_NAME , ## arg) 45#define info(format, arg...) printk(KERN_INFO "%s: " format, MY_NAME, ## arg)
46#define warn(format, arg...) printk(KERN_WARNING "%s: " format , MY_NAME , ## arg) 46#define warn(format, arg...) printk(KERN_WARNING "%s: " format, MY_NAME, ## arg)
47 47
48 48
49/* EBDA stuff */ 49/* EBDA stuff */
@@ -603,7 +603,7 @@ void ibmphp_hpc_stop_poll_thread(void);
603#define SLOT_CONNECT(s) ((u8) ((s & HPC_SLOT_CONNECT) \ 603#define SLOT_CONNECT(s) ((u8) ((s & HPC_SLOT_CONNECT) \
604 ? HPC_SLOT_DISCONNECTED : HPC_SLOT_CONNECTED)) 604 ? HPC_SLOT_DISCONNECTED : HPC_SLOT_CONNECTED))
605 605
606#define SLOT_ATTN(s,es) ((u8) ((es & HPC_SLOT_BLINK_ATTN) \ 606#define SLOT_ATTN(s, es) ((u8) ((es & HPC_SLOT_BLINK_ATTN) \
607 ? HPC_SLOT_ATTN_BLINK \ 607 ? HPC_SLOT_ATTN_BLINK \
608 : ((s & HPC_SLOT_ATTN) ? HPC_SLOT_ATTN_ON : HPC_SLOT_ATTN_OFF))) 608 : ((s & HPC_SLOT_ATTN) ? HPC_SLOT_ATTN_ON : HPC_SLOT_ATTN_OFF)))
609 609
diff --git a/drivers/pci/hotplug/ibmphp_core.c b/drivers/pci/hotplug/ibmphp_core.c
index 49adf2278c14..5efd01d84498 100644
--- a/drivers/pci/hotplug/ibmphp_core.c
+++ b/drivers/pci/hotplug/ibmphp_core.c
@@ -39,11 +39,11 @@
39#include <asm/io_apic.h> 39#include <asm/io_apic.h>
40#include "ibmphp.h" 40#include "ibmphp.h"
41 41
42#define attn_on(sl) ibmphp_hpc_writeslot (sl, HPC_SLOT_ATTNON) 42#define attn_on(sl) ibmphp_hpc_writeslot(sl, HPC_SLOT_ATTNON)
43#define attn_off(sl) ibmphp_hpc_writeslot (sl, HPC_SLOT_ATTNOFF) 43#define attn_off(sl) ibmphp_hpc_writeslot(sl, HPC_SLOT_ATTNOFF)
44#define attn_LED_blink(sl) ibmphp_hpc_writeslot (sl, HPC_SLOT_BLINKLED) 44#define attn_LED_blink(sl) ibmphp_hpc_writeslot(sl, HPC_SLOT_BLINKLED)
45#define get_ctrl_revision(sl, rev) ibmphp_hpc_readslot (sl, READ_REVLEVEL, rev) 45#define get_ctrl_revision(sl, rev) ibmphp_hpc_readslot(sl, READ_REVLEVEL, rev)
46#define get_hpc_options(sl, opt) ibmphp_hpc_readslot (sl, READ_HPCOPTIONS, opt) 46#define get_hpc_options(sl, opt) ibmphp_hpc_readslot(sl, READ_HPCOPTIONS, opt)
47 47
48#define DRIVER_VERSION "0.6" 48#define DRIVER_VERSION "0.6"
49#define DRIVER_DESC "IBM Hot Plug PCI Controller Driver" 49#define DRIVER_DESC "IBM Hot Plug PCI Controller Driver"
@@ -52,9 +52,9 @@ int ibmphp_debug;
52 52
53static bool debug; 53static bool debug;
54module_param(debug, bool, S_IRUGO | S_IWUSR); 54module_param(debug, bool, S_IRUGO | S_IWUSR);
55MODULE_PARM_DESC (debug, "Debugging mode enabled or not"); 55MODULE_PARM_DESC(debug, "Debugging mode enabled or not");
56MODULE_LICENSE ("GPL"); 56MODULE_LICENSE("GPL");
57MODULE_DESCRIPTION (DRIVER_DESC); 57MODULE_DESCRIPTION(DRIVER_DESC);
58 58
59struct pci_bus *ibmphp_pci_bus; 59struct pci_bus *ibmphp_pci_bus;
60static int max_slots; 60static int max_slots;
@@ -113,7 +113,7 @@ static inline int slot_update(struct slot **sl)
113 return rc; 113 return rc;
114} 114}
115 115
116static int __init get_max_slots (void) 116static int __init get_max_slots(void)
117{ 117{
118 struct slot *slot_cur; 118 struct slot *slot_cur;
119 u8 slot_count = 0; 119 u8 slot_count = 0;
@@ -457,7 +457,7 @@ static int get_max_adapter_speed_1(struct hotplug_slot *hotplug_slot, u8 *value,
457 *value = SLOT_SPEED(myslot.ext_status); 457 *value = SLOT_SPEED(myslot.ext_status);
458 } else 458 } else
459 *value = MAX_ADAPTER_NONE; 459 *value = MAX_ADAPTER_NONE;
460 } 460 }
461 } 461 }
462 462
463 if (flag) 463 if (flag)
@@ -612,11 +612,11 @@ int ibmphp_update_slot_info(struct slot *slot_cur)
612 info->attention_status = SLOT_ATTN(slot_cur->status, 612 info->attention_status = SLOT_ATTN(slot_cur->status,
613 slot_cur->ext_status); 613 slot_cur->ext_status);
614 info->latch_status = SLOT_LATCH(slot_cur->status); 614 info->latch_status = SLOT_LATCH(slot_cur->status);
615 if (!SLOT_PRESENT(slot_cur->status)) { 615 if (!SLOT_PRESENT(slot_cur->status)) {
616 info->adapter_status = 0; 616 info->adapter_status = 0;
617/* info->max_adapter_speed_status = MAX_ADAPTER_NONE; */ 617/* info->max_adapter_speed_status = MAX_ADAPTER_NONE; */
618 } else { 618 } else {
619 info->adapter_status = 1; 619 info->adapter_status = 1;
620/* get_max_adapter_speed_1(slot_cur->hotplug_slot, 620/* get_max_adapter_speed_1(slot_cur->hotplug_slot,
621 &info->max_adapter_speed_status, 0); */ 621 &info->max_adapter_speed_status, 0); */
622 } 622 }
@@ -854,7 +854,7 @@ static int set_bus(struct slot *slot_cur)
854 int retval; 854 int retval;
855 static struct pci_device_id ciobx[] = { 855 static struct pci_device_id ciobx[] = {
856 { PCI_DEVICE(PCI_VENDOR_ID_SERVERWORKS, 0x0101) }, 856 { PCI_DEVICE(PCI_VENDOR_ID_SERVERWORKS, 0x0101) },
857 { }, 857 { },
858 }; 858 };
859 859
860 debug("%s - entry slot # %d\n", __func__, slot_cur->number); 860 debug("%s - entry slot # %d\n", __func__, slot_cur->number);
@@ -1170,7 +1170,7 @@ error_power:
1170* HOT REMOVING ADAPTER CARD * 1170* HOT REMOVING ADAPTER CARD *
1171* INPUT: POINTER TO THE HOTPLUG SLOT STRUCTURE * 1171* INPUT: POINTER TO THE HOTPLUG SLOT STRUCTURE *
1172* OUTPUT: SUCCESS 0 ; FAILURE: UNCONFIGURE , VALIDATE * 1172* OUTPUT: SUCCESS 0 ; FAILURE: UNCONFIGURE , VALIDATE *
1173 DISABLE POWER , * 1173* DISABLE POWER , *
1174**************************************************************/ 1174**************************************************************/
1175static int ibmphp_disable_slot(struct hotplug_slot *hotplug_slot) 1175static int ibmphp_disable_slot(struct hotplug_slot *hotplug_slot)
1176{ 1176{
diff --git a/drivers/pci/hotplug/ibmphp_ebda.c b/drivers/pci/hotplug/ibmphp_ebda.c
index 664b5d1efb8f..43e345ac296b 100644
--- a/drivers/pci/hotplug/ibmphp_ebda.c
+++ b/drivers/pci/hotplug/ibmphp_ebda.c
@@ -49,32 +49,32 @@
49 */ 49 */
50 50
51/* Global lists */ 51/* Global lists */
52LIST_HEAD (ibmphp_ebda_pci_rsrc_head); 52LIST_HEAD(ibmphp_ebda_pci_rsrc_head);
53LIST_HEAD (ibmphp_slot_head); 53LIST_HEAD(ibmphp_slot_head);
54 54
55/* Local variables */ 55/* Local variables */
56static struct ebda_hpc_list *hpc_list_ptr; 56static struct ebda_hpc_list *hpc_list_ptr;
57static struct ebda_rsrc_list *rsrc_list_ptr; 57static struct ebda_rsrc_list *rsrc_list_ptr;
58static struct rio_table_hdr *rio_table_ptr = NULL; 58static struct rio_table_hdr *rio_table_ptr = NULL;
59static LIST_HEAD (ebda_hpc_head); 59static LIST_HEAD(ebda_hpc_head);
60static LIST_HEAD (bus_info_head); 60static LIST_HEAD(bus_info_head);
61static LIST_HEAD (rio_vg_head); 61static LIST_HEAD(rio_vg_head);
62static LIST_HEAD (rio_lo_head); 62static LIST_HEAD(rio_lo_head);
63static LIST_HEAD (opt_vg_head); 63static LIST_HEAD(opt_vg_head);
64static LIST_HEAD (opt_lo_head); 64static LIST_HEAD(opt_lo_head);
65static void __iomem *io_mem; 65static void __iomem *io_mem;
66 66
67/* Local functions */ 67/* Local functions */
68static int ebda_rsrc_controller (void); 68static int ebda_rsrc_controller(void);
69static int ebda_rsrc_rsrc (void); 69static int ebda_rsrc_rsrc(void);
70static int ebda_rio_table (void); 70static int ebda_rio_table(void);
71 71
72static struct ebda_hpc_list * __init alloc_ebda_hpc_list (void) 72static struct ebda_hpc_list * __init alloc_ebda_hpc_list(void)
73{ 73{
74 return kzalloc(sizeof(struct ebda_hpc_list), GFP_KERNEL); 74 return kzalloc(sizeof(struct ebda_hpc_list), GFP_KERNEL);
75} 75}
76 76
77static struct controller *alloc_ebda_hpc (u32 slot_count, u32 bus_count) 77static struct controller *alloc_ebda_hpc(u32 slot_count, u32 bus_count)
78{ 78{
79 struct controller *controller; 79 struct controller *controller;
80 struct ebda_hpc_slot *slots; 80 struct ebda_hpc_slot *slots;
@@ -103,146 +103,146 @@ error:
103 return NULL; 103 return NULL;
104} 104}
105 105
106static void free_ebda_hpc (struct controller *controller) 106static void free_ebda_hpc(struct controller *controller)
107{ 107{
108 kfree (controller->slots); 108 kfree(controller->slots);
109 kfree (controller->buses); 109 kfree(controller->buses);
110 kfree (controller); 110 kfree(controller);
111} 111}
112 112
113static struct ebda_rsrc_list * __init alloc_ebda_rsrc_list (void) 113static struct ebda_rsrc_list * __init alloc_ebda_rsrc_list(void)
114{ 114{
115 return kzalloc(sizeof(struct ebda_rsrc_list), GFP_KERNEL); 115 return kzalloc(sizeof(struct ebda_rsrc_list), GFP_KERNEL);
116} 116}
117 117
118static struct ebda_pci_rsrc *alloc_ebda_pci_rsrc (void) 118static struct ebda_pci_rsrc *alloc_ebda_pci_rsrc(void)
119{ 119{
120 return kzalloc(sizeof(struct ebda_pci_rsrc), GFP_KERNEL); 120 return kzalloc(sizeof(struct ebda_pci_rsrc), GFP_KERNEL);
121} 121}
122 122
123static void __init print_bus_info (void) 123static void __init print_bus_info(void)
124{ 124{
125 struct bus_info *ptr; 125 struct bus_info *ptr;
126 126
127 list_for_each_entry(ptr, &bus_info_head, bus_info_list) { 127 list_for_each_entry(ptr, &bus_info_head, bus_info_list) {
128 debug ("%s - slot_min = %x\n", __func__, ptr->slot_min); 128 debug("%s - slot_min = %x\n", __func__, ptr->slot_min);
129 debug ("%s - slot_max = %x\n", __func__, ptr->slot_max); 129 debug("%s - slot_max = %x\n", __func__, ptr->slot_max);
130 debug ("%s - slot_count = %x\n", __func__, ptr->slot_count); 130 debug("%s - slot_count = %x\n", __func__, ptr->slot_count);
131 debug ("%s - bus# = %x\n", __func__, ptr->busno); 131 debug("%s - bus# = %x\n", __func__, ptr->busno);
132 debug ("%s - current_speed = %x\n", __func__, ptr->current_speed); 132 debug("%s - current_speed = %x\n", __func__, ptr->current_speed);
133 debug ("%s - controller_id = %x\n", __func__, ptr->controller_id); 133 debug("%s - controller_id = %x\n", __func__, ptr->controller_id);
134 134
135 debug ("%s - slots_at_33_conv = %x\n", __func__, ptr->slots_at_33_conv); 135 debug("%s - slots_at_33_conv = %x\n", __func__, ptr->slots_at_33_conv);
136 debug ("%s - slots_at_66_conv = %x\n", __func__, ptr->slots_at_66_conv); 136 debug("%s - slots_at_66_conv = %x\n", __func__, ptr->slots_at_66_conv);
137 debug ("%s - slots_at_66_pcix = %x\n", __func__, ptr->slots_at_66_pcix); 137 debug("%s - slots_at_66_pcix = %x\n", __func__, ptr->slots_at_66_pcix);
138 debug ("%s - slots_at_100_pcix = %x\n", __func__, ptr->slots_at_100_pcix); 138 debug("%s - slots_at_100_pcix = %x\n", __func__, ptr->slots_at_100_pcix);
139 debug ("%s - slots_at_133_pcix = %x\n", __func__, ptr->slots_at_133_pcix); 139 debug("%s - slots_at_133_pcix = %x\n", __func__, ptr->slots_at_133_pcix);
140 140
141 } 141 }
142} 142}
143 143
144static void print_lo_info (void) 144static void print_lo_info(void)
145{ 145{
146 struct rio_detail *ptr; 146 struct rio_detail *ptr;
147 debug ("print_lo_info ----\n"); 147 debug("print_lo_info ----\n");
148 list_for_each_entry(ptr, &rio_lo_head, rio_detail_list) { 148 list_for_each_entry(ptr, &rio_lo_head, rio_detail_list) {
149 debug ("%s - rio_node_id = %x\n", __func__, ptr->rio_node_id); 149 debug("%s - rio_node_id = %x\n", __func__, ptr->rio_node_id);
150 debug ("%s - rio_type = %x\n", __func__, ptr->rio_type); 150 debug("%s - rio_type = %x\n", __func__, ptr->rio_type);
151 debug ("%s - owner_id = %x\n", __func__, ptr->owner_id); 151 debug("%s - owner_id = %x\n", __func__, ptr->owner_id);
152 debug ("%s - first_slot_num = %x\n", __func__, ptr->first_slot_num); 152 debug("%s - first_slot_num = %x\n", __func__, ptr->first_slot_num);
153 debug ("%s - wpindex = %x\n", __func__, ptr->wpindex); 153 debug("%s - wpindex = %x\n", __func__, ptr->wpindex);
154 debug ("%s - chassis_num = %x\n", __func__, ptr->chassis_num); 154 debug("%s - chassis_num = %x\n", __func__, ptr->chassis_num);
155 155
156 } 156 }
157} 157}
158 158
159static void print_vg_info (void) 159static void print_vg_info(void)
160{ 160{
161 struct rio_detail *ptr; 161 struct rio_detail *ptr;
162 debug ("%s ---\n", __func__); 162 debug("%s ---\n", __func__);
163 list_for_each_entry(ptr, &rio_vg_head, rio_detail_list) { 163 list_for_each_entry(ptr, &rio_vg_head, rio_detail_list) {
164 debug ("%s - rio_node_id = %x\n", __func__, ptr->rio_node_id); 164 debug("%s - rio_node_id = %x\n", __func__, ptr->rio_node_id);
165 debug ("%s - rio_type = %x\n", __func__, ptr->rio_type); 165 debug("%s - rio_type = %x\n", __func__, ptr->rio_type);
166 debug ("%s - owner_id = %x\n", __func__, ptr->owner_id); 166 debug("%s - owner_id = %x\n", __func__, ptr->owner_id);
167 debug ("%s - first_slot_num = %x\n", __func__, ptr->first_slot_num); 167 debug("%s - first_slot_num = %x\n", __func__, ptr->first_slot_num);
168 debug ("%s - wpindex = %x\n", __func__, ptr->wpindex); 168 debug("%s - wpindex = %x\n", __func__, ptr->wpindex);
169 debug ("%s - chassis_num = %x\n", __func__, ptr->chassis_num); 169 debug("%s - chassis_num = %x\n", __func__, ptr->chassis_num);
170 170
171 } 171 }
172} 172}
173 173
174static void __init print_ebda_pci_rsrc (void) 174static void __init print_ebda_pci_rsrc(void)
175{ 175{
176 struct ebda_pci_rsrc *ptr; 176 struct ebda_pci_rsrc *ptr;
177 177
178 list_for_each_entry(ptr, &ibmphp_ebda_pci_rsrc_head, ebda_pci_rsrc_list) { 178 list_for_each_entry(ptr, &ibmphp_ebda_pci_rsrc_head, ebda_pci_rsrc_list) {
179 debug ("%s - rsrc type: %x bus#: %x dev_func: %x start addr: %x end addr: %x\n", 179 debug("%s - rsrc type: %x bus#: %x dev_func: %x start addr: %x end addr: %x\n",
180 __func__, ptr->rsrc_type ,ptr->bus_num, ptr->dev_fun,ptr->start_addr, ptr->end_addr); 180 __func__, ptr->rsrc_type, ptr->bus_num, ptr->dev_fun, ptr->start_addr, ptr->end_addr);
181 } 181 }
182} 182}
183 183
184static void __init print_ibm_slot (void) 184static void __init print_ibm_slot(void)
185{ 185{
186 struct slot *ptr; 186 struct slot *ptr;
187 187
188 list_for_each_entry(ptr, &ibmphp_slot_head, ibm_slot_list) { 188 list_for_each_entry(ptr, &ibmphp_slot_head, ibm_slot_list) {
189 debug ("%s - slot_number: %x\n", __func__, ptr->number); 189 debug("%s - slot_number: %x\n", __func__, ptr->number);
190 } 190 }
191} 191}
192 192
193static void __init print_opt_vg (void) 193static void __init print_opt_vg(void)
194{ 194{
195 struct opt_rio *ptr; 195 struct opt_rio *ptr;
196 debug ("%s ---\n", __func__); 196 debug("%s ---\n", __func__);
197 list_for_each_entry(ptr, &opt_vg_head, opt_rio_list) { 197 list_for_each_entry(ptr, &opt_vg_head, opt_rio_list) {
198 debug ("%s - rio_type %x\n", __func__, ptr->rio_type); 198 debug("%s - rio_type %x\n", __func__, ptr->rio_type);
199 debug ("%s - chassis_num: %x\n", __func__, ptr->chassis_num); 199 debug("%s - chassis_num: %x\n", __func__, ptr->chassis_num);
200 debug ("%s - first_slot_num: %x\n", __func__, ptr->first_slot_num); 200 debug("%s - first_slot_num: %x\n", __func__, ptr->first_slot_num);
201 debug ("%s - middle_num: %x\n", __func__, ptr->middle_num); 201 debug("%s - middle_num: %x\n", __func__, ptr->middle_num);
202 } 202 }
203} 203}
204 204
205static void __init print_ebda_hpc (void) 205static void __init print_ebda_hpc(void)
206{ 206{
207 struct controller *hpc_ptr; 207 struct controller *hpc_ptr;
208 u16 index; 208 u16 index;
209 209
210 list_for_each_entry(hpc_ptr, &ebda_hpc_head, ebda_hpc_list) { 210 list_for_each_entry(hpc_ptr, &ebda_hpc_head, ebda_hpc_list) {
211 for (index = 0; index < hpc_ptr->slot_count; index++) { 211 for (index = 0; index < hpc_ptr->slot_count; index++) {
212 debug ("%s - physical slot#: %x\n", __func__, hpc_ptr->slots[index].slot_num); 212 debug("%s - physical slot#: %x\n", __func__, hpc_ptr->slots[index].slot_num);
213 debug ("%s - pci bus# of the slot: %x\n", __func__, hpc_ptr->slots[index].slot_bus_num); 213 debug("%s - pci bus# of the slot: %x\n", __func__, hpc_ptr->slots[index].slot_bus_num);
214 debug ("%s - index into ctlr addr: %x\n", __func__, hpc_ptr->slots[index].ctl_index); 214 debug("%s - index into ctlr addr: %x\n", __func__, hpc_ptr->slots[index].ctl_index);
215 debug ("%s - cap of the slot: %x\n", __func__, hpc_ptr->slots[index].slot_cap); 215 debug("%s - cap of the slot: %x\n", __func__, hpc_ptr->slots[index].slot_cap);
216 } 216 }
217 217
218 for (index = 0; index < hpc_ptr->bus_count; index++) 218 for (index = 0; index < hpc_ptr->bus_count; index++)
219 debug ("%s - bus# of each bus controlled by this ctlr: %x\n", __func__, hpc_ptr->buses[index].bus_num); 219 debug("%s - bus# of each bus controlled by this ctlr: %x\n", __func__, hpc_ptr->buses[index].bus_num);
220 220
221 debug ("%s - type of hpc: %x\n", __func__, hpc_ptr->ctlr_type); 221 debug("%s - type of hpc: %x\n", __func__, hpc_ptr->ctlr_type);
222 switch (hpc_ptr->ctlr_type) { 222 switch (hpc_ptr->ctlr_type) {
223 case 1: 223 case 1:
224 debug ("%s - bus: %x\n", __func__, hpc_ptr->u.pci_ctlr.bus); 224 debug("%s - bus: %x\n", __func__, hpc_ptr->u.pci_ctlr.bus);
225 debug ("%s - dev_fun: %x\n", __func__, hpc_ptr->u.pci_ctlr.dev_fun); 225 debug("%s - dev_fun: %x\n", __func__, hpc_ptr->u.pci_ctlr.dev_fun);
226 debug ("%s - irq: %x\n", __func__, hpc_ptr->irq); 226 debug("%s - irq: %x\n", __func__, hpc_ptr->irq);
227 break; 227 break;
228 228
229 case 0: 229 case 0:
230 debug ("%s - io_start: %x\n", __func__, hpc_ptr->u.isa_ctlr.io_start); 230 debug("%s - io_start: %x\n", __func__, hpc_ptr->u.isa_ctlr.io_start);
231 debug ("%s - io_end: %x\n", __func__, hpc_ptr->u.isa_ctlr.io_end); 231 debug("%s - io_end: %x\n", __func__, hpc_ptr->u.isa_ctlr.io_end);
232 debug ("%s - irq: %x\n", __func__, hpc_ptr->irq); 232 debug("%s - irq: %x\n", __func__, hpc_ptr->irq);
233 break; 233 break;
234 234
235 case 2: 235 case 2:
236 case 4: 236 case 4:
237 debug ("%s - wpegbbar: %lx\n", __func__, hpc_ptr->u.wpeg_ctlr.wpegbbar); 237 debug("%s - wpegbbar: %lx\n", __func__, hpc_ptr->u.wpeg_ctlr.wpegbbar);
238 debug ("%s - i2c_addr: %x\n", __func__, hpc_ptr->u.wpeg_ctlr.i2c_addr); 238 debug("%s - i2c_addr: %x\n", __func__, hpc_ptr->u.wpeg_ctlr.i2c_addr);
239 debug ("%s - irq: %x\n", __func__, hpc_ptr->irq); 239 debug("%s - irq: %x\n", __func__, hpc_ptr->irq);
240 break; 240 break;
241 } 241 }
242 } 242 }
243} 243}
244 244
245int __init ibmphp_access_ebda (void) 245int __init ibmphp_access_ebda(void)
246{ 246{
247 u8 format, num_ctlrs, rio_complete, hs_complete, ebda_sz; 247 u8 format, num_ctlrs, rio_complete, hs_complete, ebda_sz;
248 u16 ebda_seg, num_entries, next_offset, offset, blk_id, sub_addr, re, rc_id, re_id, base; 248 u16 ebda_seg, num_entries, next_offset, offset, blk_id, sub_addr, re, rc_id, re_id, base;
@@ -252,12 +252,12 @@ int __init ibmphp_access_ebda (void)
252 rio_complete = 0; 252 rio_complete = 0;
253 hs_complete = 0; 253 hs_complete = 0;
254 254
255 io_mem = ioremap ((0x40 << 4) + 0x0e, 2); 255 io_mem = ioremap((0x40 << 4) + 0x0e, 2);
256 if (!io_mem ) 256 if (!io_mem)
257 return -ENOMEM; 257 return -ENOMEM;
258 ebda_seg = readw (io_mem); 258 ebda_seg = readw(io_mem);
259 iounmap (io_mem); 259 iounmap(io_mem);
260 debug ("returned ebda segment: %x\n", ebda_seg); 260 debug("returned ebda segment: %x\n", ebda_seg);
261 261
262 io_mem = ioremap(ebda_seg<<4, 1); 262 io_mem = ioremap(ebda_seg<<4, 1);
263 if (!io_mem) 263 if (!io_mem)
@@ -269,7 +269,7 @@ int __init ibmphp_access_ebda (void)
269 return -ENOMEM; 269 return -ENOMEM;
270 270
271 io_mem = ioremap(ebda_seg<<4, (ebda_sz * 1024)); 271 io_mem = ioremap(ebda_seg<<4, (ebda_sz * 1024));
272 if (!io_mem ) 272 if (!io_mem)
273 return -ENOMEM; 273 return -ENOMEM;
274 next_offset = 0x180; 274 next_offset = 0x180;
275 275
@@ -281,12 +281,12 @@ int __init ibmphp_access_ebda (void)
281 "ibmphp_ebda: next read is beyond ebda_sz\n")) 281 "ibmphp_ebda: next read is beyond ebda_sz\n"))
282 break; 282 break;
283 283
284 next_offset = readw (io_mem + offset); /* offset of next blk */ 284 next_offset = readw(io_mem + offset); /* offset of next blk */
285 285
286 offset += 2; 286 offset += 2;
287 if (next_offset == 0) /* 0 indicate it's last blk */ 287 if (next_offset == 0) /* 0 indicate it's last blk */
288 break; 288 break;
289 blk_id = readw (io_mem + offset); /* this blk id */ 289 blk_id = readw(io_mem + offset); /* this blk id */
290 290
291 offset += 2; 291 offset += 2;
292 /* check if it is hot swap block or rio block */ 292 /* check if it is hot swap block or rio block */
@@ -294,31 +294,31 @@ int __init ibmphp_access_ebda (void)
294 continue; 294 continue;
295 /* found hs table */ 295 /* found hs table */
296 if (blk_id == 0x4853) { 296 if (blk_id == 0x4853) {
297 debug ("now enter hot swap block---\n"); 297 debug("now enter hot swap block---\n");
298 debug ("hot blk id: %x\n", blk_id); 298 debug("hot blk id: %x\n", blk_id);
299 format = readb (io_mem + offset); 299 format = readb(io_mem + offset);
300 300
301 offset += 1; 301 offset += 1;
302 if (format != 4) 302 if (format != 4)
303 goto error_nodev; 303 goto error_nodev;
304 debug ("hot blk format: %x\n", format); 304 debug("hot blk format: %x\n", format);
305 /* hot swap sub blk */ 305 /* hot swap sub blk */
306 base = offset; 306 base = offset;
307 307
308 sub_addr = base; 308 sub_addr = base;
309 re = readw (io_mem + sub_addr); /* next sub blk */ 309 re = readw(io_mem + sub_addr); /* next sub blk */
310 310
311 sub_addr += 2; 311 sub_addr += 2;
312 rc_id = readw (io_mem + sub_addr); /* sub blk id */ 312 rc_id = readw(io_mem + sub_addr); /* sub blk id */
313 313
314 sub_addr += 2; 314 sub_addr += 2;
315 if (rc_id != 0x5243) 315 if (rc_id != 0x5243)
316 goto error_nodev; 316 goto error_nodev;
317 /* rc sub blk signature */ 317 /* rc sub blk signature */
318 num_ctlrs = readb (io_mem + sub_addr); 318 num_ctlrs = readb(io_mem + sub_addr);
319 319
320 sub_addr += 1; 320 sub_addr += 1;
321 hpc_list_ptr = alloc_ebda_hpc_list (); 321 hpc_list_ptr = alloc_ebda_hpc_list();
322 if (!hpc_list_ptr) { 322 if (!hpc_list_ptr) {
323 rc = -ENOMEM; 323 rc = -ENOMEM;
324 goto out; 324 goto out;
@@ -326,28 +326,28 @@ int __init ibmphp_access_ebda (void)
326 hpc_list_ptr->format = format; 326 hpc_list_ptr->format = format;
327 hpc_list_ptr->num_ctlrs = num_ctlrs; 327 hpc_list_ptr->num_ctlrs = num_ctlrs;
328 hpc_list_ptr->phys_addr = sub_addr; /* offset of RSRC_CONTROLLER blk */ 328 hpc_list_ptr->phys_addr = sub_addr; /* offset of RSRC_CONTROLLER blk */
329 debug ("info about hpc descriptor---\n"); 329 debug("info about hpc descriptor---\n");
330 debug ("hot blk format: %x\n", format); 330 debug("hot blk format: %x\n", format);
331 debug ("num of controller: %x\n", num_ctlrs); 331 debug("num of controller: %x\n", num_ctlrs);
332 debug ("offset of hpc data structure entries: %x\n ", sub_addr); 332 debug("offset of hpc data structure entries: %x\n ", sub_addr);
333 333
334 sub_addr = base + re; /* re sub blk */ 334 sub_addr = base + re; /* re sub blk */
335 /* FIXME: rc is never used/checked */ 335 /* FIXME: rc is never used/checked */
336 rc = readw (io_mem + sub_addr); /* next sub blk */ 336 rc = readw(io_mem + sub_addr); /* next sub blk */
337 337
338 sub_addr += 2; 338 sub_addr += 2;
339 re_id = readw (io_mem + sub_addr); /* sub blk id */ 339 re_id = readw(io_mem + sub_addr); /* sub blk id */
340 340
341 sub_addr += 2; 341 sub_addr += 2;
342 if (re_id != 0x5245) 342 if (re_id != 0x5245)
343 goto error_nodev; 343 goto error_nodev;
344 344
345 /* signature of re */ 345 /* signature of re */
346 num_entries = readw (io_mem + sub_addr); 346 num_entries = readw(io_mem + sub_addr);
347 347
348 sub_addr += 2; /* offset of RSRC_ENTRIES blk */ 348 sub_addr += 2; /* offset of RSRC_ENTRIES blk */
349 rsrc_list_ptr = alloc_ebda_rsrc_list (); 349 rsrc_list_ptr = alloc_ebda_rsrc_list();
350 if (!rsrc_list_ptr ) { 350 if (!rsrc_list_ptr) {
351 rc = -ENOMEM; 351 rc = -ENOMEM;
352 goto out; 352 goto out;
353 } 353 }
@@ -355,26 +355,26 @@ int __init ibmphp_access_ebda (void)
355 rsrc_list_ptr->num_entries = num_entries; 355 rsrc_list_ptr->num_entries = num_entries;
356 rsrc_list_ptr->phys_addr = sub_addr; 356 rsrc_list_ptr->phys_addr = sub_addr;
357 357
358 debug ("info about rsrc descriptor---\n"); 358 debug("info about rsrc descriptor---\n");
359 debug ("format: %x\n", format); 359 debug("format: %x\n", format);
360 debug ("num of rsrc: %x\n", num_entries); 360 debug("num of rsrc: %x\n", num_entries);
361 debug ("offset of rsrc data structure entries: %x\n ", sub_addr); 361 debug("offset of rsrc data structure entries: %x\n ", sub_addr);
362 362
363 hs_complete = 1; 363 hs_complete = 1;
364 } else { 364 } else {
365 /* found rio table, blk_id == 0x4752 */ 365 /* found rio table, blk_id == 0x4752 */
366 debug ("now enter io table ---\n"); 366 debug("now enter io table ---\n");
367 debug ("rio blk id: %x\n", blk_id); 367 debug("rio blk id: %x\n", blk_id);
368 368
369 rio_table_ptr = kzalloc(sizeof(struct rio_table_hdr), GFP_KERNEL); 369 rio_table_ptr = kzalloc(sizeof(struct rio_table_hdr), GFP_KERNEL);
370 if (!rio_table_ptr) { 370 if (!rio_table_ptr) {
371 rc = -ENOMEM; 371 rc = -ENOMEM;
372 goto out; 372 goto out;
373 } 373 }
374 rio_table_ptr->ver_num = readb (io_mem + offset); 374 rio_table_ptr->ver_num = readb(io_mem + offset);
375 rio_table_ptr->scal_count = readb (io_mem + offset + 1); 375 rio_table_ptr->scal_count = readb(io_mem + offset + 1);
376 rio_table_ptr->riodev_count = readb (io_mem + offset + 2); 376 rio_table_ptr->riodev_count = readb(io_mem + offset + 2);
377 rio_table_ptr->offset = offset +3 ; 377 rio_table_ptr->offset = offset + 3 ;
378 378
379 debug("info about rio table hdr ---\n"); 379 debug("info about rio table hdr ---\n");
380 debug("ver_num: %x\nscal_count: %x\nriodev_count: %x\noffset of rio table: %x\n ", 380 debug("ver_num: %x\nscal_count: %x\nriodev_count: %x\noffset of rio table: %x\n ",
@@ -390,28 +390,28 @@ int __init ibmphp_access_ebda (void)
390 390
391 if (rio_table_ptr) { 391 if (rio_table_ptr) {
392 if (rio_complete && rio_table_ptr->ver_num == 3) { 392 if (rio_complete && rio_table_ptr->ver_num == 3) {
393 rc = ebda_rio_table (); 393 rc = ebda_rio_table();
394 if (rc) 394 if (rc)
395 goto out; 395 goto out;
396 } 396 }
397 } 397 }
398 rc = ebda_rsrc_controller (); 398 rc = ebda_rsrc_controller();
399 if (rc) 399 if (rc)
400 goto out; 400 goto out;
401 401
402 rc = ebda_rsrc_rsrc (); 402 rc = ebda_rsrc_rsrc();
403 goto out; 403 goto out;
404error_nodev: 404error_nodev:
405 rc = -ENODEV; 405 rc = -ENODEV;
406out: 406out:
407 iounmap (io_mem); 407 iounmap(io_mem);
408 return rc; 408 return rc;
409} 409}
410 410
411/* 411/*
412 * map info of scalability details and rio details from physical address 412 * map info of scalability details and rio details from physical address
413 */ 413 */
414static int __init ebda_rio_table (void) 414static int __init ebda_rio_table(void)
415{ 415{
416 u16 offset; 416 u16 offset;
417 u8 i; 417 u8 i;
@@ -425,39 +425,39 @@ static int __init ebda_rio_table (void)
425 rio_detail_ptr = kzalloc(sizeof(struct rio_detail), GFP_KERNEL); 425 rio_detail_ptr = kzalloc(sizeof(struct rio_detail), GFP_KERNEL);
426 if (!rio_detail_ptr) 426 if (!rio_detail_ptr)
427 return -ENOMEM; 427 return -ENOMEM;
428 rio_detail_ptr->rio_node_id = readb (io_mem + offset); 428 rio_detail_ptr->rio_node_id = readb(io_mem + offset);
429 rio_detail_ptr->bbar = readl (io_mem + offset + 1); 429 rio_detail_ptr->bbar = readl(io_mem + offset + 1);
430 rio_detail_ptr->rio_type = readb (io_mem + offset + 5); 430 rio_detail_ptr->rio_type = readb(io_mem + offset + 5);
431 rio_detail_ptr->owner_id = readb (io_mem + offset + 6); 431 rio_detail_ptr->owner_id = readb(io_mem + offset + 6);
432 rio_detail_ptr->port0_node_connect = readb (io_mem + offset + 7); 432 rio_detail_ptr->port0_node_connect = readb(io_mem + offset + 7);
433 rio_detail_ptr->port0_port_connect = readb (io_mem + offset + 8); 433 rio_detail_ptr->port0_port_connect = readb(io_mem + offset + 8);
434 rio_detail_ptr->port1_node_connect = readb (io_mem + offset + 9); 434 rio_detail_ptr->port1_node_connect = readb(io_mem + offset + 9);
435 rio_detail_ptr->port1_port_connect = readb (io_mem + offset + 10); 435 rio_detail_ptr->port1_port_connect = readb(io_mem + offset + 10);
436 rio_detail_ptr->first_slot_num = readb (io_mem + offset + 11); 436 rio_detail_ptr->first_slot_num = readb(io_mem + offset + 11);
437 rio_detail_ptr->status = readb (io_mem + offset + 12); 437 rio_detail_ptr->status = readb(io_mem + offset + 12);
438 rio_detail_ptr->wpindex = readb (io_mem + offset + 13); 438 rio_detail_ptr->wpindex = readb(io_mem + offset + 13);
439 rio_detail_ptr->chassis_num = readb (io_mem + offset + 14); 439 rio_detail_ptr->chassis_num = readb(io_mem + offset + 14);
440// debug ("rio_node_id: %x\nbbar: %x\nrio_type: %x\nowner_id: %x\nport0_node: %x\nport0_port: %x\nport1_node: %x\nport1_port: %x\nfirst_slot_num: %x\nstatus: %x\n", rio_detail_ptr->rio_node_id, rio_detail_ptr->bbar, rio_detail_ptr->rio_type, rio_detail_ptr->owner_id, rio_detail_ptr->port0_node_connect, rio_detail_ptr->port0_port_connect, rio_detail_ptr->port1_node_connect, rio_detail_ptr->port1_port_connect, rio_detail_ptr->first_slot_num, rio_detail_ptr->status); 440// debug("rio_node_id: %x\nbbar: %x\nrio_type: %x\nowner_id: %x\nport0_node: %x\nport0_port: %x\nport1_node: %x\nport1_port: %x\nfirst_slot_num: %x\nstatus: %x\n", rio_detail_ptr->rio_node_id, rio_detail_ptr->bbar, rio_detail_ptr->rio_type, rio_detail_ptr->owner_id, rio_detail_ptr->port0_node_connect, rio_detail_ptr->port0_port_connect, rio_detail_ptr->port1_node_connect, rio_detail_ptr->port1_port_connect, rio_detail_ptr->first_slot_num, rio_detail_ptr->status);
441 //create linked list of chassis 441 //create linked list of chassis
442 if (rio_detail_ptr->rio_type == 4 || rio_detail_ptr->rio_type == 5) 442 if (rio_detail_ptr->rio_type == 4 || rio_detail_ptr->rio_type == 5)
443 list_add (&rio_detail_ptr->rio_detail_list, &rio_vg_head); 443 list_add(&rio_detail_ptr->rio_detail_list, &rio_vg_head);
444 //create linked list of expansion box 444 //create linked list of expansion box
445 else if (rio_detail_ptr->rio_type == 6 || rio_detail_ptr->rio_type == 7) 445 else if (rio_detail_ptr->rio_type == 6 || rio_detail_ptr->rio_type == 7)
446 list_add (&rio_detail_ptr->rio_detail_list, &rio_lo_head); 446 list_add(&rio_detail_ptr->rio_detail_list, &rio_lo_head);
447 else 447 else
448 // not in my concern 448 // not in my concern
449 kfree (rio_detail_ptr); 449 kfree(rio_detail_ptr);
450 offset += 15; 450 offset += 15;
451 } 451 }
452 print_lo_info (); 452 print_lo_info();
453 print_vg_info (); 453 print_vg_info();
454 return 0; 454 return 0;
455} 455}
456 456
457/* 457/*
458 * reorganizing linked list of chassis 458 * reorganizing linked list of chassis
459 */ 459 */
460static struct opt_rio *search_opt_vg (u8 chassis_num) 460static struct opt_rio *search_opt_vg(u8 chassis_num)
461{ 461{
462 struct opt_rio *ptr; 462 struct opt_rio *ptr;
463 list_for_each_entry(ptr, &opt_vg_head, opt_rio_list) { 463 list_for_each_entry(ptr, &opt_vg_head, opt_rio_list) {
@@ -467,13 +467,13 @@ static struct opt_rio *search_opt_vg (u8 chassis_num)
467 return NULL; 467 return NULL;
468} 468}
469 469
470static int __init combine_wpg_for_chassis (void) 470static int __init combine_wpg_for_chassis(void)
471{ 471{
472 struct opt_rio *opt_rio_ptr = NULL; 472 struct opt_rio *opt_rio_ptr = NULL;
473 struct rio_detail *rio_detail_ptr = NULL; 473 struct rio_detail *rio_detail_ptr = NULL;
474 474
475 list_for_each_entry(rio_detail_ptr, &rio_vg_head, rio_detail_list) { 475 list_for_each_entry(rio_detail_ptr, &rio_vg_head, rio_detail_list) {
476 opt_rio_ptr = search_opt_vg (rio_detail_ptr->chassis_num); 476 opt_rio_ptr = search_opt_vg(rio_detail_ptr->chassis_num);
477 if (!opt_rio_ptr) { 477 if (!opt_rio_ptr) {
478 opt_rio_ptr = kzalloc(sizeof(struct opt_rio), GFP_KERNEL); 478 opt_rio_ptr = kzalloc(sizeof(struct opt_rio), GFP_KERNEL);
479 if (!opt_rio_ptr) 479 if (!opt_rio_ptr)
@@ -482,20 +482,20 @@ static int __init combine_wpg_for_chassis (void)
482 opt_rio_ptr->chassis_num = rio_detail_ptr->chassis_num; 482 opt_rio_ptr->chassis_num = rio_detail_ptr->chassis_num;
483 opt_rio_ptr->first_slot_num = rio_detail_ptr->first_slot_num; 483 opt_rio_ptr->first_slot_num = rio_detail_ptr->first_slot_num;
484 opt_rio_ptr->middle_num = rio_detail_ptr->first_slot_num; 484 opt_rio_ptr->middle_num = rio_detail_ptr->first_slot_num;
485 list_add (&opt_rio_ptr->opt_rio_list, &opt_vg_head); 485 list_add(&opt_rio_ptr->opt_rio_list, &opt_vg_head);
486 } else { 486 } else {
487 opt_rio_ptr->first_slot_num = min (opt_rio_ptr->first_slot_num, rio_detail_ptr->first_slot_num); 487 opt_rio_ptr->first_slot_num = min(opt_rio_ptr->first_slot_num, rio_detail_ptr->first_slot_num);
488 opt_rio_ptr->middle_num = max (opt_rio_ptr->middle_num, rio_detail_ptr->first_slot_num); 488 opt_rio_ptr->middle_num = max(opt_rio_ptr->middle_num, rio_detail_ptr->first_slot_num);
489 } 489 }
490 } 490 }
491 print_opt_vg (); 491 print_opt_vg();
492 return 0; 492 return 0;
493} 493}
494 494
495/* 495/*
496 * reorganizing linked list of expansion box 496 * reorganizing linked list of expansion box
497 */ 497 */
498static struct opt_rio_lo *search_opt_lo (u8 chassis_num) 498static struct opt_rio_lo *search_opt_lo(u8 chassis_num)
499{ 499{
500 struct opt_rio_lo *ptr; 500 struct opt_rio_lo *ptr;
501 list_for_each_entry(ptr, &opt_lo_head, opt_rio_lo_list) { 501 list_for_each_entry(ptr, &opt_lo_head, opt_rio_lo_list) {
@@ -505,13 +505,13 @@ static struct opt_rio_lo *search_opt_lo (u8 chassis_num)
505 return NULL; 505 return NULL;
506} 506}
507 507
508static int combine_wpg_for_expansion (void) 508static int combine_wpg_for_expansion(void)
509{ 509{
510 struct opt_rio_lo *opt_rio_lo_ptr = NULL; 510 struct opt_rio_lo *opt_rio_lo_ptr = NULL;
511 struct rio_detail *rio_detail_ptr = NULL; 511 struct rio_detail *rio_detail_ptr = NULL;
512 512
513 list_for_each_entry(rio_detail_ptr, &rio_lo_head, rio_detail_list) { 513 list_for_each_entry(rio_detail_ptr, &rio_lo_head, rio_detail_list) {
514 opt_rio_lo_ptr = search_opt_lo (rio_detail_ptr->chassis_num); 514 opt_rio_lo_ptr = search_opt_lo(rio_detail_ptr->chassis_num);
515 if (!opt_rio_lo_ptr) { 515 if (!opt_rio_lo_ptr) {
516 opt_rio_lo_ptr = kzalloc(sizeof(struct opt_rio_lo), GFP_KERNEL); 516 opt_rio_lo_ptr = kzalloc(sizeof(struct opt_rio_lo), GFP_KERNEL);
517 if (!opt_rio_lo_ptr) 517 if (!opt_rio_lo_ptr)
@@ -522,10 +522,10 @@ static int combine_wpg_for_expansion (void)
522 opt_rio_lo_ptr->middle_num = rio_detail_ptr->first_slot_num; 522 opt_rio_lo_ptr->middle_num = rio_detail_ptr->first_slot_num;
523 opt_rio_lo_ptr->pack_count = 1; 523 opt_rio_lo_ptr->pack_count = 1;
524 524
525 list_add (&opt_rio_lo_ptr->opt_rio_lo_list, &opt_lo_head); 525 list_add(&opt_rio_lo_ptr->opt_rio_lo_list, &opt_lo_head);
526 } else { 526 } else {
527 opt_rio_lo_ptr->first_slot_num = min (opt_rio_lo_ptr->first_slot_num, rio_detail_ptr->first_slot_num); 527 opt_rio_lo_ptr->first_slot_num = min(opt_rio_lo_ptr->first_slot_num, rio_detail_ptr->first_slot_num);
528 opt_rio_lo_ptr->middle_num = max (opt_rio_lo_ptr->middle_num, rio_detail_ptr->first_slot_num); 528 opt_rio_lo_ptr->middle_num = max(opt_rio_lo_ptr->middle_num, rio_detail_ptr->first_slot_num);
529 opt_rio_lo_ptr->pack_count = 2; 529 opt_rio_lo_ptr->pack_count = 2;
530 } 530 }
531 } 531 }
@@ -538,7 +538,7 @@ static int combine_wpg_for_expansion (void)
538 * Arguments: slot_num, 1st slot number of the chassis we think we are on, 538 * Arguments: slot_num, 1st slot number of the chassis we think we are on,
539 * var (0 = chassis, 1 = expansion box) 539 * var (0 = chassis, 1 = expansion box)
540 */ 540 */
541static int first_slot_num (u8 slot_num, u8 first_slot, u8 var) 541static int first_slot_num(u8 slot_num, u8 first_slot, u8 var)
542{ 542{
543 struct opt_rio *opt_vg_ptr = NULL; 543 struct opt_rio *opt_vg_ptr = NULL;
544 struct opt_rio_lo *opt_lo_ptr = NULL; 544 struct opt_rio_lo *opt_lo_ptr = NULL;
@@ -562,25 +562,25 @@ static int first_slot_num (u8 slot_num, u8 first_slot, u8 var)
562 return rc; 562 return rc;
563} 563}
564 564
565static struct opt_rio_lo *find_rxe_num (u8 slot_num) 565static struct opt_rio_lo *find_rxe_num(u8 slot_num)
566{ 566{
567 struct opt_rio_lo *opt_lo_ptr; 567 struct opt_rio_lo *opt_lo_ptr;
568 568
569 list_for_each_entry(opt_lo_ptr, &opt_lo_head, opt_rio_lo_list) { 569 list_for_each_entry(opt_lo_ptr, &opt_lo_head, opt_rio_lo_list) {
570 //check to see if this slot_num belongs to expansion box 570 //check to see if this slot_num belongs to expansion box
571 if ((slot_num >= opt_lo_ptr->first_slot_num) && (!first_slot_num (slot_num, opt_lo_ptr->first_slot_num, 1))) 571 if ((slot_num >= opt_lo_ptr->first_slot_num) && (!first_slot_num(slot_num, opt_lo_ptr->first_slot_num, 1)))
572 return opt_lo_ptr; 572 return opt_lo_ptr;
573 } 573 }
574 return NULL; 574 return NULL;
575} 575}
576 576
577static struct opt_rio *find_chassis_num (u8 slot_num) 577static struct opt_rio *find_chassis_num(u8 slot_num)
578{ 578{
579 struct opt_rio *opt_vg_ptr; 579 struct opt_rio *opt_vg_ptr;
580 580
581 list_for_each_entry(opt_vg_ptr, &opt_vg_head, opt_rio_list) { 581 list_for_each_entry(opt_vg_ptr, &opt_vg_head, opt_rio_list) {
582 //check to see if this slot_num belongs to chassis 582 //check to see if this slot_num belongs to chassis
583 if ((slot_num >= opt_vg_ptr->first_slot_num) && (!first_slot_num (slot_num, opt_vg_ptr->first_slot_num, 0))) 583 if ((slot_num >= opt_vg_ptr->first_slot_num) && (!first_slot_num(slot_num, opt_vg_ptr->first_slot_num, 0)))
584 return opt_vg_ptr; 584 return opt_vg_ptr;
585 } 585 }
586 return NULL; 586 return NULL;
@@ -589,7 +589,7 @@ static struct opt_rio *find_chassis_num (u8 slot_num)
589/* This routine will find out how many slots are in the chassis, so that 589/* This routine will find out how many slots are in the chassis, so that
590 * the slot numbers for rxe100 would start from 1, and not from 7, or 6 etc 590 * the slot numbers for rxe100 would start from 1, and not from 7, or 6 etc
591 */ 591 */
592static u8 calculate_first_slot (u8 slot_num) 592static u8 calculate_first_slot(u8 slot_num)
593{ 593{
594 u8 first_slot = 1; 594 u8 first_slot = 1;
595 struct slot *slot_cur; 595 struct slot *slot_cur;
@@ -606,7 +606,7 @@ static u8 calculate_first_slot (u8 slot_num)
606 606
607#define SLOT_NAME_SIZE 30 607#define SLOT_NAME_SIZE 30
608 608
609static char *create_file_name (struct slot *slot_cur) 609static char *create_file_name(struct slot *slot_cur)
610{ 610{
611 struct opt_rio *opt_vg_ptr = NULL; 611 struct opt_rio *opt_vg_ptr = NULL;
612 struct opt_rio_lo *opt_lo_ptr = NULL; 612 struct opt_rio_lo *opt_lo_ptr = NULL;
@@ -618,18 +618,18 @@ static char *create_file_name (struct slot *slot_cur)
618 u8 flag = 0; 618 u8 flag = 0;
619 619
620 if (!slot_cur) { 620 if (!slot_cur) {
621 err ("Structure passed is empty\n"); 621 err("Structure passed is empty\n");
622 return NULL; 622 return NULL;
623 } 623 }
624 624
625 slot_num = slot_cur->number; 625 slot_num = slot_cur->number;
626 626
627 memset (str, 0, sizeof(str)); 627 memset(str, 0, sizeof(str));
628 628
629 if (rio_table_ptr) { 629 if (rio_table_ptr) {
630 if (rio_table_ptr->ver_num == 3) { 630 if (rio_table_ptr->ver_num == 3) {
631 opt_vg_ptr = find_chassis_num (slot_num); 631 opt_vg_ptr = find_chassis_num(slot_num);
632 opt_lo_ptr = find_rxe_num (slot_num); 632 opt_lo_ptr = find_rxe_num(slot_num);
633 } 633 }
634 } 634 }
635 if (opt_vg_ptr) { 635 if (opt_vg_ptr) {
@@ -662,7 +662,7 @@ static char *create_file_name (struct slot *slot_cur)
662 } 662 }
663 if (!flag) { 663 if (!flag) {
664 if (slot_cur->ctrl->ctlr_type == 4) { 664 if (slot_cur->ctrl->ctlr_type == 4) {
665 first_slot = calculate_first_slot (slot_num); 665 first_slot = calculate_first_slot(slot_num);
666 which = 1; 666 which = 1;
667 } else { 667 } else {
668 which = 0; 668 which = 0;
@@ -698,7 +698,7 @@ static int fillslotinfo(struct hotplug_slot *hotplug_slot)
698 hotplug_slot->info->latch_status = SLOT_LATCH(slot->status); 698 hotplug_slot->info->latch_status = SLOT_LATCH(slot->status);
699 699
700 // pci board - present:1 not:0 700 // pci board - present:1 not:0
701 if (SLOT_PRESENT (slot->status)) 701 if (SLOT_PRESENT(slot->status))
702 hotplug_slot->info->adapter_status = 1; 702 hotplug_slot->info->adapter_status = 1;
703 else 703 else
704 hotplug_slot->info->adapter_status = 0; 704 hotplug_slot->info->adapter_status = 0;
@@ -729,7 +729,7 @@ static void release_slot(struct hotplug_slot *hotplug_slot)
729 /* we don't want to actually remove the resources, since free_resources will do just that */ 729 /* we don't want to actually remove the resources, since free_resources will do just that */
730 ibmphp_unconfigure_card(&slot, -1); 730 ibmphp_unconfigure_card(&slot, -1);
731 731
732 kfree (slot); 732 kfree(slot);
733} 733}
734 734
735static struct pci_driver ibmphp_driver; 735static struct pci_driver ibmphp_driver;
@@ -739,7 +739,7 @@ static struct pci_driver ibmphp_driver;
739 * each hpc from physical address to a list of hot plug controllers based on 739 * each hpc from physical address to a list of hot plug controllers based on
740 * hpc descriptors. 740 * hpc descriptors.
741 */ 741 */
742static int __init ebda_rsrc_controller (void) 742static int __init ebda_rsrc_controller(void)
743{ 743{
744 u16 addr, addr_slot, addr_bus; 744 u16 addr, addr_slot, addr_bus;
745 u8 ctlr_id, temp, bus_index; 745 u8 ctlr_id, temp, bus_index;
@@ -757,25 +757,25 @@ static int __init ebda_rsrc_controller (void)
757 addr = hpc_list_ptr->phys_addr; 757 addr = hpc_list_ptr->phys_addr;
758 for (ctlr = 0; ctlr < hpc_list_ptr->num_ctlrs; ctlr++) { 758 for (ctlr = 0; ctlr < hpc_list_ptr->num_ctlrs; ctlr++) {
759 bus_index = 1; 759 bus_index = 1;
760 ctlr_id = readb (io_mem + addr); 760 ctlr_id = readb(io_mem + addr);
761 addr += 1; 761 addr += 1;
762 slot_num = readb (io_mem + addr); 762 slot_num = readb(io_mem + addr);
763 763
764 addr += 1; 764 addr += 1;
765 addr_slot = addr; /* offset of slot structure */ 765 addr_slot = addr; /* offset of slot structure */
766 addr += (slot_num * 4); 766 addr += (slot_num * 4);
767 767
768 bus_num = readb (io_mem + addr); 768 bus_num = readb(io_mem + addr);
769 769
770 addr += 1; 770 addr += 1;
771 addr_bus = addr; /* offset of bus */ 771 addr_bus = addr; /* offset of bus */
772 addr += (bus_num * 9); /* offset of ctlr_type */ 772 addr += (bus_num * 9); /* offset of ctlr_type */
773 temp = readb (io_mem + addr); 773 temp = readb(io_mem + addr);
774 774
775 addr += 1; 775 addr += 1;
776 /* init hpc structure */ 776 /* init hpc structure */
777 hpc_ptr = alloc_ebda_hpc (slot_num, bus_num); 777 hpc_ptr = alloc_ebda_hpc(slot_num, bus_num);
778 if (!hpc_ptr ) { 778 if (!hpc_ptr) {
779 rc = -ENOMEM; 779 rc = -ENOMEM;
780 goto error_no_hpc; 780 goto error_no_hpc;
781 } 781 }
@@ -783,23 +783,23 @@ static int __init ebda_rsrc_controller (void)
783 hpc_ptr->ctlr_relative_id = ctlr; 783 hpc_ptr->ctlr_relative_id = ctlr;
784 hpc_ptr->slot_count = slot_num; 784 hpc_ptr->slot_count = slot_num;
785 hpc_ptr->bus_count = bus_num; 785 hpc_ptr->bus_count = bus_num;
786 debug ("now enter ctlr data structure ---\n"); 786 debug("now enter ctlr data structure ---\n");
787 debug ("ctlr id: %x\n", ctlr_id); 787 debug("ctlr id: %x\n", ctlr_id);
788 debug ("ctlr_relative_id: %x\n", hpc_ptr->ctlr_relative_id); 788 debug("ctlr_relative_id: %x\n", hpc_ptr->ctlr_relative_id);
789 debug ("count of slots controlled by this ctlr: %x\n", slot_num); 789 debug("count of slots controlled by this ctlr: %x\n", slot_num);
790 debug ("count of buses controlled by this ctlr: %x\n", bus_num); 790 debug("count of buses controlled by this ctlr: %x\n", bus_num);
791 791
792 /* init slot structure, fetch slot, bus, cap... */ 792 /* init slot structure, fetch slot, bus, cap... */
793 slot_ptr = hpc_ptr->slots; 793 slot_ptr = hpc_ptr->slots;
794 for (slot = 0; slot < slot_num; slot++) { 794 for (slot = 0; slot < slot_num; slot++) {
795 slot_ptr->slot_num = readb (io_mem + addr_slot); 795 slot_ptr->slot_num = readb(io_mem + addr_slot);
796 slot_ptr->slot_bus_num = readb (io_mem + addr_slot + slot_num); 796 slot_ptr->slot_bus_num = readb(io_mem + addr_slot + slot_num);
797 slot_ptr->ctl_index = readb (io_mem + addr_slot + 2*slot_num); 797 slot_ptr->ctl_index = readb(io_mem + addr_slot + 2*slot_num);
798 slot_ptr->slot_cap = readb (io_mem + addr_slot + 3*slot_num); 798 slot_ptr->slot_cap = readb(io_mem + addr_slot + 3*slot_num);
799 799
800 // create bus_info lined list --- if only one slot per bus: slot_min = slot_max 800 // create bus_info lined list --- if only one slot per bus: slot_min = slot_max
801 801
802 bus_info_ptr2 = ibmphp_find_same_bus_num (slot_ptr->slot_bus_num); 802 bus_info_ptr2 = ibmphp_find_same_bus_num(slot_ptr->slot_bus_num);
803 if (!bus_info_ptr2) { 803 if (!bus_info_ptr2) {
804 bus_info_ptr1 = kzalloc(sizeof(struct bus_info), GFP_KERNEL); 804 bus_info_ptr1 = kzalloc(sizeof(struct bus_info), GFP_KERNEL);
805 if (!bus_info_ptr1) { 805 if (!bus_info_ptr1) {
@@ -816,11 +816,11 @@ static int __init ebda_rsrc_controller (void)
816 816
817 bus_info_ptr1->controller_id = hpc_ptr->ctlr_id; 817 bus_info_ptr1->controller_id = hpc_ptr->ctlr_id;
818 818
819 list_add_tail (&bus_info_ptr1->bus_info_list, &bus_info_head); 819 list_add_tail(&bus_info_ptr1->bus_info_list, &bus_info_head);
820 820
821 } else { 821 } else {
822 bus_info_ptr2->slot_min = min (bus_info_ptr2->slot_min, slot_ptr->slot_num); 822 bus_info_ptr2->slot_min = min(bus_info_ptr2->slot_min, slot_ptr->slot_num);
823 bus_info_ptr2->slot_max = max (bus_info_ptr2->slot_max, slot_ptr->slot_num); 823 bus_info_ptr2->slot_max = max(bus_info_ptr2->slot_max, slot_ptr->slot_num);
824 bus_info_ptr2->slot_count += 1; 824 bus_info_ptr2->slot_count += 1;
825 825
826 } 826 }
@@ -834,17 +834,17 @@ static int __init ebda_rsrc_controller (void)
834 /* init bus structure */ 834 /* init bus structure */
835 bus_ptr = hpc_ptr->buses; 835 bus_ptr = hpc_ptr->buses;
836 for (bus = 0; bus < bus_num; bus++) { 836 for (bus = 0; bus < bus_num; bus++) {
837 bus_ptr->bus_num = readb (io_mem + addr_bus + bus); 837 bus_ptr->bus_num = readb(io_mem + addr_bus + bus);
838 bus_ptr->slots_at_33_conv = readb (io_mem + addr_bus + bus_num + 8 * bus); 838 bus_ptr->slots_at_33_conv = readb(io_mem + addr_bus + bus_num + 8 * bus);
839 bus_ptr->slots_at_66_conv = readb (io_mem + addr_bus + bus_num + 8 * bus + 1); 839 bus_ptr->slots_at_66_conv = readb(io_mem + addr_bus + bus_num + 8 * bus + 1);
840 840
841 bus_ptr->slots_at_66_pcix = readb (io_mem + addr_bus + bus_num + 8 * bus + 2); 841 bus_ptr->slots_at_66_pcix = readb(io_mem + addr_bus + bus_num + 8 * bus + 2);
842 842
843 bus_ptr->slots_at_100_pcix = readb (io_mem + addr_bus + bus_num + 8 * bus + 3); 843 bus_ptr->slots_at_100_pcix = readb(io_mem + addr_bus + bus_num + 8 * bus + 3);
844 844
845 bus_ptr->slots_at_133_pcix = readb (io_mem + addr_bus + bus_num + 8 * bus + 4); 845 bus_ptr->slots_at_133_pcix = readb(io_mem + addr_bus + bus_num + 8 * bus + 4);
846 846
847 bus_info_ptr2 = ibmphp_find_same_bus_num (bus_ptr->bus_num); 847 bus_info_ptr2 = ibmphp_find_same_bus_num(bus_ptr->bus_num);
848 if (bus_info_ptr2) { 848 if (bus_info_ptr2) {
849 bus_info_ptr2->slots_at_33_conv = bus_ptr->slots_at_33_conv; 849 bus_info_ptr2->slots_at_33_conv = bus_ptr->slots_at_33_conv;
850 bus_info_ptr2->slots_at_66_conv = bus_ptr->slots_at_66_conv; 850 bus_info_ptr2->slots_at_66_conv = bus_ptr->slots_at_66_conv;
@@ -859,33 +859,33 @@ static int __init ebda_rsrc_controller (void)
859 859
860 switch (hpc_ptr->ctlr_type) { 860 switch (hpc_ptr->ctlr_type) {
861 case 1: 861 case 1:
862 hpc_ptr->u.pci_ctlr.bus = readb (io_mem + addr); 862 hpc_ptr->u.pci_ctlr.bus = readb(io_mem + addr);
863 hpc_ptr->u.pci_ctlr.dev_fun = readb (io_mem + addr + 1); 863 hpc_ptr->u.pci_ctlr.dev_fun = readb(io_mem + addr + 1);
864 hpc_ptr->irq = readb (io_mem + addr + 2); 864 hpc_ptr->irq = readb(io_mem + addr + 2);
865 addr += 3; 865 addr += 3;
866 debug ("ctrl bus = %x, ctlr devfun = %x, irq = %x\n", 866 debug("ctrl bus = %x, ctlr devfun = %x, irq = %x\n",
867 hpc_ptr->u.pci_ctlr.bus, 867 hpc_ptr->u.pci_ctlr.bus,
868 hpc_ptr->u.pci_ctlr.dev_fun, hpc_ptr->irq); 868 hpc_ptr->u.pci_ctlr.dev_fun, hpc_ptr->irq);
869 break; 869 break;
870 870
871 case 0: 871 case 0:
872 hpc_ptr->u.isa_ctlr.io_start = readw (io_mem + addr); 872 hpc_ptr->u.isa_ctlr.io_start = readw(io_mem + addr);
873 hpc_ptr->u.isa_ctlr.io_end = readw (io_mem + addr + 2); 873 hpc_ptr->u.isa_ctlr.io_end = readw(io_mem + addr + 2);
874 if (!request_region (hpc_ptr->u.isa_ctlr.io_start, 874 if (!request_region(hpc_ptr->u.isa_ctlr.io_start,
875 (hpc_ptr->u.isa_ctlr.io_end - hpc_ptr->u.isa_ctlr.io_start + 1), 875 (hpc_ptr->u.isa_ctlr.io_end - hpc_ptr->u.isa_ctlr.io_start + 1),
876 "ibmphp")) { 876 "ibmphp")) {
877 rc = -ENODEV; 877 rc = -ENODEV;
878 goto error_no_hp_slot; 878 goto error_no_hp_slot;
879 } 879 }
880 hpc_ptr->irq = readb (io_mem + addr + 4); 880 hpc_ptr->irq = readb(io_mem + addr + 4);
881 addr += 5; 881 addr += 5;
882 break; 882 break;
883 883
884 case 2: 884 case 2:
885 case 4: 885 case 4:
886 hpc_ptr->u.wpeg_ctlr.wpegbbar = readl (io_mem + addr); 886 hpc_ptr->u.wpeg_ctlr.wpegbbar = readl(io_mem + addr);
887 hpc_ptr->u.wpeg_ctlr.i2c_addr = readb (io_mem + addr + 4); 887 hpc_ptr->u.wpeg_ctlr.i2c_addr = readb(io_mem + addr + 4);
888 hpc_ptr->irq = readb (io_mem + addr + 5); 888 hpc_ptr->irq = readb(io_mem + addr + 5);
889 addr += 6; 889 addr += 6;
890 break; 890 break;
891 default: 891 default:
@@ -894,8 +894,8 @@ static int __init ebda_rsrc_controller (void)
894 } 894 }
895 895
896 //reorganize chassis' linked list 896 //reorganize chassis' linked list
897 combine_wpg_for_chassis (); 897 combine_wpg_for_chassis();
898 combine_wpg_for_expansion (); 898 combine_wpg_for_expansion();
899 hpc_ptr->revision = 0xff; 899 hpc_ptr->revision = 0xff;
900 hpc_ptr->options = 0xff; 900 hpc_ptr->options = 0xff;
901 hpc_ptr->starting_slot_num = hpc_ptr->slots[0].slot_num; 901 hpc_ptr->starting_slot_num = hpc_ptr->slots[0].slot_num;
@@ -940,7 +940,7 @@ static int __init ebda_rsrc_controller (void)
940 940
941 tmp_slot->bus = hpc_ptr->slots[index].slot_bus_num; 941 tmp_slot->bus = hpc_ptr->slots[index].slot_bus_num;
942 942
943 bus_info_ptr1 = ibmphp_find_same_bus_num (hpc_ptr->slots[index].slot_bus_num); 943 bus_info_ptr1 = ibmphp_find_same_bus_num(hpc_ptr->slots[index].slot_bus_num);
944 if (!bus_info_ptr1) { 944 if (!bus_info_ptr1) {
945 kfree(tmp_slot); 945 kfree(tmp_slot);
946 rc = -ENODEV; 946 rc = -ENODEV;
@@ -961,18 +961,18 @@ static int __init ebda_rsrc_controller (void)
961 if (rc) 961 if (rc)
962 goto error; 962 goto error;
963 963
964 rc = ibmphp_init_devno ((struct slot **) &hp_slot_ptr->private); 964 rc = ibmphp_init_devno((struct slot **) &hp_slot_ptr->private);
965 if (rc) 965 if (rc)
966 goto error; 966 goto error;
967 hp_slot_ptr->ops = &ibmphp_hotplug_slot_ops; 967 hp_slot_ptr->ops = &ibmphp_hotplug_slot_ops;
968 968
969 // end of registering ibm slot with hotplug core 969 // end of registering ibm slot with hotplug core
970 970
971 list_add (& ((struct slot *)(hp_slot_ptr->private))->ibm_slot_list, &ibmphp_slot_head); 971 list_add(&((struct slot *)(hp_slot_ptr->private))->ibm_slot_list, &ibmphp_slot_head);
972 } 972 }
973 973
974 print_bus_info (); 974 print_bus_info();
975 list_add (&hpc_ptr->ebda_hpc_list, &ebda_hpc_head ); 975 list_add(&hpc_ptr->ebda_hpc_list, &ebda_hpc_head);
976 976
977 } /* each hpc */ 977 } /* each hpc */
978 978
@@ -982,20 +982,20 @@ static int __init ebda_rsrc_controller (void)
982 pci_find_bus(0, tmp_slot->bus), tmp_slot->device, name); 982 pci_find_bus(0, tmp_slot->bus), tmp_slot->device, name);
983 } 983 }
984 984
985 print_ebda_hpc (); 985 print_ebda_hpc();
986 print_ibm_slot (); 986 print_ibm_slot();
987 return 0; 987 return 0;
988 988
989error: 989error:
990 kfree (hp_slot_ptr->private); 990 kfree(hp_slot_ptr->private);
991error_no_slot: 991error_no_slot:
992 kfree (hp_slot_ptr->info); 992 kfree(hp_slot_ptr->info);
993error_no_hp_info: 993error_no_hp_info:
994 kfree (hp_slot_ptr); 994 kfree(hp_slot_ptr);
995error_no_hp_slot: 995error_no_hp_slot:
996 free_ebda_hpc (hpc_ptr); 996 free_ebda_hpc(hpc_ptr);
997error_no_hpc: 997error_no_hpc:
998 iounmap (io_mem); 998 iounmap(io_mem);
999 return rc; 999 return rc;
1000} 1000}
1001 1001
@@ -1003,7 +1003,7 @@ error_no_hpc:
1003 * map info (bus, devfun, start addr, end addr..) of i/o, memory, 1003 * map info (bus, devfun, start addr, end addr..) of i/o, memory,
1004 * pfm from the physical addr to a list of resource. 1004 * pfm from the physical addr to a list of resource.
1005 */ 1005 */
1006static int __init ebda_rsrc_rsrc (void) 1006static int __init ebda_rsrc_rsrc(void)
1007{ 1007{
1008 u16 addr; 1008 u16 addr;
1009 short rsrc; 1009 short rsrc;
@@ -1011,69 +1011,69 @@ static int __init ebda_rsrc_rsrc (void)
1011 struct ebda_pci_rsrc *rsrc_ptr; 1011 struct ebda_pci_rsrc *rsrc_ptr;
1012 1012
1013 addr = rsrc_list_ptr->phys_addr; 1013 addr = rsrc_list_ptr->phys_addr;
1014 debug ("now entering rsrc land\n"); 1014 debug("now entering rsrc land\n");
1015 debug ("offset of rsrc: %x\n", rsrc_list_ptr->phys_addr); 1015 debug("offset of rsrc: %x\n", rsrc_list_ptr->phys_addr);
1016 1016
1017 for (rsrc = 0; rsrc < rsrc_list_ptr->num_entries; rsrc++) { 1017 for (rsrc = 0; rsrc < rsrc_list_ptr->num_entries; rsrc++) {
1018 type = readb (io_mem + addr); 1018 type = readb(io_mem + addr);
1019 1019
1020 addr += 1; 1020 addr += 1;
1021 rsrc_type = type & EBDA_RSRC_TYPE_MASK; 1021 rsrc_type = type & EBDA_RSRC_TYPE_MASK;
1022 1022
1023 if (rsrc_type == EBDA_IO_RSRC_TYPE) { 1023 if (rsrc_type == EBDA_IO_RSRC_TYPE) {
1024 rsrc_ptr = alloc_ebda_pci_rsrc (); 1024 rsrc_ptr = alloc_ebda_pci_rsrc();
1025 if (!rsrc_ptr) { 1025 if (!rsrc_ptr) {
1026 iounmap (io_mem); 1026 iounmap(io_mem);
1027 return -ENOMEM; 1027 return -ENOMEM;
1028 } 1028 }
1029 rsrc_ptr->rsrc_type = type; 1029 rsrc_ptr->rsrc_type = type;
1030 1030
1031 rsrc_ptr->bus_num = readb (io_mem + addr); 1031 rsrc_ptr->bus_num = readb(io_mem + addr);
1032 rsrc_ptr->dev_fun = readb (io_mem + addr + 1); 1032 rsrc_ptr->dev_fun = readb(io_mem + addr + 1);
1033 rsrc_ptr->start_addr = readw (io_mem + addr + 2); 1033 rsrc_ptr->start_addr = readw(io_mem + addr + 2);
1034 rsrc_ptr->end_addr = readw (io_mem + addr + 4); 1034 rsrc_ptr->end_addr = readw(io_mem + addr + 4);
1035 addr += 6; 1035 addr += 6;
1036 1036
1037 debug ("rsrc from io type ----\n"); 1037 debug("rsrc from io type ----\n");
1038 debug ("rsrc type: %x bus#: %x dev_func: %x start addr: %x end addr: %x\n", 1038 debug("rsrc type: %x bus#: %x dev_func: %x start addr: %x end addr: %x\n",
1039 rsrc_ptr->rsrc_type, rsrc_ptr->bus_num, rsrc_ptr->dev_fun, rsrc_ptr->start_addr, rsrc_ptr->end_addr); 1039 rsrc_ptr->rsrc_type, rsrc_ptr->bus_num, rsrc_ptr->dev_fun, rsrc_ptr->start_addr, rsrc_ptr->end_addr);
1040 1040
1041 list_add (&rsrc_ptr->ebda_pci_rsrc_list, &ibmphp_ebda_pci_rsrc_head); 1041 list_add(&rsrc_ptr->ebda_pci_rsrc_list, &ibmphp_ebda_pci_rsrc_head);
1042 } 1042 }
1043 1043
1044 if (rsrc_type == EBDA_MEM_RSRC_TYPE || rsrc_type == EBDA_PFM_RSRC_TYPE) { 1044 if (rsrc_type == EBDA_MEM_RSRC_TYPE || rsrc_type == EBDA_PFM_RSRC_TYPE) {
1045 rsrc_ptr = alloc_ebda_pci_rsrc (); 1045 rsrc_ptr = alloc_ebda_pci_rsrc();
1046 if (!rsrc_ptr ) { 1046 if (!rsrc_ptr) {
1047 iounmap (io_mem); 1047 iounmap(io_mem);
1048 return -ENOMEM; 1048 return -ENOMEM;
1049 } 1049 }
1050 rsrc_ptr->rsrc_type = type; 1050 rsrc_ptr->rsrc_type = type;
1051 1051
1052 rsrc_ptr->bus_num = readb (io_mem + addr); 1052 rsrc_ptr->bus_num = readb(io_mem + addr);
1053 rsrc_ptr->dev_fun = readb (io_mem + addr + 1); 1053 rsrc_ptr->dev_fun = readb(io_mem + addr + 1);
1054 rsrc_ptr->start_addr = readl (io_mem + addr + 2); 1054 rsrc_ptr->start_addr = readl(io_mem + addr + 2);
1055 rsrc_ptr->end_addr = readl (io_mem + addr + 6); 1055 rsrc_ptr->end_addr = readl(io_mem + addr + 6);
1056 addr += 10; 1056 addr += 10;
1057 1057
1058 debug ("rsrc from mem or pfm ---\n"); 1058 debug("rsrc from mem or pfm ---\n");
1059 debug ("rsrc type: %x bus#: %x dev_func: %x start addr: %x end addr: %x\n", 1059 debug("rsrc type: %x bus#: %x dev_func: %x start addr: %x end addr: %x\n",
1060 rsrc_ptr->rsrc_type, rsrc_ptr->bus_num, rsrc_ptr->dev_fun, rsrc_ptr->start_addr, rsrc_ptr->end_addr); 1060 rsrc_ptr->rsrc_type, rsrc_ptr->bus_num, rsrc_ptr->dev_fun, rsrc_ptr->start_addr, rsrc_ptr->end_addr);
1061 1061
1062 list_add (&rsrc_ptr->ebda_pci_rsrc_list, &ibmphp_ebda_pci_rsrc_head); 1062 list_add(&rsrc_ptr->ebda_pci_rsrc_list, &ibmphp_ebda_pci_rsrc_head);
1063 } 1063 }
1064 } 1064 }
1065 kfree (rsrc_list_ptr); 1065 kfree(rsrc_list_ptr);
1066 rsrc_list_ptr = NULL; 1066 rsrc_list_ptr = NULL;
1067 print_ebda_pci_rsrc (); 1067 print_ebda_pci_rsrc();
1068 return 0; 1068 return 0;
1069} 1069}
1070 1070
1071u16 ibmphp_get_total_controllers (void) 1071u16 ibmphp_get_total_controllers(void)
1072{ 1072{
1073 return hpc_list_ptr->num_ctlrs; 1073 return hpc_list_ptr->num_ctlrs;
1074} 1074}
1075 1075
1076struct slot *ibmphp_get_slot_from_physical_num (u8 physical_num) 1076struct slot *ibmphp_get_slot_from_physical_num(u8 physical_num)
1077{ 1077{
1078 struct slot *slot; 1078 struct slot *slot;
1079 1079
@@ -1090,7 +1090,7 @@ struct slot *ibmphp_get_slot_from_physical_num (u8 physical_num)
1090 * - the total number of the slots based on each bus 1090 * - the total number of the slots based on each bus
1091 * (if only one slot per bus slot_min = slot_max ) 1091 * (if only one slot per bus slot_min = slot_max )
1092 */ 1092 */
1093struct bus_info *ibmphp_find_same_bus_num (u32 num) 1093struct bus_info *ibmphp_find_same_bus_num(u32 num)
1094{ 1094{
1095 struct bus_info *ptr; 1095 struct bus_info *ptr;
1096 1096
@@ -1104,7 +1104,7 @@ struct bus_info *ibmphp_find_same_bus_num (u32 num)
1104/* Finding relative bus number, in order to map corresponding 1104/* Finding relative bus number, in order to map corresponding
1105 * bus register 1105 * bus register
1106 */ 1106 */
1107int ibmphp_get_bus_index (u8 num) 1107int ibmphp_get_bus_index(u8 num)
1108{ 1108{
1109 struct bus_info *ptr; 1109 struct bus_info *ptr;
1110 1110
@@ -1115,7 +1115,7 @@ int ibmphp_get_bus_index (u8 num)
1115 return -ENODEV; 1115 return -ENODEV;
1116} 1116}
1117 1117
1118void ibmphp_free_bus_info_queue (void) 1118void ibmphp_free_bus_info_queue(void)
1119{ 1119{
1120 struct bus_info *bus_info, *next; 1120 struct bus_info *bus_info, *next;
1121 1121
@@ -1125,7 +1125,7 @@ void ibmphp_free_bus_info_queue (void)
1125 } 1125 }
1126} 1126}
1127 1127
1128void ibmphp_free_ebda_hpc_queue (void) 1128void ibmphp_free_ebda_hpc_queue(void)
1129{ 1129{
1130 struct controller *controller = NULL, *next; 1130 struct controller *controller = NULL, *next;
1131 int pci_flag = 0; 1131 int pci_flag = 0;
@@ -1133,16 +1133,16 @@ void ibmphp_free_ebda_hpc_queue (void)
1133 list_for_each_entry_safe(controller, next, &ebda_hpc_head, 1133 list_for_each_entry_safe(controller, next, &ebda_hpc_head,
1134 ebda_hpc_list) { 1134 ebda_hpc_list) {
1135 if (controller->ctlr_type == 0) 1135 if (controller->ctlr_type == 0)
1136 release_region (controller->u.isa_ctlr.io_start, (controller->u.isa_ctlr.io_end - controller->u.isa_ctlr.io_start + 1)); 1136 release_region(controller->u.isa_ctlr.io_start, (controller->u.isa_ctlr.io_end - controller->u.isa_ctlr.io_start + 1));
1137 else if ((controller->ctlr_type == 1) && (!pci_flag)) { 1137 else if ((controller->ctlr_type == 1) && (!pci_flag)) {
1138 ++pci_flag; 1138 ++pci_flag;
1139 pci_unregister_driver (&ibmphp_driver); 1139 pci_unregister_driver(&ibmphp_driver);
1140 } 1140 }
1141 free_ebda_hpc (controller); 1141 free_ebda_hpc(controller);
1142 } 1142 }
1143} 1143}
1144 1144
1145void ibmphp_free_ebda_pci_rsrc_queue (void) 1145void ibmphp_free_ebda_pci_rsrc_queue(void)
1146{ 1146{
1147 struct ebda_pci_rsrc *resource, *next; 1147 struct ebda_pci_rsrc *resource, *next;
1148 1148
@@ -1165,14 +1165,14 @@ static struct pci_device_id id_table[] = {
1165 1165
1166MODULE_DEVICE_TABLE(pci, id_table); 1166MODULE_DEVICE_TABLE(pci, id_table);
1167 1167
1168static int ibmphp_probe (struct pci_dev *, const struct pci_device_id *); 1168static int ibmphp_probe(struct pci_dev *, const struct pci_device_id *);
1169static struct pci_driver ibmphp_driver = { 1169static struct pci_driver ibmphp_driver = {
1170 .name = "ibmphp", 1170 .name = "ibmphp",
1171 .id_table = id_table, 1171 .id_table = id_table,
1172 .probe = ibmphp_probe, 1172 .probe = ibmphp_probe,
1173}; 1173};
1174 1174
1175int ibmphp_register_pci (void) 1175int ibmphp_register_pci(void)
1176{ 1176{
1177 struct controller *ctrl; 1177 struct controller *ctrl;
1178 int rc = 0; 1178 int rc = 0;
@@ -1185,18 +1185,18 @@ int ibmphp_register_pci (void)
1185 } 1185 }
1186 return rc; 1186 return rc;
1187} 1187}
1188static int ibmphp_probe (struct pci_dev *dev, const struct pci_device_id *ids) 1188static int ibmphp_probe(struct pci_dev *dev, const struct pci_device_id *ids)
1189{ 1189{
1190 struct controller *ctrl; 1190 struct controller *ctrl;
1191 1191
1192 debug ("inside ibmphp_probe\n"); 1192 debug("inside ibmphp_probe\n");
1193 1193
1194 list_for_each_entry(ctrl, &ebda_hpc_head, ebda_hpc_list) { 1194 list_for_each_entry(ctrl, &ebda_hpc_head, ebda_hpc_list) {
1195 if (ctrl->ctlr_type == 1) { 1195 if (ctrl->ctlr_type == 1) {
1196 if ((dev->devfn == ctrl->u.pci_ctlr.dev_fun) && (dev->bus->number == ctrl->u.pci_ctlr.bus)) { 1196 if ((dev->devfn == ctrl->u.pci_ctlr.dev_fun) && (dev->bus->number == ctrl->u.pci_ctlr.bus)) {
1197 ctrl->ctrl_dev = dev; 1197 ctrl->ctrl_dev = dev;
1198 debug ("found device!!!\n"); 1198 debug("found device!!!\n");
1199 debug ("dev->device = %x, dev->subsystem_device = %x\n", dev->device, dev->subsystem_device); 1199 debug("dev->device = %x, dev->subsystem_device = %x\n", dev->device, dev->subsystem_device);
1200 return 0; 1200 return 0;
1201 } 1201 }
1202 } 1202 }
diff --git a/drivers/pci/hotplug/ibmphp_hpc.c b/drivers/pci/hotplug/ibmphp_hpc.c
index e2608585abd3..a6b458e4ab46 100644
--- a/drivers/pci/hotplug/ibmphp_hpc.c
+++ b/drivers/pci/hotplug/ibmphp_hpc.c
@@ -40,7 +40,7 @@
40#include "ibmphp.h" 40#include "ibmphp.h"
41 41
42static int to_debug = 0; 42static int to_debug = 0;
43#define debug_polling(fmt, arg...) do { if (to_debug) debug (fmt, arg); } while (0) 43#define debug_polling(fmt, arg...) do { if (to_debug) debug(fmt, arg); } while (0)
44 44
45//---------------------------------------------------------------------------- 45//----------------------------------------------------------------------------
46// timeout values 46// timeout values
@@ -110,16 +110,16 @@ static struct task_struct *ibmphp_poll_thread;
110//---------------------------------------------------------------------------- 110//----------------------------------------------------------------------------
111// local function prototypes 111// local function prototypes
112//---------------------------------------------------------------------------- 112//----------------------------------------------------------------------------
113static u8 i2c_ctrl_read (struct controller *, void __iomem *, u8); 113static u8 i2c_ctrl_read(struct controller *, void __iomem *, u8);
114static u8 i2c_ctrl_write (struct controller *, void __iomem *, u8, u8); 114static u8 i2c_ctrl_write(struct controller *, void __iomem *, u8, u8);
115static u8 hpc_writecmdtoindex (u8, u8); 115static u8 hpc_writecmdtoindex(u8, u8);
116static u8 hpc_readcmdtoindex (u8, u8); 116static u8 hpc_readcmdtoindex(u8, u8);
117static void get_hpc_access (void); 117static void get_hpc_access(void);
118static void free_hpc_access (void); 118static void free_hpc_access(void);
119static int poll_hpc(void *data); 119static int poll_hpc(void *data);
120static int process_changeinstatus (struct slot *, struct slot *); 120static int process_changeinstatus(struct slot *, struct slot *);
121static int process_changeinlatch (u8, u8, struct controller *); 121static int process_changeinlatch(u8, u8, struct controller *);
122static int hpc_wait_ctlr_notworking (int, struct controller *, void __iomem *, u8 *); 122static int hpc_wait_ctlr_notworking(int, struct controller *, void __iomem *, u8 *);
123//---------------------------------------------------------------------------- 123//----------------------------------------------------------------------------
124 124
125 125
@@ -128,16 +128,16 @@ static int hpc_wait_ctlr_notworking (int, struct controller *, void __iomem *, u
128* 128*
129* Action: initialize semaphores and variables 129* Action: initialize semaphores and variables
130*---------------------------------------------------------------------*/ 130*---------------------------------------------------------------------*/
131void __init ibmphp_hpc_initvars (void) 131void __init ibmphp_hpc_initvars(void)
132{ 132{
133 debug ("%s - Entry\n", __func__); 133 debug("%s - Entry\n", __func__);
134 134
135 mutex_init(&sem_hpcaccess); 135 mutex_init(&sem_hpcaccess);
136 sema_init(&semOperations, 1); 136 sema_init(&semOperations, 1);
137 sema_init(&sem_exit, 0); 137 sema_init(&sem_exit, 0);
138 to_debug = 0; 138 to_debug = 0;
139 139
140 debug ("%s - Exit\n", __func__); 140 debug("%s - Exit\n", __func__);
141} 141}
142 142
143/*---------------------------------------------------------------------- 143/*----------------------------------------------------------------------
@@ -146,7 +146,7 @@ void __init ibmphp_hpc_initvars (void)
146* Action: read from HPC over I2C 146* Action: read from HPC over I2C
147* 147*
148*---------------------------------------------------------------------*/ 148*---------------------------------------------------------------------*/
149static u8 i2c_ctrl_read (struct controller *ctlr_ptr, void __iomem *WPGBbar, u8 index) 149static u8 i2c_ctrl_read(struct controller *ctlr_ptr, void __iomem *WPGBbar, u8 index)
150{ 150{
151 u8 status; 151 u8 status;
152 int i; 152 int i;
@@ -155,7 +155,7 @@ static u8 i2c_ctrl_read (struct controller *ctlr_ptr, void __iomem *WPGBbar, u8
155 unsigned long ultemp; 155 unsigned long ultemp;
156 unsigned long data; // actual data HILO format 156 unsigned long data; // actual data HILO format
157 157
158 debug_polling ("%s - Entry WPGBbar[%p] index[%x] \n", __func__, WPGBbar, index); 158 debug_polling("%s - Entry WPGBbar[%p] index[%x] \n", __func__, WPGBbar, index);
159 159
160 //-------------------------------------------------------------------- 160 //--------------------------------------------------------------------
161 // READ - step 1 161 // READ - step 1
@@ -178,28 +178,28 @@ static u8 i2c_ctrl_read (struct controller *ctlr_ptr, void __iomem *WPGBbar, u8
178 ultemp = ultemp << 8; 178 ultemp = ultemp << 8;
179 data |= ultemp; 179 data |= ultemp;
180 } else { 180 } else {
181 err ("this controller type is not supported \n"); 181 err("this controller type is not supported \n");
182 return HPC_ERROR; 182 return HPC_ERROR;
183 } 183 }
184 184
185 wpg_data = swab32 (data); // swap data before writing 185 wpg_data = swab32(data); // swap data before writing
186 wpg_addr = WPGBbar + WPG_I2CMOSUP_OFFSET; 186 wpg_addr = WPGBbar + WPG_I2CMOSUP_OFFSET;
187 writel (wpg_data, wpg_addr); 187 writel(wpg_data, wpg_addr);
188 188
189 //-------------------------------------------------------------------- 189 //--------------------------------------------------------------------
190 // READ - step 2 : clear the message buffer 190 // READ - step 2 : clear the message buffer
191 data = 0x00000000; 191 data = 0x00000000;
192 wpg_data = swab32 (data); 192 wpg_data = swab32(data);
193 wpg_addr = WPGBbar + WPG_I2CMBUFL_OFFSET; 193 wpg_addr = WPGBbar + WPG_I2CMBUFL_OFFSET;
194 writel (wpg_data, wpg_addr); 194 writel(wpg_data, wpg_addr);
195 195
196 //-------------------------------------------------------------------- 196 //--------------------------------------------------------------------
197 // READ - step 3 : issue start operation, I2C master control bit 30:ON 197 // READ - step 3 : issue start operation, I2C master control bit 30:ON
198 // 2020 : [20] OR operation at [20] offset 0x20 198 // 2020 : [20] OR operation at [20] offset 0x20
199 data = WPG_I2CMCNTL_STARTOP_MASK; 199 data = WPG_I2CMCNTL_STARTOP_MASK;
200 wpg_data = swab32 (data); 200 wpg_data = swab32(data);
201 wpg_addr = WPGBbar + WPG_I2CMCNTL_OFFSET + WPG_I2C_OR; 201 wpg_addr = WPGBbar + WPG_I2CMCNTL_OFFSET + WPG_I2C_OR;
202 writel (wpg_data, wpg_addr); 202 writel(wpg_data, wpg_addr);
203 203
204 //-------------------------------------------------------------------- 204 //--------------------------------------------------------------------
205 // READ - step 4 : wait until start operation bit clears 205 // READ - step 4 : wait until start operation bit clears
@@ -207,14 +207,14 @@ static u8 i2c_ctrl_read (struct controller *ctlr_ptr, void __iomem *WPGBbar, u8
207 while (i) { 207 while (i) {
208 msleep(10); 208 msleep(10);
209 wpg_addr = WPGBbar + WPG_I2CMCNTL_OFFSET; 209 wpg_addr = WPGBbar + WPG_I2CMCNTL_OFFSET;
210 wpg_data = readl (wpg_addr); 210 wpg_data = readl(wpg_addr);
211 data = swab32 (wpg_data); 211 data = swab32(wpg_data);
212 if (!(data & WPG_I2CMCNTL_STARTOP_MASK)) 212 if (!(data & WPG_I2CMCNTL_STARTOP_MASK))
213 break; 213 break;
214 i--; 214 i--;
215 } 215 }
216 if (i == 0) { 216 if (i == 0) {
217 debug ("%s - Error : WPG timeout\n", __func__); 217 debug("%s - Error : WPG timeout\n", __func__);
218 return HPC_ERROR; 218 return HPC_ERROR;
219 } 219 }
220 //-------------------------------------------------------------------- 220 //--------------------------------------------------------------------
@@ -223,26 +223,26 @@ static u8 i2c_ctrl_read (struct controller *ctlr_ptr, void __iomem *WPGBbar, u8
223 while (i) { 223 while (i) {
224 msleep(10); 224 msleep(10);
225 wpg_addr = WPGBbar + WPG_I2CSTAT_OFFSET; 225 wpg_addr = WPGBbar + WPG_I2CSTAT_OFFSET;
226 wpg_data = readl (wpg_addr); 226 wpg_data = readl(wpg_addr);
227 data = swab32 (wpg_data); 227 data = swab32(wpg_data);
228 if (HPC_I2CSTATUS_CHECK (data)) 228 if (HPC_I2CSTATUS_CHECK(data))
229 break; 229 break;
230 i--; 230 i--;
231 } 231 }
232 if (i == 0) { 232 if (i == 0) {
233 debug ("ctrl_read - Exit Error:I2C timeout\n"); 233 debug("ctrl_read - Exit Error:I2C timeout\n");
234 return HPC_ERROR; 234 return HPC_ERROR;
235 } 235 }
236 236
237 //-------------------------------------------------------------------- 237 //--------------------------------------------------------------------
238 // READ - step 6 : get DATA 238 // READ - step 6 : get DATA
239 wpg_addr = WPGBbar + WPG_I2CMBUFL_OFFSET; 239 wpg_addr = WPGBbar + WPG_I2CMBUFL_OFFSET;
240 wpg_data = readl (wpg_addr); 240 wpg_data = readl(wpg_addr);
241 data = swab32 (wpg_data); 241 data = swab32(wpg_data);
242 242
243 status = (u8) data; 243 status = (u8) data;
244 244
245 debug_polling ("%s - Exit index[%x] status[%x]\n", __func__, index, status); 245 debug_polling("%s - Exit index[%x] status[%x]\n", __func__, index, status);
246 246
247 return (status); 247 return (status);
248} 248}
@@ -254,7 +254,7 @@ static u8 i2c_ctrl_read (struct controller *ctlr_ptr, void __iomem *WPGBbar, u8
254* 254*
255* Return 0 or error codes 255* Return 0 or error codes
256*---------------------------------------------------------------------*/ 256*---------------------------------------------------------------------*/
257static u8 i2c_ctrl_write (struct controller *ctlr_ptr, void __iomem *WPGBbar, u8 index, u8 cmd) 257static u8 i2c_ctrl_write(struct controller *ctlr_ptr, void __iomem *WPGBbar, u8 index, u8 cmd)
258{ 258{
259 u8 rc; 259 u8 rc;
260 void __iomem *wpg_addr; // base addr + offset 260 void __iomem *wpg_addr; // base addr + offset
@@ -263,7 +263,7 @@ static u8 i2c_ctrl_write (struct controller *ctlr_ptr, void __iomem *WPGBbar, u8
263 unsigned long data; // actual data HILO format 263 unsigned long data; // actual data HILO format
264 int i; 264 int i;
265 265
266 debug_polling ("%s - Entry WPGBbar[%p] index[%x] cmd[%x]\n", __func__, WPGBbar, index, cmd); 266 debug_polling("%s - Entry WPGBbar[%p] index[%x] cmd[%x]\n", __func__, WPGBbar, index, cmd);
267 267
268 rc = 0; 268 rc = 0;
269 //-------------------------------------------------------------------- 269 //--------------------------------------------------------------------
@@ -289,28 +289,28 @@ static u8 i2c_ctrl_write (struct controller *ctlr_ptr, void __iomem *WPGBbar, u8
289 ultemp = ultemp << 8; 289 ultemp = ultemp << 8;
290 data |= ultemp; 290 data |= ultemp;
291 } else { 291 } else {
292 err ("this controller type is not supported \n"); 292 err("this controller type is not supported \n");
293 return HPC_ERROR; 293 return HPC_ERROR;
294 } 294 }
295 295
296 wpg_data = swab32 (data); // swap data before writing 296 wpg_data = swab32(data); // swap data before writing
297 wpg_addr = WPGBbar + WPG_I2CMOSUP_OFFSET; 297 wpg_addr = WPGBbar + WPG_I2CMOSUP_OFFSET;
298 writel (wpg_data, wpg_addr); 298 writel(wpg_data, wpg_addr);
299 299
300 //-------------------------------------------------------------------- 300 //--------------------------------------------------------------------
301 // WRITE - step 2 : clear the message buffer 301 // WRITE - step 2 : clear the message buffer
302 data = 0x00000000 | (unsigned long)cmd; 302 data = 0x00000000 | (unsigned long)cmd;
303 wpg_data = swab32 (data); 303 wpg_data = swab32(data);
304 wpg_addr = WPGBbar + WPG_I2CMBUFL_OFFSET; 304 wpg_addr = WPGBbar + WPG_I2CMBUFL_OFFSET;
305 writel (wpg_data, wpg_addr); 305 writel(wpg_data, wpg_addr);
306 306
307 //-------------------------------------------------------------------- 307 //--------------------------------------------------------------------
308 // WRITE - step 3 : issue start operation,I2C master control bit 30:ON 308 // WRITE - step 3 : issue start operation,I2C master control bit 30:ON
309 // 2020 : [20] OR operation at [20] offset 0x20 309 // 2020 : [20] OR operation at [20] offset 0x20
310 data = WPG_I2CMCNTL_STARTOP_MASK; 310 data = WPG_I2CMCNTL_STARTOP_MASK;
311 wpg_data = swab32 (data); 311 wpg_data = swab32(data);
312 wpg_addr = WPGBbar + WPG_I2CMCNTL_OFFSET + WPG_I2C_OR; 312 wpg_addr = WPGBbar + WPG_I2CMCNTL_OFFSET + WPG_I2C_OR;
313 writel (wpg_data, wpg_addr); 313 writel(wpg_data, wpg_addr);
314 314
315 //-------------------------------------------------------------------- 315 //--------------------------------------------------------------------
316 // WRITE - step 4 : wait until start operation bit clears 316 // WRITE - step 4 : wait until start operation bit clears
@@ -318,14 +318,14 @@ static u8 i2c_ctrl_write (struct controller *ctlr_ptr, void __iomem *WPGBbar, u8
318 while (i) { 318 while (i) {
319 msleep(10); 319 msleep(10);
320 wpg_addr = WPGBbar + WPG_I2CMCNTL_OFFSET; 320 wpg_addr = WPGBbar + WPG_I2CMCNTL_OFFSET;
321 wpg_data = readl (wpg_addr); 321 wpg_data = readl(wpg_addr);
322 data = swab32 (wpg_data); 322 data = swab32(wpg_data);
323 if (!(data & WPG_I2CMCNTL_STARTOP_MASK)) 323 if (!(data & WPG_I2CMCNTL_STARTOP_MASK))
324 break; 324 break;
325 i--; 325 i--;
326 } 326 }
327 if (i == 0) { 327 if (i == 0) {
328 debug ("%s - Exit Error:WPG timeout\n", __func__); 328 debug("%s - Exit Error:WPG timeout\n", __func__);
329 rc = HPC_ERROR; 329 rc = HPC_ERROR;
330 } 330 }
331 331
@@ -335,25 +335,25 @@ static u8 i2c_ctrl_write (struct controller *ctlr_ptr, void __iomem *WPGBbar, u8
335 while (i) { 335 while (i) {
336 msleep(10); 336 msleep(10);
337 wpg_addr = WPGBbar + WPG_I2CSTAT_OFFSET; 337 wpg_addr = WPGBbar + WPG_I2CSTAT_OFFSET;
338 wpg_data = readl (wpg_addr); 338 wpg_data = readl(wpg_addr);
339 data = swab32 (wpg_data); 339 data = swab32(wpg_data);
340 if (HPC_I2CSTATUS_CHECK (data)) 340 if (HPC_I2CSTATUS_CHECK(data))
341 break; 341 break;
342 i--; 342 i--;
343 } 343 }
344 if (i == 0) { 344 if (i == 0) {
345 debug ("ctrl_read - Error : I2C timeout\n"); 345 debug("ctrl_read - Error : I2C timeout\n");
346 rc = HPC_ERROR; 346 rc = HPC_ERROR;
347 } 347 }
348 348
349 debug_polling ("%s Exit rc[%x]\n", __func__, rc); 349 debug_polling("%s Exit rc[%x]\n", __func__, rc);
350 return (rc); 350 return (rc);
351} 351}
352 352
353//------------------------------------------------------------ 353//------------------------------------------------------------
354// Read from ISA type HPC 354// Read from ISA type HPC
355//------------------------------------------------------------ 355//------------------------------------------------------------
356static u8 isa_ctrl_read (struct controller *ctlr_ptr, u8 offset) 356static u8 isa_ctrl_read(struct controller *ctlr_ptr, u8 offset)
357{ 357{
358 u16 start_address; 358 u16 start_address;
359 u16 end_address; 359 u16 end_address;
@@ -361,56 +361,56 @@ static u8 isa_ctrl_read (struct controller *ctlr_ptr, u8 offset)
361 361
362 start_address = ctlr_ptr->u.isa_ctlr.io_start; 362 start_address = ctlr_ptr->u.isa_ctlr.io_start;
363 end_address = ctlr_ptr->u.isa_ctlr.io_end; 363 end_address = ctlr_ptr->u.isa_ctlr.io_end;
364 data = inb (start_address + offset); 364 data = inb(start_address + offset);
365 return data; 365 return data;
366} 366}
367 367
368//-------------------------------------------------------------- 368//--------------------------------------------------------------
369// Write to ISA type HPC 369// Write to ISA type HPC
370//-------------------------------------------------------------- 370//--------------------------------------------------------------
371static void isa_ctrl_write (struct controller *ctlr_ptr, u8 offset, u8 data) 371static void isa_ctrl_write(struct controller *ctlr_ptr, u8 offset, u8 data)
372{ 372{
373 u16 start_address; 373 u16 start_address;
374 u16 port_address; 374 u16 port_address;
375 375
376 start_address = ctlr_ptr->u.isa_ctlr.io_start; 376 start_address = ctlr_ptr->u.isa_ctlr.io_start;
377 port_address = start_address + (u16) offset; 377 port_address = start_address + (u16) offset;
378 outb (data, port_address); 378 outb(data, port_address);
379} 379}
380 380
381static u8 pci_ctrl_read (struct controller *ctrl, u8 offset) 381static u8 pci_ctrl_read(struct controller *ctrl, u8 offset)
382{ 382{
383 u8 data = 0x00; 383 u8 data = 0x00;
384 debug ("inside pci_ctrl_read\n"); 384 debug("inside pci_ctrl_read\n");
385 if (ctrl->ctrl_dev) 385 if (ctrl->ctrl_dev)
386 pci_read_config_byte (ctrl->ctrl_dev, HPC_PCI_OFFSET + offset, &data); 386 pci_read_config_byte(ctrl->ctrl_dev, HPC_PCI_OFFSET + offset, &data);
387 return data; 387 return data;
388} 388}
389 389
390static u8 pci_ctrl_write (struct controller *ctrl, u8 offset, u8 data) 390static u8 pci_ctrl_write(struct controller *ctrl, u8 offset, u8 data)
391{ 391{
392 u8 rc = -ENODEV; 392 u8 rc = -ENODEV;
393 debug ("inside pci_ctrl_write\n"); 393 debug("inside pci_ctrl_write\n");
394 if (ctrl->ctrl_dev) { 394 if (ctrl->ctrl_dev) {
395 pci_write_config_byte (ctrl->ctrl_dev, HPC_PCI_OFFSET + offset, data); 395 pci_write_config_byte(ctrl->ctrl_dev, HPC_PCI_OFFSET + offset, data);
396 rc = 0; 396 rc = 0;
397 } 397 }
398 return rc; 398 return rc;
399} 399}
400 400
401static u8 ctrl_read (struct controller *ctlr, void __iomem *base, u8 offset) 401static u8 ctrl_read(struct controller *ctlr, void __iomem *base, u8 offset)
402{ 402{
403 u8 rc; 403 u8 rc;
404 switch (ctlr->ctlr_type) { 404 switch (ctlr->ctlr_type) {
405 case 0: 405 case 0:
406 rc = isa_ctrl_read (ctlr, offset); 406 rc = isa_ctrl_read(ctlr, offset);
407 break; 407 break;
408 case 1: 408 case 1:
409 rc = pci_ctrl_read (ctlr, offset); 409 rc = pci_ctrl_read(ctlr, offset);
410 break; 410 break;
411 case 2: 411 case 2:
412 case 4: 412 case 4:
413 rc = i2c_ctrl_read (ctlr, base, offset); 413 rc = i2c_ctrl_read(ctlr, base, offset);
414 break; 414 break;
415 default: 415 default:
416 return -ENODEV; 416 return -ENODEV;
@@ -418,7 +418,7 @@ static u8 ctrl_read (struct controller *ctlr, void __iomem *base, u8 offset)
418 return rc; 418 return rc;
419} 419}
420 420
421static u8 ctrl_write (struct controller *ctlr, void __iomem *base, u8 offset, u8 data) 421static u8 ctrl_write(struct controller *ctlr, void __iomem *base, u8 offset, u8 data)
422{ 422{
423 u8 rc = 0; 423 u8 rc = 0;
424 switch (ctlr->ctlr_type) { 424 switch (ctlr->ctlr_type) {
@@ -426,7 +426,7 @@ static u8 ctrl_write (struct controller *ctlr, void __iomem *base, u8 offset, u8
426 isa_ctrl_write(ctlr, offset, data); 426 isa_ctrl_write(ctlr, offset, data);
427 break; 427 break;
428 case 1: 428 case 1:
429 rc = pci_ctrl_write (ctlr, offset, data); 429 rc = pci_ctrl_write(ctlr, offset, data);
430 break; 430 break;
431 case 2: 431 case 2:
432 case 4: 432 case 4:
@@ -444,7 +444,7 @@ static u8 ctrl_write (struct controller *ctlr, void __iomem *base, u8 offset, u8
444* 444*
445* Return index, HPC_ERROR 445* Return index, HPC_ERROR
446*---------------------------------------------------------------------*/ 446*---------------------------------------------------------------------*/
447static u8 hpc_writecmdtoindex (u8 cmd, u8 index) 447static u8 hpc_writecmdtoindex(u8 cmd, u8 index)
448{ 448{
449 u8 rc; 449 u8 rc;
450 450
@@ -476,7 +476,7 @@ static u8 hpc_writecmdtoindex (u8 cmd, u8 index)
476 break; 476 break;
477 477
478 default: 478 default:
479 err ("hpc_writecmdtoindex - Error invalid cmd[%x]\n", cmd); 479 err("hpc_writecmdtoindex - Error invalid cmd[%x]\n", cmd);
480 rc = HPC_ERROR; 480 rc = HPC_ERROR;
481 } 481 }
482 482
@@ -490,7 +490,7 @@ static u8 hpc_writecmdtoindex (u8 cmd, u8 index)
490* 490*
491* Return index, HPC_ERROR 491* Return index, HPC_ERROR
492*---------------------------------------------------------------------*/ 492*---------------------------------------------------------------------*/
493static u8 hpc_readcmdtoindex (u8 cmd, u8 index) 493static u8 hpc_readcmdtoindex(u8 cmd, u8 index)
494{ 494{
495 u8 rc; 495 u8 rc;
496 496
@@ -533,7 +533,7 @@ static u8 hpc_readcmdtoindex (u8 cmd, u8 index)
533* 533*
534* Return 0 or error codes 534* Return 0 or error codes
535*---------------------------------------------------------------------*/ 535*---------------------------------------------------------------------*/
536int ibmphp_hpc_readslot (struct slot *pslot, u8 cmd, u8 *pstatus) 536int ibmphp_hpc_readslot(struct slot *pslot, u8 cmd, u8 *pstatus)
537{ 537{
538 void __iomem *wpg_bbar = NULL; 538 void __iomem *wpg_bbar = NULL;
539 struct controller *ctlr_ptr; 539 struct controller *ctlr_ptr;
@@ -541,69 +541,69 @@ int ibmphp_hpc_readslot (struct slot *pslot, u8 cmd, u8 *pstatus)
541 int rc = 0; 541 int rc = 0;
542 int busindex; 542 int busindex;
543 543
544 debug_polling ("%s - Entry pslot[%p] cmd[%x] pstatus[%p]\n", __func__, pslot, cmd, pstatus); 544 debug_polling("%s - Entry pslot[%p] cmd[%x] pstatus[%p]\n", __func__, pslot, cmd, pstatus);
545 545
546 if ((pslot == NULL) 546 if ((pslot == NULL)
547 || ((pstatus == NULL) && (cmd != READ_ALLSTAT) && (cmd != READ_BUSSTATUS))) { 547 || ((pstatus == NULL) && (cmd != READ_ALLSTAT) && (cmd != READ_BUSSTATUS))) {
548 rc = -EINVAL; 548 rc = -EINVAL;
549 err ("%s - Error invalid pointer, rc[%d]\n", __func__, rc); 549 err("%s - Error invalid pointer, rc[%d]\n", __func__, rc);
550 return rc; 550 return rc;
551 } 551 }
552 552
553 if (cmd == READ_BUSSTATUS) { 553 if (cmd == READ_BUSSTATUS) {
554 busindex = ibmphp_get_bus_index (pslot->bus); 554 busindex = ibmphp_get_bus_index(pslot->bus);
555 if (busindex < 0) { 555 if (busindex < 0) {
556 rc = -EINVAL; 556 rc = -EINVAL;
557 err ("%s - Exit Error:invalid bus, rc[%d]\n", __func__, rc); 557 err("%s - Exit Error:invalid bus, rc[%d]\n", __func__, rc);
558 return rc; 558 return rc;
559 } else 559 } else
560 index = (u8) busindex; 560 index = (u8) busindex;
561 } else 561 } else
562 index = pslot->ctlr_index; 562 index = pslot->ctlr_index;
563 563
564 index = hpc_readcmdtoindex (cmd, index); 564 index = hpc_readcmdtoindex(cmd, index);
565 565
566 if (index == HPC_ERROR) { 566 if (index == HPC_ERROR) {
567 rc = -EINVAL; 567 rc = -EINVAL;
568 err ("%s - Exit Error:invalid index, rc[%d]\n", __func__, rc); 568 err("%s - Exit Error:invalid index, rc[%d]\n", __func__, rc);
569 return rc; 569 return rc;
570 } 570 }
571 571
572 ctlr_ptr = pslot->ctrl; 572 ctlr_ptr = pslot->ctrl;
573 573
574 get_hpc_access (); 574 get_hpc_access();
575 575
576 //-------------------------------------------------------------------- 576 //--------------------------------------------------------------------
577 // map physical address to logical address 577 // map physical address to logical address
578 //-------------------------------------------------------------------- 578 //--------------------------------------------------------------------
579 if ((ctlr_ptr->ctlr_type == 2) || (ctlr_ptr->ctlr_type == 4)) 579 if ((ctlr_ptr->ctlr_type == 2) || (ctlr_ptr->ctlr_type == 4))
580 wpg_bbar = ioremap (ctlr_ptr->u.wpeg_ctlr.wpegbbar, WPG_I2C_IOREMAP_SIZE); 580 wpg_bbar = ioremap(ctlr_ptr->u.wpeg_ctlr.wpegbbar, WPG_I2C_IOREMAP_SIZE);
581 581
582 //-------------------------------------------------------------------- 582 //--------------------------------------------------------------------
583 // check controller status before reading 583 // check controller status before reading
584 //-------------------------------------------------------------------- 584 //--------------------------------------------------------------------
585 rc = hpc_wait_ctlr_notworking (HPC_CTLR_WORKING_TOUT, ctlr_ptr, wpg_bbar, &status); 585 rc = hpc_wait_ctlr_notworking(HPC_CTLR_WORKING_TOUT, ctlr_ptr, wpg_bbar, &status);
586 if (!rc) { 586 if (!rc) {
587 switch (cmd) { 587 switch (cmd) {
588 case READ_ALLSTAT: 588 case READ_ALLSTAT:
589 // update the slot structure 589 // update the slot structure
590 pslot->ctrl->status = status; 590 pslot->ctrl->status = status;
591 pslot->status = ctrl_read (ctlr_ptr, wpg_bbar, index); 591 pslot->status = ctrl_read(ctlr_ptr, wpg_bbar, index);
592 rc = hpc_wait_ctlr_notworking (HPC_CTLR_WORKING_TOUT, ctlr_ptr, wpg_bbar, 592 rc = hpc_wait_ctlr_notworking(HPC_CTLR_WORKING_TOUT, ctlr_ptr, wpg_bbar,
593 &status); 593 &status);
594 if (!rc) 594 if (!rc)
595 pslot->ext_status = ctrl_read (ctlr_ptr, wpg_bbar, index + WPG_1ST_EXTSLOT_INDEX); 595 pslot->ext_status = ctrl_read(ctlr_ptr, wpg_bbar, index + WPG_1ST_EXTSLOT_INDEX);
596 596
597 break; 597 break;
598 598
599 case READ_SLOTSTATUS: 599 case READ_SLOTSTATUS:
600 // DO NOT update the slot structure 600 // DO NOT update the slot structure
601 *pstatus = ctrl_read (ctlr_ptr, wpg_bbar, index); 601 *pstatus = ctrl_read(ctlr_ptr, wpg_bbar, index);
602 break; 602 break;
603 603
604 case READ_EXTSLOTSTATUS: 604 case READ_EXTSLOTSTATUS:
605 // DO NOT update the slot structure 605 // DO NOT update the slot structure
606 *pstatus = ctrl_read (ctlr_ptr, wpg_bbar, index); 606 *pstatus = ctrl_read(ctlr_ptr, wpg_bbar, index);
607 break; 607 break;
608 608
609 case READ_CTLRSTATUS: 609 case READ_CTLRSTATUS:
@@ -612,17 +612,17 @@ int ibmphp_hpc_readslot (struct slot *pslot, u8 cmd, u8 *pstatus)
612 break; 612 break;
613 613
614 case READ_BUSSTATUS: 614 case READ_BUSSTATUS:
615 pslot->busstatus = ctrl_read (ctlr_ptr, wpg_bbar, index); 615 pslot->busstatus = ctrl_read(ctlr_ptr, wpg_bbar, index);
616 break; 616 break;
617 case READ_REVLEVEL: 617 case READ_REVLEVEL:
618 *pstatus = ctrl_read (ctlr_ptr, wpg_bbar, index); 618 *pstatus = ctrl_read(ctlr_ptr, wpg_bbar, index);
619 break; 619 break;
620 case READ_HPCOPTIONS: 620 case READ_HPCOPTIONS:
621 *pstatus = ctrl_read (ctlr_ptr, wpg_bbar, index); 621 *pstatus = ctrl_read(ctlr_ptr, wpg_bbar, index);
622 break; 622 break;
623 case READ_SLOTLATCHLOWREG: 623 case READ_SLOTLATCHLOWREG:
624 // DO NOT update the slot structure 624 // DO NOT update the slot structure
625 *pstatus = ctrl_read (ctlr_ptr, wpg_bbar, index); 625 *pstatus = ctrl_read(ctlr_ptr, wpg_bbar, index);
626 break; 626 break;
627 627
628 // Not used 628 // Not used
@@ -630,18 +630,18 @@ int ibmphp_hpc_readslot (struct slot *pslot, u8 cmd, u8 *pstatus)
630 list_for_each_entry(pslot, &ibmphp_slot_head, 630 list_for_each_entry(pslot, &ibmphp_slot_head,
631 ibm_slot_list) { 631 ibm_slot_list) {
632 index = pslot->ctlr_index; 632 index = pslot->ctlr_index;
633 rc = hpc_wait_ctlr_notworking (HPC_CTLR_WORKING_TOUT, ctlr_ptr, 633 rc = hpc_wait_ctlr_notworking(HPC_CTLR_WORKING_TOUT, ctlr_ptr,
634 wpg_bbar, &status); 634 wpg_bbar, &status);
635 if (!rc) { 635 if (!rc) {
636 pslot->status = ctrl_read (ctlr_ptr, wpg_bbar, index); 636 pslot->status = ctrl_read(ctlr_ptr, wpg_bbar, index);
637 rc = hpc_wait_ctlr_notworking (HPC_CTLR_WORKING_TOUT, 637 rc = hpc_wait_ctlr_notworking(HPC_CTLR_WORKING_TOUT,
638 ctlr_ptr, wpg_bbar, &status); 638 ctlr_ptr, wpg_bbar, &status);
639 if (!rc) 639 if (!rc)
640 pslot->ext_status = 640 pslot->ext_status =
641 ctrl_read (ctlr_ptr, wpg_bbar, 641 ctrl_read(ctlr_ptr, wpg_bbar,
642 index + WPG_1ST_EXTSLOT_INDEX); 642 index + WPG_1ST_EXTSLOT_INDEX);
643 } else { 643 } else {
644 err ("%s - Error ctrl_read failed\n", __func__); 644 err("%s - Error ctrl_read failed\n", __func__);
645 rc = -EINVAL; 645 rc = -EINVAL;
646 break; 646 break;
647 } 647 }
@@ -658,11 +658,11 @@ int ibmphp_hpc_readslot (struct slot *pslot, u8 cmd, u8 *pstatus)
658 658
659 // remove physical to logical address mapping 659 // remove physical to logical address mapping
660 if ((ctlr_ptr->ctlr_type == 2) || (ctlr_ptr->ctlr_type == 4)) 660 if ((ctlr_ptr->ctlr_type == 2) || (ctlr_ptr->ctlr_type == 4))
661 iounmap (wpg_bbar); 661 iounmap(wpg_bbar);
662 662
663 free_hpc_access (); 663 free_hpc_access();
664 664
665 debug_polling ("%s - Exit rc[%d]\n", __func__, rc); 665 debug_polling("%s - Exit rc[%d]\n", __func__, rc);
666 return rc; 666 return rc;
667} 667}
668 668
@@ -671,7 +671,7 @@ int ibmphp_hpc_readslot (struct slot *pslot, u8 cmd, u8 *pstatus)
671* 671*
672* Action: issue a WRITE command to HPC 672* Action: issue a WRITE command to HPC
673*---------------------------------------------------------------------*/ 673*---------------------------------------------------------------------*/
674int ibmphp_hpc_writeslot (struct slot *pslot, u8 cmd) 674int ibmphp_hpc_writeslot(struct slot *pslot, u8 cmd)
675{ 675{
676 void __iomem *wpg_bbar = NULL; 676 void __iomem *wpg_bbar = NULL;
677 struct controller *ctlr_ptr; 677 struct controller *ctlr_ptr;
@@ -681,55 +681,55 @@ int ibmphp_hpc_writeslot (struct slot *pslot, u8 cmd)
681 int rc = 0; 681 int rc = 0;
682 int timeout; 682 int timeout;
683 683
684 debug_polling ("%s - Entry pslot[%p] cmd[%x]\n", __func__, pslot, cmd); 684 debug_polling("%s - Entry pslot[%p] cmd[%x]\n", __func__, pslot, cmd);
685 if (pslot == NULL) { 685 if (pslot == NULL) {
686 rc = -EINVAL; 686 rc = -EINVAL;
687 err ("%s - Error Exit rc[%d]\n", __func__, rc); 687 err("%s - Error Exit rc[%d]\n", __func__, rc);
688 return rc; 688 return rc;
689 } 689 }
690 690
691 if ((cmd == HPC_BUS_33CONVMODE) || (cmd == HPC_BUS_66CONVMODE) || 691 if ((cmd == HPC_BUS_33CONVMODE) || (cmd == HPC_BUS_66CONVMODE) ||
692 (cmd == HPC_BUS_66PCIXMODE) || (cmd == HPC_BUS_100PCIXMODE) || 692 (cmd == HPC_BUS_66PCIXMODE) || (cmd == HPC_BUS_100PCIXMODE) ||
693 (cmd == HPC_BUS_133PCIXMODE)) { 693 (cmd == HPC_BUS_133PCIXMODE)) {
694 busindex = ibmphp_get_bus_index (pslot->bus); 694 busindex = ibmphp_get_bus_index(pslot->bus);
695 if (busindex < 0) { 695 if (busindex < 0) {
696 rc = -EINVAL; 696 rc = -EINVAL;
697 err ("%s - Exit Error:invalid bus, rc[%d]\n", __func__, rc); 697 err("%s - Exit Error:invalid bus, rc[%d]\n", __func__, rc);
698 return rc; 698 return rc;
699 } else 699 } else
700 index = (u8) busindex; 700 index = (u8) busindex;
701 } else 701 } else
702 index = pslot->ctlr_index; 702 index = pslot->ctlr_index;
703 703
704 index = hpc_writecmdtoindex (cmd, index); 704 index = hpc_writecmdtoindex(cmd, index);
705 705
706 if (index == HPC_ERROR) { 706 if (index == HPC_ERROR) {
707 rc = -EINVAL; 707 rc = -EINVAL;
708 err ("%s - Error Exit rc[%d]\n", __func__, rc); 708 err("%s - Error Exit rc[%d]\n", __func__, rc);
709 return rc; 709 return rc;
710 } 710 }
711 711
712 ctlr_ptr = pslot->ctrl; 712 ctlr_ptr = pslot->ctrl;
713 713
714 get_hpc_access (); 714 get_hpc_access();
715 715
716 //-------------------------------------------------------------------- 716 //--------------------------------------------------------------------
717 // map physical address to logical address 717 // map physical address to logical address
718 //-------------------------------------------------------------------- 718 //--------------------------------------------------------------------
719 if ((ctlr_ptr->ctlr_type == 2) || (ctlr_ptr->ctlr_type == 4)) { 719 if ((ctlr_ptr->ctlr_type == 2) || (ctlr_ptr->ctlr_type == 4)) {
720 wpg_bbar = ioremap (ctlr_ptr->u.wpeg_ctlr.wpegbbar, WPG_I2C_IOREMAP_SIZE); 720 wpg_bbar = ioremap(ctlr_ptr->u.wpeg_ctlr.wpegbbar, WPG_I2C_IOREMAP_SIZE);
721 721
722 debug ("%s - ctlr id[%x] physical[%lx] logical[%lx] i2c[%x]\n", __func__, 722 debug("%s - ctlr id[%x] physical[%lx] logical[%lx] i2c[%x]\n", __func__,
723 ctlr_ptr->ctlr_id, (ulong) (ctlr_ptr->u.wpeg_ctlr.wpegbbar), (ulong) wpg_bbar, 723 ctlr_ptr->ctlr_id, (ulong) (ctlr_ptr->u.wpeg_ctlr.wpegbbar), (ulong) wpg_bbar,
724 ctlr_ptr->u.wpeg_ctlr.i2c_addr); 724 ctlr_ptr->u.wpeg_ctlr.i2c_addr);
725 } 725 }
726 //-------------------------------------------------------------------- 726 //--------------------------------------------------------------------
727 // check controller status before writing 727 // check controller status before writing
728 //-------------------------------------------------------------------- 728 //--------------------------------------------------------------------
729 rc = hpc_wait_ctlr_notworking (HPC_CTLR_WORKING_TOUT, ctlr_ptr, wpg_bbar, &status); 729 rc = hpc_wait_ctlr_notworking(HPC_CTLR_WORKING_TOUT, ctlr_ptr, wpg_bbar, &status);
730 if (!rc) { 730 if (!rc) {
731 731
732 ctrl_write (ctlr_ptr, wpg_bbar, index, cmd); 732 ctrl_write(ctlr_ptr, wpg_bbar, index, cmd);
733 733
734 //-------------------------------------------------------------------- 734 //--------------------------------------------------------------------
735 // check controller is still not working on the command 735 // check controller is still not working on the command
@@ -737,11 +737,11 @@ int ibmphp_hpc_writeslot (struct slot *pslot, u8 cmd)
737 timeout = CMD_COMPLETE_TOUT_SEC; 737 timeout = CMD_COMPLETE_TOUT_SEC;
738 done = 0; 738 done = 0;
739 while (!done) { 739 while (!done) {
740 rc = hpc_wait_ctlr_notworking (HPC_CTLR_WORKING_TOUT, ctlr_ptr, wpg_bbar, 740 rc = hpc_wait_ctlr_notworking(HPC_CTLR_WORKING_TOUT, ctlr_ptr, wpg_bbar,
741 &status); 741 &status);
742 if (!rc) { 742 if (!rc) {
743 if (NEEDTOCHECK_CMDSTATUS (cmd)) { 743 if (NEEDTOCHECK_CMDSTATUS(cmd)) {
744 if (CTLR_FINISHED (status) == HPC_CTLR_FINISHED_YES) 744 if (CTLR_FINISHED(status) == HPC_CTLR_FINISHED_YES)
745 done = 1; 745 done = 1;
746 } else 746 } else
747 done = 1; 747 done = 1;
@@ -750,7 +750,7 @@ int ibmphp_hpc_writeslot (struct slot *pslot, u8 cmd)
750 msleep(1000); 750 msleep(1000);
751 if (timeout < 1) { 751 if (timeout < 1) {
752 done = 1; 752 done = 1;
753 err ("%s - Error command complete timeout\n", __func__); 753 err("%s - Error command complete timeout\n", __func__);
754 rc = -EFAULT; 754 rc = -EFAULT;
755 } else 755 } else
756 timeout--; 756 timeout--;
@@ -762,10 +762,10 @@ int ibmphp_hpc_writeslot (struct slot *pslot, u8 cmd)
762 762
763 // remove physical to logical address mapping 763 // remove physical to logical address mapping
764 if ((ctlr_ptr->ctlr_type == 2) || (ctlr_ptr->ctlr_type == 4)) 764 if ((ctlr_ptr->ctlr_type == 2) || (ctlr_ptr->ctlr_type == 4))
765 iounmap (wpg_bbar); 765 iounmap(wpg_bbar);
766 free_hpc_access (); 766 free_hpc_access();
767 767
768 debug_polling ("%s - Exit rc[%d]\n", __func__, rc); 768 debug_polling("%s - Exit rc[%d]\n", __func__, rc);
769 return rc; 769 return rc;
770} 770}
771 771
@@ -774,7 +774,7 @@ int ibmphp_hpc_writeslot (struct slot *pslot, u8 cmd)
774* 774*
775* Action: make sure only one process can access HPC at one time 775* Action: make sure only one process can access HPC at one time
776*---------------------------------------------------------------------*/ 776*---------------------------------------------------------------------*/
777static void get_hpc_access (void) 777static void get_hpc_access(void)
778{ 778{
779 mutex_lock(&sem_hpcaccess); 779 mutex_lock(&sem_hpcaccess);
780} 780}
@@ -782,7 +782,7 @@ static void get_hpc_access (void)
782/*---------------------------------------------------------------------- 782/*----------------------------------------------------------------------
783* Name: free_hpc_access() 783* Name: free_hpc_access()
784*---------------------------------------------------------------------*/ 784*---------------------------------------------------------------------*/
785void free_hpc_access (void) 785void free_hpc_access(void)
786{ 786{
787 mutex_unlock(&sem_hpcaccess); 787 mutex_unlock(&sem_hpcaccess);
788} 788}
@@ -792,21 +792,21 @@ void free_hpc_access (void)
792* 792*
793* Action: make sure only one process can change the data structure 793* Action: make sure only one process can change the data structure
794*---------------------------------------------------------------------*/ 794*---------------------------------------------------------------------*/
795void ibmphp_lock_operations (void) 795void ibmphp_lock_operations(void)
796{ 796{
797 down (&semOperations); 797 down(&semOperations);
798 to_debug = 1; 798 to_debug = 1;
799} 799}
800 800
801/*---------------------------------------------------------------------- 801/*----------------------------------------------------------------------
802* Name: ibmphp_unlock_operations() 802* Name: ibmphp_unlock_operations()
803*---------------------------------------------------------------------*/ 803*---------------------------------------------------------------------*/
804void ibmphp_unlock_operations (void) 804void ibmphp_unlock_operations(void)
805{ 805{
806 debug ("%s - Entry\n", __func__); 806 debug("%s - Entry\n", __func__);
807 up (&semOperations); 807 up(&semOperations);
808 to_debug = 0; 808 to_debug = 0;
809 debug ("%s - Exit\n", __func__); 809 debug("%s - Exit\n", __func__);
810} 810}
811 811
812/*---------------------------------------------------------------------- 812/*----------------------------------------------------------------------
@@ -826,11 +826,11 @@ static int poll_hpc(void *data)
826 int poll_count = 0; 826 int poll_count = 0;
827 u8 ctrl_count = 0x00; 827 u8 ctrl_count = 0x00;
828 828
829 debug ("%s - Entry\n", __func__); 829 debug("%s - Entry\n", __func__);
830 830
831 while (!kthread_should_stop()) { 831 while (!kthread_should_stop()) {
832 /* try to get the lock to do some kind of hardware access */ 832 /* try to get the lock to do some kind of hardware access */
833 down (&semOperations); 833 down(&semOperations);
834 834
835 switch (poll_state) { 835 switch (poll_state) {
836 case POLL_LATCH_REGISTER: 836 case POLL_LATCH_REGISTER:
@@ -842,12 +842,12 @@ static int poll_hpc(void *data)
842 break; 842 break;
843 if (pslot->ctrl->ctlr_relative_id == ctrl_count) { 843 if (pslot->ctrl->ctlr_relative_id == ctrl_count) {
844 ctrl_count++; 844 ctrl_count++;
845 if (READ_SLOT_LATCH (pslot->ctrl)) { 845 if (READ_SLOT_LATCH(pslot->ctrl)) {
846 rc = ibmphp_hpc_readslot (pslot, 846 rc = ibmphp_hpc_readslot(pslot,
847 READ_SLOTLATCHLOWREG, 847 READ_SLOTLATCHLOWREG,
848 &curlatchlow); 848 &curlatchlow);
849 if (oldlatchlow != curlatchlow) 849 if (oldlatchlow != curlatchlow)
850 process_changeinlatch (oldlatchlow, 850 process_changeinlatch(oldlatchlow,
851 curlatchlow, 851 curlatchlow,
852 pslot->ctrl); 852 pslot->ctrl);
853 } 853 }
@@ -860,12 +860,12 @@ static int poll_hpc(void *data)
860 list_for_each_entry(pslot, &ibmphp_slot_head, 860 list_for_each_entry(pslot, &ibmphp_slot_head,
861 ibm_slot_list) { 861 ibm_slot_list) {
862 // make a copy of the old status 862 // make a copy of the old status
863 memcpy ((void *) &myslot, (void *) pslot, 863 memcpy((void *) &myslot, (void *) pslot,
864 sizeof (struct slot)); 864 sizeof(struct slot));
865 rc = ibmphp_hpc_readslot (pslot, READ_ALLSTAT, NULL); 865 rc = ibmphp_hpc_readslot(pslot, READ_ALLSTAT, NULL);
866 if ((myslot.status != pslot->status) 866 if ((myslot.status != pslot->status)
867 || (myslot.ext_status != pslot->ext_status)) 867 || (myslot.ext_status != pslot->ext_status))
868 process_changeinstatus (pslot, &myslot); 868 process_changeinstatus(pslot, &myslot);
869 } 869 }
870 ctrl_count = 0x00; 870 ctrl_count = 0x00;
871 list_for_each_entry(pslot, &ibmphp_slot_head, 871 list_for_each_entry(pslot, &ibmphp_slot_head,
@@ -874,8 +874,8 @@ static int poll_hpc(void *data)
874 break; 874 break;
875 if (pslot->ctrl->ctlr_relative_id == ctrl_count) { 875 if (pslot->ctrl->ctlr_relative_id == ctrl_count) {
876 ctrl_count++; 876 ctrl_count++;
877 if (READ_SLOT_LATCH (pslot->ctrl)) 877 if (READ_SLOT_LATCH(pslot->ctrl))
878 rc = ibmphp_hpc_readslot (pslot, 878 rc = ibmphp_hpc_readslot(pslot,
879 READ_SLOTLATCHLOWREG, 879 READ_SLOTLATCHLOWREG,
880 &curlatchlow); 880 &curlatchlow);
881 } 881 }
@@ -885,13 +885,13 @@ static int poll_hpc(void *data)
885 break; 885 break;
886 case POLL_SLEEP: 886 case POLL_SLEEP:
887 /* don't sleep with a lock on the hardware */ 887 /* don't sleep with a lock on the hardware */
888 up (&semOperations); 888 up(&semOperations);
889 msleep(POLL_INTERVAL_SEC * 1000); 889 msleep(POLL_INTERVAL_SEC * 1000);
890 890
891 if (kthread_should_stop()) 891 if (kthread_should_stop())
892 goto out_sleep; 892 goto out_sleep;
893 893
894 down (&semOperations); 894 down(&semOperations);
895 895
896 if (poll_count >= POLL_LATCH_CNT) { 896 if (poll_count >= POLL_LATCH_CNT) {
897 poll_count = 0; 897 poll_count = 0;
@@ -901,13 +901,13 @@ static int poll_hpc(void *data)
901 break; 901 break;
902 } 902 }
903 /* give up the hardware semaphore */ 903 /* give up the hardware semaphore */
904 up (&semOperations); 904 up(&semOperations);
905 /* sleep for a short time just for good measure */ 905 /* sleep for a short time just for good measure */
906out_sleep: 906out_sleep:
907 msleep(100); 907 msleep(100);
908 } 908 }
909 up (&sem_exit); 909 up(&sem_exit);
910 debug ("%s - Exit\n", __func__); 910 debug("%s - Exit\n", __func__);
911 return 0; 911 return 0;
912} 912}
913 913
@@ -927,14 +927,14 @@ out_sleep:
927* 927*
928* Notes: 928* Notes:
929*---------------------------------------------------------------------*/ 929*---------------------------------------------------------------------*/
930static int process_changeinstatus (struct slot *pslot, struct slot *poldslot) 930static int process_changeinstatus(struct slot *pslot, struct slot *poldslot)
931{ 931{
932 u8 status; 932 u8 status;
933 int rc = 0; 933 int rc = 0;
934 u8 disable = 0; 934 u8 disable = 0;
935 u8 update = 0; 935 u8 update = 0;
936 936
937 debug ("process_changeinstatus - Entry pslot[%p], poldslot[%p]\n", pslot, poldslot); 937 debug("process_changeinstatus - Entry pslot[%p], poldslot[%p]\n", pslot, poldslot);
938 938
939 // bit 0 - HPC_SLOT_POWER 939 // bit 0 - HPC_SLOT_POWER
940 if ((pslot->status & 0x01) != (poldslot->status & 0x01)) 940 if ((pslot->status & 0x01) != (poldslot->status & 0x01))
@@ -956,7 +956,7 @@ static int process_changeinstatus (struct slot *pslot, struct slot *poldslot)
956 // bit 5 - HPC_SLOT_PWRGD 956 // bit 5 - HPC_SLOT_PWRGD
957 if ((pslot->status & 0x20) != (poldslot->status & 0x20)) 957 if ((pslot->status & 0x20) != (poldslot->status & 0x20))
958 // OFF -> ON: ignore, ON -> OFF: disable slot 958 // OFF -> ON: ignore, ON -> OFF: disable slot
959 if ((poldslot->status & 0x20) && (SLOT_CONNECT (poldslot->status) == HPC_SLOT_CONNECTED) && (SLOT_PRESENT (poldslot->status))) 959 if ((poldslot->status & 0x20) && (SLOT_CONNECT(poldslot->status) == HPC_SLOT_CONNECTED) && (SLOT_PRESENT(poldslot->status)))
960 disable = 1; 960 disable = 1;
961 961
962 // bit 6 - HPC_SLOT_BUS_SPEED 962 // bit 6 - HPC_SLOT_BUS_SPEED
@@ -967,20 +967,20 @@ static int process_changeinstatus (struct slot *pslot, struct slot *poldslot)
967 update = 1; 967 update = 1;
968 // OPEN -> CLOSE 968 // OPEN -> CLOSE
969 if (pslot->status & 0x80) { 969 if (pslot->status & 0x80) {
970 if (SLOT_PWRGD (pslot->status)) { 970 if (SLOT_PWRGD(pslot->status)) {
971 // power goes on and off after closing latch 971 // power goes on and off after closing latch
972 // check again to make sure power is still ON 972 // check again to make sure power is still ON
973 msleep(1000); 973 msleep(1000);
974 rc = ibmphp_hpc_readslot (pslot, READ_SLOTSTATUS, &status); 974 rc = ibmphp_hpc_readslot(pslot, READ_SLOTSTATUS, &status);
975 if (SLOT_PWRGD (status)) 975 if (SLOT_PWRGD(status))
976 update = 1; 976 update = 1;
977 else // overwrite power in pslot to OFF 977 else // overwrite power in pslot to OFF
978 pslot->status &= ~HPC_SLOT_POWER; 978 pslot->status &= ~HPC_SLOT_POWER;
979 } 979 }
980 } 980 }
981 // CLOSE -> OPEN 981 // CLOSE -> OPEN
982 else if ((SLOT_PWRGD (poldslot->status) == HPC_SLOT_PWRGD_GOOD) 982 else if ((SLOT_PWRGD(poldslot->status) == HPC_SLOT_PWRGD_GOOD)
983 && (SLOT_CONNECT (poldslot->status) == HPC_SLOT_CONNECTED) && (SLOT_PRESENT (poldslot->status))) { 983 && (SLOT_CONNECT(poldslot->status) == HPC_SLOT_CONNECTED) && (SLOT_PRESENT(poldslot->status))) {
984 disable = 1; 984 disable = 1;
985 } 985 }
986 // else - ignore 986 // else - ignore
@@ -990,15 +990,15 @@ static int process_changeinstatus (struct slot *pslot, struct slot *poldslot)
990 update = 1; 990 update = 1;
991 991
992 if (disable) { 992 if (disable) {
993 debug ("process_changeinstatus - disable slot\n"); 993 debug("process_changeinstatus - disable slot\n");
994 pslot->flag = 0; 994 pslot->flag = 0;
995 rc = ibmphp_do_disable_slot (pslot); 995 rc = ibmphp_do_disable_slot(pslot);
996 } 996 }
997 997
998 if (update || disable) 998 if (update || disable)
999 ibmphp_update_slot_info (pslot); 999 ibmphp_update_slot_info(pslot);
1000 1000
1001 debug ("%s - Exit rc[%d] disable[%x] update[%x]\n", __func__, rc, disable, update); 1001 debug("%s - Exit rc[%d] disable[%x] update[%x]\n", __func__, rc, disable, update);
1002 1002
1003 return rc; 1003 return rc;
1004} 1004}
@@ -1013,32 +1013,32 @@ static int process_changeinstatus (struct slot *pslot, struct slot *poldslot)
1013* Return 0 or error codes 1013* Return 0 or error codes
1014* Value: 1014* Value:
1015*---------------------------------------------------------------------*/ 1015*---------------------------------------------------------------------*/
1016static int process_changeinlatch (u8 old, u8 new, struct controller *ctrl) 1016static int process_changeinlatch(u8 old, u8 new, struct controller *ctrl)
1017{ 1017{
1018 struct slot myslot, *pslot; 1018 struct slot myslot, *pslot;
1019 u8 i; 1019 u8 i;
1020 u8 mask; 1020 u8 mask;
1021 int rc = 0; 1021 int rc = 0;
1022 1022
1023 debug ("%s - Entry old[%x], new[%x]\n", __func__, old, new); 1023 debug("%s - Entry old[%x], new[%x]\n", __func__, old, new);
1024 // bit 0 reserved, 0 is LSB, check bit 1-6 for 6 slots 1024 // bit 0 reserved, 0 is LSB, check bit 1-6 for 6 slots
1025 1025
1026 for (i = ctrl->starting_slot_num; i <= ctrl->ending_slot_num; i++) { 1026 for (i = ctrl->starting_slot_num; i <= ctrl->ending_slot_num; i++) {
1027 mask = 0x01 << i; 1027 mask = 0x01 << i;
1028 if ((mask & old) != (mask & new)) { 1028 if ((mask & old) != (mask & new)) {
1029 pslot = ibmphp_get_slot_from_physical_num (i); 1029 pslot = ibmphp_get_slot_from_physical_num(i);
1030 if (pslot) { 1030 if (pslot) {
1031 memcpy ((void *) &myslot, (void *) pslot, sizeof (struct slot)); 1031 memcpy((void *) &myslot, (void *) pslot, sizeof(struct slot));
1032 rc = ibmphp_hpc_readslot (pslot, READ_ALLSTAT, NULL); 1032 rc = ibmphp_hpc_readslot(pslot, READ_ALLSTAT, NULL);
1033 debug ("%s - call process_changeinstatus for slot[%d]\n", __func__, i); 1033 debug("%s - call process_changeinstatus for slot[%d]\n", __func__, i);
1034 process_changeinstatus (pslot, &myslot); 1034 process_changeinstatus(pslot, &myslot);
1035 } else { 1035 } else {
1036 rc = -EINVAL; 1036 rc = -EINVAL;
1037 err ("%s - Error bad pointer for slot[%d]\n", __func__, i); 1037 err("%s - Error bad pointer for slot[%d]\n", __func__, i);
1038 } 1038 }
1039 } 1039 }
1040 } 1040 }
1041 debug ("%s - Exit rc[%d]\n", __func__, rc); 1041 debug("%s - Exit rc[%d]\n", __func__, rc);
1042 return rc; 1042 return rc;
1043} 1043}
1044 1044
@@ -1047,13 +1047,13 @@ static int process_changeinlatch (u8 old, u8 new, struct controller *ctrl)
1047* 1047*
1048* Action: start polling thread 1048* Action: start polling thread
1049*---------------------------------------------------------------------*/ 1049*---------------------------------------------------------------------*/
1050int __init ibmphp_hpc_start_poll_thread (void) 1050int __init ibmphp_hpc_start_poll_thread(void)
1051{ 1051{
1052 debug ("%s - Entry\n", __func__); 1052 debug("%s - Entry\n", __func__);
1053 1053
1054 ibmphp_poll_thread = kthread_run(poll_hpc, NULL, "hpc_poll"); 1054 ibmphp_poll_thread = kthread_run(poll_hpc, NULL, "hpc_poll");
1055 if (IS_ERR(ibmphp_poll_thread)) { 1055 if (IS_ERR(ibmphp_poll_thread)) {
1056 err ("%s - Error, thread not started\n", __func__); 1056 err("%s - Error, thread not started\n", __func__);
1057 return PTR_ERR(ibmphp_poll_thread); 1057 return PTR_ERR(ibmphp_poll_thread);
1058 } 1058 }
1059 return 0; 1059 return 0;
@@ -1064,30 +1064,30 @@ int __init ibmphp_hpc_start_poll_thread (void)
1064* 1064*
1065* Action: stop polling thread and cleanup 1065* Action: stop polling thread and cleanup
1066*---------------------------------------------------------------------*/ 1066*---------------------------------------------------------------------*/
1067void __exit ibmphp_hpc_stop_poll_thread (void) 1067void __exit ibmphp_hpc_stop_poll_thread(void)
1068{ 1068{
1069 debug ("%s - Entry\n", __func__); 1069 debug("%s - Entry\n", __func__);
1070 1070
1071 kthread_stop(ibmphp_poll_thread); 1071 kthread_stop(ibmphp_poll_thread);
1072 debug ("before locking operations \n"); 1072 debug("before locking operations\n");
1073 ibmphp_lock_operations (); 1073 ibmphp_lock_operations();
1074 debug ("after locking operations \n"); 1074 debug("after locking operations\n");
1075 1075
1076 // wait for poll thread to exit 1076 // wait for poll thread to exit
1077 debug ("before sem_exit down \n"); 1077 debug("before sem_exit down\n");
1078 down (&sem_exit); 1078 down(&sem_exit);
1079 debug ("after sem_exit down \n"); 1079 debug("after sem_exit down\n");
1080 1080
1081 // cleanup 1081 // cleanup
1082 debug ("before free_hpc_access \n"); 1082 debug("before free_hpc_access\n");
1083 free_hpc_access (); 1083 free_hpc_access();
1084 debug ("after free_hpc_access \n"); 1084 debug("after free_hpc_access\n");
1085 ibmphp_unlock_operations (); 1085 ibmphp_unlock_operations();
1086 debug ("after unlock operations \n"); 1086 debug("after unlock operations\n");
1087 up (&sem_exit); 1087 up(&sem_exit);
1088 debug ("after sem exit up\n"); 1088 debug("after sem exit up\n");
1089 1089
1090 debug ("%s - Exit\n", __func__); 1090 debug("%s - Exit\n", __func__);
1091} 1091}
1092 1092
1093/*---------------------------------------------------------------------- 1093/*----------------------------------------------------------------------
@@ -1098,32 +1098,32 @@ void __exit ibmphp_hpc_stop_poll_thread (void)
1098* Return 0, HPC_ERROR 1098* Return 0, HPC_ERROR
1099* Value: 1099* Value:
1100*---------------------------------------------------------------------*/ 1100*---------------------------------------------------------------------*/
1101static int hpc_wait_ctlr_notworking (int timeout, struct controller *ctlr_ptr, void __iomem *wpg_bbar, 1101static int hpc_wait_ctlr_notworking(int timeout, struct controller *ctlr_ptr, void __iomem *wpg_bbar,
1102 u8 *pstatus) 1102 u8 *pstatus)
1103{ 1103{
1104 int rc = 0; 1104 int rc = 0;
1105 u8 done = 0; 1105 u8 done = 0;
1106 1106
1107 debug_polling ("hpc_wait_ctlr_notworking - Entry timeout[%d]\n", timeout); 1107 debug_polling("hpc_wait_ctlr_notworking - Entry timeout[%d]\n", timeout);
1108 1108
1109 while (!done) { 1109 while (!done) {
1110 *pstatus = ctrl_read (ctlr_ptr, wpg_bbar, WPG_CTLR_INDEX); 1110 *pstatus = ctrl_read(ctlr_ptr, wpg_bbar, WPG_CTLR_INDEX);
1111 if (*pstatus == HPC_ERROR) { 1111 if (*pstatus == HPC_ERROR) {
1112 rc = HPC_ERROR; 1112 rc = HPC_ERROR;
1113 done = 1; 1113 done = 1;
1114 } 1114 }
1115 if (CTLR_WORKING (*pstatus) == HPC_CTLR_WORKING_NO) 1115 if (CTLR_WORKING(*pstatus) == HPC_CTLR_WORKING_NO)
1116 done = 1; 1116 done = 1;
1117 if (!done) { 1117 if (!done) {
1118 msleep(1000); 1118 msleep(1000);
1119 if (timeout < 1) { 1119 if (timeout < 1) {
1120 done = 1; 1120 done = 1;
1121 err ("HPCreadslot - Error ctlr timeout\n"); 1121 err("HPCreadslot - Error ctlr timeout\n");
1122 rc = HPC_ERROR; 1122 rc = HPC_ERROR;
1123 } else 1123 } else
1124 timeout--; 1124 timeout--;
1125 } 1125 }
1126 } 1126 }
1127 debug_polling ("hpc_wait_ctlr_notworking - Exit rc[%x] status[%x]\n", rc, *pstatus); 1127 debug_polling("hpc_wait_ctlr_notworking - Exit rc[%x] status[%x]\n", rc, *pstatus);
1128 return rc; 1128 return rc;
1129} 1129}
diff --git a/drivers/pci/hotplug/ibmphp_pci.c b/drivers/pci/hotplug/ibmphp_pci.c
index 5824df538f72..dc1876feb06f 100644
--- a/drivers/pci/hotplug/ibmphp_pci.c
+++ b/drivers/pci/hotplug/ibmphp_pci.c
@@ -37,8 +37,8 @@
37static int configure_device(struct pci_func *); 37static int configure_device(struct pci_func *);
38static int configure_bridge(struct pci_func **, u8); 38static int configure_bridge(struct pci_func **, u8);
39static struct res_needed *scan_behind_bridge(struct pci_func *, u8); 39static struct res_needed *scan_behind_bridge(struct pci_func *, u8);
40static int add_new_bus (struct bus_node *, struct resource_node *, struct resource_node *, struct resource_node *, u8); 40static int add_new_bus(struct bus_node *, struct resource_node *, struct resource_node *, struct resource_node *, u8);
41static u8 find_sec_number (u8 primary_busno, u8 slotno); 41static u8 find_sec_number(u8 primary_busno, u8 slotno);
42 42
43/* 43/*
44 * NOTE..... If BIOS doesn't provide default routing, we assign: 44 * NOTE..... If BIOS doesn't provide default routing, we assign:
@@ -47,7 +47,7 @@ static u8 find_sec_number (u8 primary_busno, u8 slotno);
47 * We also assign the same irq numbers for multi function devices. 47 * We also assign the same irq numbers for multi function devices.
48 * These are PIC mode, so shouldn't matter n.e.ways (hopefully) 48 * These are PIC mode, so shouldn't matter n.e.ways (hopefully)
49 */ 49 */
50static void assign_alt_irq (struct pci_func *cur_func, u8 class_code) 50static void assign_alt_irq(struct pci_func *cur_func, u8 class_code)
51{ 51{
52 int j; 52 int j;
53 for (j = 0; j < 4; j++) { 53 for (j = 0; j < 4; j++) {
@@ -78,7 +78,7 @@ static void assign_alt_irq (struct pci_func *cur_func, u8 class_code)
78 * if there is an error, will need to go through all previous functions and 78 * if there is an error, will need to go through all previous functions and
79 * unconfigure....or can add some code into unconfigure_card.... 79 * unconfigure....or can add some code into unconfigure_card....
80 */ 80 */
81int ibmphp_configure_card (struct pci_func *func, u8 slotno) 81int ibmphp_configure_card(struct pci_func *func, u8 slotno)
82{ 82{
83 u16 vendor_id; 83 u16 vendor_id;
84 u32 class; 84 u32 class;
@@ -92,7 +92,7 @@ int ibmphp_configure_card (struct pci_func *func, u8 slotno)
92 u8 flag; 92 u8 flag;
93 u8 valid_device = 0x00; /* to see if we are able to read from card any device info at all */ 93 u8 valid_device = 0x00; /* to see if we are able to read from card any device info at all */
94 94
95 debug ("inside configure_card, func->busno = %x\n", func->busno); 95 debug("inside configure_card, func->busno = %x\n", func->busno);
96 96
97 device = func->device; 97 device = func->device;
98 cur_func = func; 98 cur_func = func;
@@ -109,15 +109,15 @@ int ibmphp_configure_card (struct pci_func *func, u8 slotno)
109 109
110 cur_func->function = function; 110 cur_func->function = function;
111 111
112 debug ("inside the loop, cur_func->busno = %x, cur_func->device = %x, cur_func->function = %x\n", 112 debug("inside the loop, cur_func->busno = %x, cur_func->device = %x, cur_func->function = %x\n",
113 cur_func->busno, cur_func->device, cur_func->function); 113 cur_func->busno, cur_func->device, cur_func->function);
114 114
115 pci_bus_read_config_word (ibmphp_pci_bus, devfn, PCI_VENDOR_ID, &vendor_id); 115 pci_bus_read_config_word(ibmphp_pci_bus, devfn, PCI_VENDOR_ID, &vendor_id);
116 116
117 debug ("vendor_id is %x\n", vendor_id); 117 debug("vendor_id is %x\n", vendor_id);
118 if (vendor_id != PCI_VENDOR_ID_NOTVALID) { 118 if (vendor_id != PCI_VENDOR_ID_NOTVALID) {
119 /* found correct device!!! */ 119 /* found correct device!!! */
120 debug ("found valid device, vendor_id = %x\n", vendor_id); 120 debug("found valid device, vendor_id = %x\n", vendor_id);
121 121
122 ++valid_device; 122 ++valid_device;
123 123
@@ -126,29 +126,29 @@ int ibmphp_configure_card (struct pci_func *func, u8 slotno)
126 * |_=> 0 = single function device, 1 = multi-function device 126 * |_=> 0 = single function device, 1 = multi-function device
127 */ 127 */
128 128
129 pci_bus_read_config_byte (ibmphp_pci_bus, devfn, PCI_HEADER_TYPE, &hdr_type); 129 pci_bus_read_config_byte(ibmphp_pci_bus, devfn, PCI_HEADER_TYPE, &hdr_type);
130 pci_bus_read_config_dword (ibmphp_pci_bus, devfn, PCI_CLASS_REVISION, &class); 130 pci_bus_read_config_dword(ibmphp_pci_bus, devfn, PCI_CLASS_REVISION, &class);
131 131
132 class_code = class >> 24; 132 class_code = class >> 24;
133 debug ("hrd_type = %x, class = %x, class_code %x\n", hdr_type, class, class_code); 133 debug("hrd_type = %x, class = %x, class_code %x\n", hdr_type, class, class_code);
134 class >>= 8; /* to take revision out, class = class.subclass.prog i/f */ 134 class >>= 8; /* to take revision out, class = class.subclass.prog i/f */
135 if (class == PCI_CLASS_NOT_DEFINED_VGA) { 135 if (class == PCI_CLASS_NOT_DEFINED_VGA) {
136 err ("The device %x is VGA compatible and as is not supported for hot plugging. " 136 err("The device %x is VGA compatible and as is not supported for hot plugging. "
137 "Please choose another device.\n", cur_func->device); 137 "Please choose another device.\n", cur_func->device);
138 return -ENODEV; 138 return -ENODEV;
139 } else if (class == PCI_CLASS_DISPLAY_VGA) { 139 } else if (class == PCI_CLASS_DISPLAY_VGA) {
140 err ("The device %x is not supported for hot plugging. Please choose another device.\n", 140 err("The device %x is not supported for hot plugging. Please choose another device.\n",
141 cur_func->device); 141 cur_func->device);
142 return -ENODEV; 142 return -ENODEV;
143 } 143 }
144 switch (hdr_type) { 144 switch (hdr_type) {
145 case PCI_HEADER_TYPE_NORMAL: 145 case PCI_HEADER_TYPE_NORMAL:
146 debug ("single device case.... vendor id = %x, hdr_type = %x, class = %x\n", vendor_id, hdr_type, class); 146 debug("single device case.... vendor id = %x, hdr_type = %x, class = %x\n", vendor_id, hdr_type, class);
147 assign_alt_irq (cur_func, class_code); 147 assign_alt_irq(cur_func, class_code);
148 rc = configure_device(cur_func); 148 rc = configure_device(cur_func);
149 if (rc < 0) { 149 if (rc < 0) {
150 /* We need to do this in case some other BARs were properly inserted */ 150 /* We need to do this in case some other BARs were properly inserted */
151 err ("was not able to configure devfunc %x on bus %x.\n", 151 err("was not able to configure devfunc %x on bus %x.\n",
152 cur_func->device, cur_func->busno); 152 cur_func->device, cur_func->busno);
153 cleanup_count = 6; 153 cleanup_count = 6;
154 goto error; 154 goto error;
@@ -157,18 +157,18 @@ int ibmphp_configure_card (struct pci_func *func, u8 slotno)
157 function = 0x8; 157 function = 0x8;
158 break; 158 break;
159 case PCI_HEADER_TYPE_MULTIDEVICE: 159 case PCI_HEADER_TYPE_MULTIDEVICE:
160 assign_alt_irq (cur_func, class_code); 160 assign_alt_irq(cur_func, class_code);
161 rc = configure_device(cur_func); 161 rc = configure_device(cur_func);
162 if (rc < 0) { 162 if (rc < 0) {
163 /* We need to do this in case some other BARs were properly inserted */ 163 /* We need to do this in case some other BARs were properly inserted */
164 err ("was not able to configure devfunc %x on bus %x...bailing out\n", 164 err("was not able to configure devfunc %x on bus %x...bailing out\n",
165 cur_func->device, cur_func->busno); 165 cur_func->device, cur_func->busno);
166 cleanup_count = 6; 166 cleanup_count = 6;
167 goto error; 167 goto error;
168 } 168 }
169 newfunc = kzalloc(sizeof(*newfunc), GFP_KERNEL); 169 newfunc = kzalloc(sizeof(*newfunc), GFP_KERNEL);
170 if (!newfunc) { 170 if (!newfunc) {
171 err ("out of system memory\n"); 171 err("out of system memory\n");
172 return -ENOMEM; 172 return -ENOMEM;
173 } 173 }
174 newfunc->busno = cur_func->busno; 174 newfunc->busno = cur_func->busno;
@@ -181,32 +181,32 @@ int ibmphp_configure_card (struct pci_func *func, u8 slotno)
181 case PCI_HEADER_TYPE_MULTIBRIDGE: 181 case PCI_HEADER_TYPE_MULTIBRIDGE:
182 class >>= 8; 182 class >>= 8;
183 if (class != PCI_CLASS_BRIDGE_PCI) { 183 if (class != PCI_CLASS_BRIDGE_PCI) {
184 err ("This %x is not PCI-to-PCI bridge, and as is not supported for hot-plugging. Please insert another card.\n", 184 err("This %x is not PCI-to-PCI bridge, and as is not supported for hot-plugging. Please insert another card.\n",
185 cur_func->device); 185 cur_func->device);
186 return -ENODEV; 186 return -ENODEV;
187 } 187 }
188 assign_alt_irq (cur_func, class_code); 188 assign_alt_irq(cur_func, class_code);
189 rc = configure_bridge (&cur_func, slotno); 189 rc = configure_bridge(&cur_func, slotno);
190 if (rc == -ENODEV) { 190 if (rc == -ENODEV) {
191 err ("You chose to insert Single Bridge, or nested bridges, this is not supported...\n"); 191 err("You chose to insert Single Bridge, or nested bridges, this is not supported...\n");
192 err ("Bus %x, devfunc %x\n", cur_func->busno, cur_func->device); 192 err("Bus %x, devfunc %x\n", cur_func->busno, cur_func->device);
193 return rc; 193 return rc;
194 } 194 }
195 if (rc) { 195 if (rc) {
196 /* We need to do this in case some other BARs were properly inserted */ 196 /* We need to do this in case some other BARs were properly inserted */
197 err ("was not able to hot-add PPB properly.\n"); 197 err("was not able to hot-add PPB properly.\n");
198 func->bus = 1; /* To indicate to the unconfigure function that this is a PPB */ 198 func->bus = 1; /* To indicate to the unconfigure function that this is a PPB */
199 cleanup_count = 2; 199 cleanup_count = 2;
200 goto error; 200 goto error;
201 } 201 }
202 202
203 pci_bus_read_config_byte (ibmphp_pci_bus, devfn, PCI_SECONDARY_BUS, &sec_number); 203 pci_bus_read_config_byte(ibmphp_pci_bus, devfn, PCI_SECONDARY_BUS, &sec_number);
204 flag = 0; 204 flag = 0;
205 for (i = 0; i < 32; i++) { 205 for (i = 0; i < 32; i++) {
206 if (func->devices[i]) { 206 if (func->devices[i]) {
207 newfunc = kzalloc(sizeof(*newfunc), GFP_KERNEL); 207 newfunc = kzalloc(sizeof(*newfunc), GFP_KERNEL);
208 if (!newfunc) { 208 if (!newfunc) {
209 err ("out of system memory\n"); 209 err("out of system memory\n");
210 return -ENOMEM; 210 return -ENOMEM;
211 } 211 }
212 newfunc->busno = sec_number; 212 newfunc->busno = sec_number;
@@ -220,7 +220,7 @@ int ibmphp_configure_card (struct pci_func *func, u8 slotno)
220 } else 220 } else
221 cur_func->next = newfunc; 221 cur_func->next = newfunc;
222 222
223 rc = ibmphp_configure_card (newfunc, slotno); 223 rc = ibmphp_configure_card(newfunc, slotno);
224 /* This could only happen if kmalloc failed */ 224 /* This could only happen if kmalloc failed */
225 if (rc) { 225 if (rc) {
226 /* We need to do this in case bridge itself got configured properly, but devices behind it failed */ 226 /* We need to do this in case bridge itself got configured properly, but devices behind it failed */
@@ -234,53 +234,53 @@ int ibmphp_configure_card (struct pci_func *func, u8 slotno)
234 234
235 newfunc = kzalloc(sizeof(*newfunc), GFP_KERNEL); 235 newfunc = kzalloc(sizeof(*newfunc), GFP_KERNEL);
236 if (!newfunc) { 236 if (!newfunc) {
237 err ("out of system memory\n"); 237 err("out of system memory\n");
238 return -ENOMEM; 238 return -ENOMEM;
239 } 239 }
240 newfunc->busno = cur_func->busno; 240 newfunc->busno = cur_func->busno;
241 newfunc->device = device; 241 newfunc->device = device;
242 for (j = 0; j < 4; j++) 242 for (j = 0; j < 4; j++)
243 newfunc->irq[j] = cur_func->irq[j]; 243 newfunc->irq[j] = cur_func->irq[j];
244 for (prev_func = cur_func; prev_func->next; prev_func = prev_func->next) ; 244 for (prev_func = cur_func; prev_func->next; prev_func = prev_func->next);
245 prev_func->next = newfunc; 245 prev_func->next = newfunc;
246 cur_func = newfunc; 246 cur_func = newfunc;
247 break; 247 break;
248 case PCI_HEADER_TYPE_BRIDGE: 248 case PCI_HEADER_TYPE_BRIDGE:
249 class >>= 8; 249 class >>= 8;
250 debug ("class now is %x\n", class); 250 debug("class now is %x\n", class);
251 if (class != PCI_CLASS_BRIDGE_PCI) { 251 if (class != PCI_CLASS_BRIDGE_PCI) {
252 err ("This %x is not PCI-to-PCI bridge, and as is not supported for hot-plugging. Please insert another card.\n", 252 err("This %x is not PCI-to-PCI bridge, and as is not supported for hot-plugging. Please insert another card.\n",
253 cur_func->device); 253 cur_func->device);
254 return -ENODEV; 254 return -ENODEV;
255 } 255 }
256 256
257 assign_alt_irq (cur_func, class_code); 257 assign_alt_irq(cur_func, class_code);
258 258
259 debug ("cur_func->busno b4 configure_bridge is %x\n", cur_func->busno); 259 debug("cur_func->busno b4 configure_bridge is %x\n", cur_func->busno);
260 rc = configure_bridge (&cur_func, slotno); 260 rc = configure_bridge(&cur_func, slotno);
261 if (rc == -ENODEV) { 261 if (rc == -ENODEV) {
262 err ("You chose to insert Single Bridge, or nested bridges, this is not supported...\n"); 262 err("You chose to insert Single Bridge, or nested bridges, this is not supported...\n");
263 err ("Bus %x, devfunc %x\n", cur_func->busno, cur_func->device); 263 err("Bus %x, devfunc %x\n", cur_func->busno, cur_func->device);
264 return rc; 264 return rc;
265 } 265 }
266 if (rc) { 266 if (rc) {
267 /* We need to do this in case some other BARs were properly inserted */ 267 /* We need to do this in case some other BARs were properly inserted */
268 func->bus = 1; /* To indicate to the unconfigure function that this is a PPB */ 268 func->bus = 1; /* To indicate to the unconfigure function that this is a PPB */
269 err ("was not able to hot-add PPB properly.\n"); 269 err("was not able to hot-add PPB properly.\n");
270 cleanup_count = 2; 270 cleanup_count = 2;
271 goto error; 271 goto error;
272 } 272 }
273 debug ("cur_func->busno = %x, device = %x, function = %x\n", 273 debug("cur_func->busno = %x, device = %x, function = %x\n",
274 cur_func->busno, device, function); 274 cur_func->busno, device, function);
275 pci_bus_read_config_byte (ibmphp_pci_bus, devfn, PCI_SECONDARY_BUS, &sec_number); 275 pci_bus_read_config_byte(ibmphp_pci_bus, devfn, PCI_SECONDARY_BUS, &sec_number);
276 debug ("after configuring bridge..., sec_number = %x\n", sec_number); 276 debug("after configuring bridge..., sec_number = %x\n", sec_number);
277 flag = 0; 277 flag = 0;
278 for (i = 0; i < 32; i++) { 278 for (i = 0; i < 32; i++) {
279 if (func->devices[i]) { 279 if (func->devices[i]) {
280 debug ("inside for loop, device is %x\n", i); 280 debug("inside for loop, device is %x\n", i);
281 newfunc = kzalloc(sizeof(*newfunc), GFP_KERNEL); 281 newfunc = kzalloc(sizeof(*newfunc), GFP_KERNEL);
282 if (!newfunc) { 282 if (!newfunc) {
283 err (" out of system memory\n"); 283 err(" out of system memory\n");
284 return -ENOMEM; 284 return -ENOMEM;
285 } 285 }
286 newfunc->busno = sec_number; 286 newfunc->busno = sec_number;
@@ -289,12 +289,12 @@ int ibmphp_configure_card (struct pci_func *func, u8 slotno)
289 newfunc->irq[j] = cur_func->irq[j]; 289 newfunc->irq[j] = cur_func->irq[j];
290 290
291 if (flag) { 291 if (flag) {
292 for (prev_func = cur_func; prev_func->next; prev_func = prev_func->next) ; 292 for (prev_func = cur_func; prev_func->next; prev_func = prev_func->next);
293 prev_func->next = newfunc; 293 prev_func->next = newfunc;
294 } else 294 } else
295 cur_func->next = newfunc; 295 cur_func->next = newfunc;
296 296
297 rc = ibmphp_configure_card (newfunc, slotno); 297 rc = ibmphp_configure_card(newfunc, slotno);
298 298
299 /* Again, this case should not happen... For complete paranoia, will need to call remove_bus */ 299 /* Again, this case should not happen... For complete paranoia, will need to call remove_bus */
300 if (rc) { 300 if (rc) {
@@ -310,7 +310,7 @@ int ibmphp_configure_card (struct pci_func *func, u8 slotno)
310 function = 0x8; 310 function = 0x8;
311 break; 311 break;
312 default: 312 default:
313 err ("MAJOR PROBLEM!!!!, header type not supported? %x\n", hdr_type); 313 err("MAJOR PROBLEM!!!!, header type not supported? %x\n", hdr_type);
314 return -ENXIO; 314 return -ENXIO;
315 break; 315 break;
316 } /* end of switch */ 316 } /* end of switch */
@@ -318,7 +318,7 @@ int ibmphp_configure_card (struct pci_func *func, u8 slotno)
318 } /* end of for */ 318 } /* end of for */
319 319
320 if (!valid_device) { 320 if (!valid_device) {
321 err ("Cannot find any valid devices on the card. Or unable to read from card.\n"); 321 err("Cannot find any valid devices on the card. Or unable to read from card.\n");
322 return -ENODEV; 322 return -ENODEV;
323 } 323 }
324 324
@@ -327,13 +327,13 @@ int ibmphp_configure_card (struct pci_func *func, u8 slotno)
327error: 327error:
328 for (i = 0; i < cleanup_count; i++) { 328 for (i = 0; i < cleanup_count; i++) {
329 if (cur_func->io[i]) { 329 if (cur_func->io[i]) {
330 ibmphp_remove_resource (cur_func->io[i]); 330 ibmphp_remove_resource(cur_func->io[i]);
331 cur_func->io[i] = NULL; 331 cur_func->io[i] = NULL;
332 } else if (cur_func->pfmem[i]) { 332 } else if (cur_func->pfmem[i]) {
333 ibmphp_remove_resource (cur_func->pfmem[i]); 333 ibmphp_remove_resource(cur_func->pfmem[i]);
334 cur_func->pfmem[i] = NULL; 334 cur_func->pfmem[i] = NULL;
335 } else if (cur_func->mem[i]) { 335 } else if (cur_func->mem[i]) {
336 ibmphp_remove_resource (cur_func->mem[i]); 336 ibmphp_remove_resource(cur_func->mem[i]);
337 cur_func->mem[i] = NULL; 337 cur_func->mem[i] = NULL;
338 } 338 }
339 } 339 }
@@ -345,7 +345,7 @@ error:
345 * Input: pointer to the pci_func 345 * Input: pointer to the pci_func
346 * Output: configured PCI, 0, or error 346 * Output: configured PCI, 0, or error
347 */ 347 */
348static int configure_device (struct pci_func *func) 348static int configure_device(struct pci_func *func)
349{ 349{
350 u32 bar[6]; 350 u32 bar[6];
351 u32 address[] = { 351 u32 address[] = {
@@ -366,7 +366,7 @@ static int configure_device (struct pci_func *func)
366 struct resource_node *pfmem[6]; 366 struct resource_node *pfmem[6];
367 unsigned int devfn; 367 unsigned int devfn;
368 368
369 debug ("%s - inside\n", __func__); 369 debug("%s - inside\n", __func__);
370 370
371 devfn = PCI_DEVFN(func->device, func->function); 371 devfn = PCI_DEVFN(func->device, func->function);
372 ibmphp_pci_bus->number = func->busno; 372 ibmphp_pci_bus->number = func->busno;
@@ -386,27 +386,27 @@ static int configure_device (struct pci_func *func)
386 pcibios_write_config_dword(cur_func->busno, cur_func->device, 386 pcibios_write_config_dword(cur_func->busno, cur_func->device,
387 PCI_BASE_ADDRESS_0 + 4 * count, 0xFFFFFFFF); 387 PCI_BASE_ADDRESS_0 + 4 * count, 0xFFFFFFFF);
388 */ 388 */
389 pci_bus_write_config_dword (ibmphp_pci_bus, devfn, address[count], 0xFFFFFFFF); 389 pci_bus_write_config_dword(ibmphp_pci_bus, devfn, address[count], 0xFFFFFFFF);
390 pci_bus_read_config_dword (ibmphp_pci_bus, devfn, address[count], &bar[count]); 390 pci_bus_read_config_dword(ibmphp_pci_bus, devfn, address[count], &bar[count]);
391 391
392 if (!bar[count]) /* This BAR is not implemented */ 392 if (!bar[count]) /* This BAR is not implemented */
393 continue; 393 continue;
394 394
395 debug ("Device %x BAR %d wants %x\n", func->device, count, bar[count]); 395 debug("Device %x BAR %d wants %x\n", func->device, count, bar[count]);
396 396
397 if (bar[count] & PCI_BASE_ADDRESS_SPACE_IO) { 397 if (bar[count] & PCI_BASE_ADDRESS_SPACE_IO) {
398 /* This is IO */ 398 /* This is IO */
399 debug ("inside IO SPACE\n"); 399 debug("inside IO SPACE\n");
400 400
401 len[count] = bar[count] & 0xFFFFFFFC; 401 len[count] = bar[count] & 0xFFFFFFFC;
402 len[count] = ~len[count] + 1; 402 len[count] = ~len[count] + 1;
403 403
404 debug ("len[count] in IO %x, count %d\n", len[count], count); 404 debug("len[count] in IO %x, count %d\n", len[count], count);
405 405
406 io[count] = kzalloc(sizeof(struct resource_node), GFP_KERNEL); 406 io[count] = kzalloc(sizeof(struct resource_node), GFP_KERNEL);
407 407
408 if (!io[count]) { 408 if (!io[count]) {
409 err ("out of system memory\n"); 409 err("out of system memory\n");
410 return -ENOMEM; 410 return -ENOMEM;
411 } 411 }
412 io[count]->type = IO; 412 io[count]->type = IO;
@@ -414,36 +414,36 @@ static int configure_device (struct pci_func *func)
414 io[count]->devfunc = PCI_DEVFN(func->device, func->function); 414 io[count]->devfunc = PCI_DEVFN(func->device, func->function);
415 io[count]->len = len[count]; 415 io[count]->len = len[count];
416 if (ibmphp_check_resource(io[count], 0) == 0) { 416 if (ibmphp_check_resource(io[count], 0) == 0) {
417 ibmphp_add_resource (io[count]); 417 ibmphp_add_resource(io[count]);
418 func->io[count] = io[count]; 418 func->io[count] = io[count];
419 } else { 419 } else {
420 err ("cannot allocate requested io for bus %x device %x function %x len %x\n", 420 err("cannot allocate requested io for bus %x device %x function %x len %x\n",
421 func->busno, func->device, func->function, len[count]); 421 func->busno, func->device, func->function, len[count]);
422 kfree (io[count]); 422 kfree(io[count]);
423 return -EIO; 423 return -EIO;
424 } 424 }
425 pci_bus_write_config_dword (ibmphp_pci_bus, devfn, address[count], func->io[count]->start); 425 pci_bus_write_config_dword(ibmphp_pci_bus, devfn, address[count], func->io[count]->start);
426 426
427 /* _______________This is for debugging purposes only_____________________ */ 427 /* _______________This is for debugging purposes only_____________________ */
428 debug ("b4 writing, the IO address is %x\n", func->io[count]->start); 428 debug("b4 writing, the IO address is %x\n", func->io[count]->start);
429 pci_bus_read_config_dword (ibmphp_pci_bus, devfn, address[count], &bar[count]); 429 pci_bus_read_config_dword(ibmphp_pci_bus, devfn, address[count], &bar[count]);
430 debug ("after writing.... the start address is %x\n", bar[count]); 430 debug("after writing.... the start address is %x\n", bar[count]);
431 /* _________________________________________________________________________*/ 431 /* _________________________________________________________________________*/
432 432
433 } else { 433 } else {
434 /* This is Memory */ 434 /* This is Memory */
435 if (bar[count] & PCI_BASE_ADDRESS_MEM_PREFETCH) { 435 if (bar[count] & PCI_BASE_ADDRESS_MEM_PREFETCH) {
436 /* pfmem */ 436 /* pfmem */
437 debug ("PFMEM SPACE\n"); 437 debug("PFMEM SPACE\n");
438 438
439 len[count] = bar[count] & 0xFFFFFFF0; 439 len[count] = bar[count] & 0xFFFFFFF0;
440 len[count] = ~len[count] + 1; 440 len[count] = ~len[count] + 1;
441 441
442 debug ("len[count] in PFMEM %x, count %d\n", len[count], count); 442 debug("len[count] in PFMEM %x, count %d\n", len[count], count);
443 443
444 pfmem[count] = kzalloc(sizeof(struct resource_node), GFP_KERNEL); 444 pfmem[count] = kzalloc(sizeof(struct resource_node), GFP_KERNEL);
445 if (!pfmem[count]) { 445 if (!pfmem[count]) {
446 err ("out of system memory\n"); 446 err("out of system memory\n");
447 return -ENOMEM; 447 return -ENOMEM;
448 } 448 }
449 pfmem[count]->type = PFMEM; 449 pfmem[count]->type = PFMEM;
@@ -452,64 +452,64 @@ static int configure_device (struct pci_func *func)
452 func->function); 452 func->function);
453 pfmem[count]->len = len[count]; 453 pfmem[count]->len = len[count];
454 pfmem[count]->fromMem = 0; 454 pfmem[count]->fromMem = 0;
455 if (ibmphp_check_resource (pfmem[count], 0) == 0) { 455 if (ibmphp_check_resource(pfmem[count], 0) == 0) {
456 ibmphp_add_resource (pfmem[count]); 456 ibmphp_add_resource(pfmem[count]);
457 func->pfmem[count] = pfmem[count]; 457 func->pfmem[count] = pfmem[count];
458 } else { 458 } else {
459 mem_tmp = kzalloc(sizeof(*mem_tmp), GFP_KERNEL); 459 mem_tmp = kzalloc(sizeof(*mem_tmp), GFP_KERNEL);
460 if (!mem_tmp) { 460 if (!mem_tmp) {
461 err ("out of system memory\n"); 461 err("out of system memory\n");
462 kfree (pfmem[count]); 462 kfree(pfmem[count]);
463 return -ENOMEM; 463 return -ENOMEM;
464 } 464 }
465 mem_tmp->type = MEM; 465 mem_tmp->type = MEM;
466 mem_tmp->busno = pfmem[count]->busno; 466 mem_tmp->busno = pfmem[count]->busno;
467 mem_tmp->devfunc = pfmem[count]->devfunc; 467 mem_tmp->devfunc = pfmem[count]->devfunc;
468 mem_tmp->len = pfmem[count]->len; 468 mem_tmp->len = pfmem[count]->len;
469 debug ("there's no pfmem... going into mem.\n"); 469 debug("there's no pfmem... going into mem.\n");
470 if (ibmphp_check_resource (mem_tmp, 0) == 0) { 470 if (ibmphp_check_resource(mem_tmp, 0) == 0) {
471 ibmphp_add_resource (mem_tmp); 471 ibmphp_add_resource(mem_tmp);
472 pfmem[count]->fromMem = 1; 472 pfmem[count]->fromMem = 1;
473 pfmem[count]->rangeno = mem_tmp->rangeno; 473 pfmem[count]->rangeno = mem_tmp->rangeno;
474 pfmem[count]->start = mem_tmp->start; 474 pfmem[count]->start = mem_tmp->start;
475 pfmem[count]->end = mem_tmp->end; 475 pfmem[count]->end = mem_tmp->end;
476 ibmphp_add_pfmem_from_mem (pfmem[count]); 476 ibmphp_add_pfmem_from_mem(pfmem[count]);
477 func->pfmem[count] = pfmem[count]; 477 func->pfmem[count] = pfmem[count];
478 } else { 478 } else {
479 err ("cannot allocate requested pfmem for bus %x, device %x, len %x\n", 479 err("cannot allocate requested pfmem for bus %x, device %x, len %x\n",
480 func->busno, func->device, len[count]); 480 func->busno, func->device, len[count]);
481 kfree (mem_tmp); 481 kfree(mem_tmp);
482 kfree (pfmem[count]); 482 kfree(pfmem[count]);
483 return -EIO; 483 return -EIO;
484 } 484 }
485 } 485 }
486 486
487 pci_bus_write_config_dword (ibmphp_pci_bus, devfn, address[count], func->pfmem[count]->start); 487 pci_bus_write_config_dword(ibmphp_pci_bus, devfn, address[count], func->pfmem[count]->start);
488 488
489 /*_______________This is for debugging purposes only______________________________*/ 489 /*_______________This is for debugging purposes only______________________________*/
490 debug ("b4 writing, start address is %x\n", func->pfmem[count]->start); 490 debug("b4 writing, start address is %x\n", func->pfmem[count]->start);
491 pci_bus_read_config_dword (ibmphp_pci_bus, devfn, address[count], &bar[count]); 491 pci_bus_read_config_dword(ibmphp_pci_bus, devfn, address[count], &bar[count]);
492 debug ("after writing, start address is %x\n", bar[count]); 492 debug("after writing, start address is %x\n", bar[count]);
493 /*_________________________________________________________________________________*/ 493 /*_________________________________________________________________________________*/
494 494
495 if (bar[count] & PCI_BASE_ADDRESS_MEM_TYPE_64) { /* takes up another dword */ 495 if (bar[count] & PCI_BASE_ADDRESS_MEM_TYPE_64) { /* takes up another dword */
496 debug ("inside the mem 64 case, count %d\n", count); 496 debug("inside the mem 64 case, count %d\n", count);
497 count += 1; 497 count += 1;
498 /* on the 2nd dword, write all 0s, since we can't handle them n.e.ways */ 498 /* on the 2nd dword, write all 0s, since we can't handle them n.e.ways */
499 pci_bus_write_config_dword (ibmphp_pci_bus, devfn, address[count], 0x00000000); 499 pci_bus_write_config_dword(ibmphp_pci_bus, devfn, address[count], 0x00000000);
500 } 500 }
501 } else { 501 } else {
502 /* regular memory */ 502 /* regular memory */
503 debug ("REGULAR MEM SPACE\n"); 503 debug("REGULAR MEM SPACE\n");
504 504
505 len[count] = bar[count] & 0xFFFFFFF0; 505 len[count] = bar[count] & 0xFFFFFFF0;
506 len[count] = ~len[count] + 1; 506 len[count] = ~len[count] + 1;
507 507
508 debug ("len[count] in Mem %x, count %d\n", len[count], count); 508 debug("len[count] in Mem %x, count %d\n", len[count], count);
509 509
510 mem[count] = kzalloc(sizeof(struct resource_node), GFP_KERNEL); 510 mem[count] = kzalloc(sizeof(struct resource_node), GFP_KERNEL);
511 if (!mem[count]) { 511 if (!mem[count]) {
512 err ("out of system memory\n"); 512 err("out of system memory\n");
513 return -ENOMEM; 513 return -ENOMEM;
514 } 514 }
515 mem[count]->type = MEM; 515 mem[count]->type = MEM;
@@ -517,43 +517,43 @@ static int configure_device (struct pci_func *func)
517 mem[count]->devfunc = PCI_DEVFN(func->device, 517 mem[count]->devfunc = PCI_DEVFN(func->device,
518 func->function); 518 func->function);
519 mem[count]->len = len[count]; 519 mem[count]->len = len[count];
520 if (ibmphp_check_resource (mem[count], 0) == 0) { 520 if (ibmphp_check_resource(mem[count], 0) == 0) {
521 ibmphp_add_resource (mem[count]); 521 ibmphp_add_resource(mem[count]);
522 func->mem[count] = mem[count]; 522 func->mem[count] = mem[count];
523 } else { 523 } else {
524 err ("cannot allocate requested mem for bus %x, device %x, len %x\n", 524 err("cannot allocate requested mem for bus %x, device %x, len %x\n",
525 func->busno, func->device, len[count]); 525 func->busno, func->device, len[count]);
526 kfree (mem[count]); 526 kfree(mem[count]);
527 return -EIO; 527 return -EIO;
528 } 528 }
529 pci_bus_write_config_dword (ibmphp_pci_bus, devfn, address[count], func->mem[count]->start); 529 pci_bus_write_config_dword(ibmphp_pci_bus, devfn, address[count], func->mem[count]->start);
530 /* _______________________This is for debugging purposes only _______________________*/ 530 /* _______________________This is for debugging purposes only _______________________*/
531 debug ("b4 writing, start address is %x\n", func->mem[count]->start); 531 debug("b4 writing, start address is %x\n", func->mem[count]->start);
532 pci_bus_read_config_dword (ibmphp_pci_bus, devfn, address[count], &bar[count]); 532 pci_bus_read_config_dword(ibmphp_pci_bus, devfn, address[count], &bar[count]);
533 debug ("after writing, the address is %x\n", bar[count]); 533 debug("after writing, the address is %x\n", bar[count]);
534 /* __________________________________________________________________________________*/ 534 /* __________________________________________________________________________________*/
535 535
536 if (bar[count] & PCI_BASE_ADDRESS_MEM_TYPE_64) { 536 if (bar[count] & PCI_BASE_ADDRESS_MEM_TYPE_64) {
537 /* takes up another dword */ 537 /* takes up another dword */
538 debug ("inside mem 64 case, reg. mem, count %d\n", count); 538 debug("inside mem 64 case, reg. mem, count %d\n", count);
539 count += 1; 539 count += 1;
540 /* on the 2nd dword, write all 0s, since we can't handle them n.e.ways */ 540 /* on the 2nd dword, write all 0s, since we can't handle them n.e.ways */
541 pci_bus_write_config_dword (ibmphp_pci_bus, devfn, address[count], 0x00000000); 541 pci_bus_write_config_dword(ibmphp_pci_bus, devfn, address[count], 0x00000000);
542 } 542 }
543 } 543 }
544 } /* end of mem */ 544 } /* end of mem */
545 } /* end of for */ 545 } /* end of for */
546 546
547 func->bus = 0; /* To indicate that this is not a PPB */ 547 func->bus = 0; /* To indicate that this is not a PPB */
548 pci_bus_read_config_byte (ibmphp_pci_bus, devfn, PCI_INTERRUPT_PIN, &irq); 548 pci_bus_read_config_byte(ibmphp_pci_bus, devfn, PCI_INTERRUPT_PIN, &irq);
549 if ((irq > 0x00) && (irq < 0x05)) 549 if ((irq > 0x00) && (irq < 0x05))
550 pci_bus_write_config_byte (ibmphp_pci_bus, devfn, PCI_INTERRUPT_LINE, func->irq[irq - 1]); 550 pci_bus_write_config_byte(ibmphp_pci_bus, devfn, PCI_INTERRUPT_LINE, func->irq[irq - 1]);
551 551
552 pci_bus_write_config_byte (ibmphp_pci_bus, devfn, PCI_CACHE_LINE_SIZE, CACHE); 552 pci_bus_write_config_byte(ibmphp_pci_bus, devfn, PCI_CACHE_LINE_SIZE, CACHE);
553 pci_bus_write_config_byte (ibmphp_pci_bus, devfn, PCI_LATENCY_TIMER, LATENCY); 553 pci_bus_write_config_byte(ibmphp_pci_bus, devfn, PCI_LATENCY_TIMER, LATENCY);
554 554
555 pci_bus_write_config_dword (ibmphp_pci_bus, devfn, PCI_ROM_ADDRESS, 0x00L); 555 pci_bus_write_config_dword(ibmphp_pci_bus, devfn, PCI_ROM_ADDRESS, 0x00L);
556 pci_bus_write_config_word (ibmphp_pci_bus, devfn, PCI_COMMAND, DEVICEENABLE); 556 pci_bus_write_config_word(ibmphp_pci_bus, devfn, PCI_COMMAND, DEVICEENABLE);
557 557
558 return 0; 558 return 0;
559} 559}
@@ -563,7 +563,7 @@ static int configure_device (struct pci_func *func)
563 * Parameters: pci_func 563 * Parameters: pci_func
564 * Returns: 564 * Returns:
565 ******************************************************************************/ 565 ******************************************************************************/
566static int configure_bridge (struct pci_func **func_passed, u8 slotno) 566static int configure_bridge(struct pci_func **func_passed, u8 slotno)
567{ 567{
568 int count; 568 int count;
569 int i; 569 int i;
@@ -597,7 +597,7 @@ static int configure_bridge (struct pci_func **func_passed, u8 slotno)
597 u8 irq; 597 u8 irq;
598 int retval; 598 int retval;
599 599
600 debug ("%s - enter\n", __func__); 600 debug("%s - enter\n", __func__);
601 601
602 devfn = PCI_DEVFN(func->function, func->device); 602 devfn = PCI_DEVFN(func->function, func->device);
603 ibmphp_pci_bus->number = func->busno; 603 ibmphp_pci_bus->number = func->busno;
@@ -606,43 +606,43 @@ static int configure_bridge (struct pci_func **func_passed, u8 slotno)
606 * behind it 606 * behind it
607 */ 607 */
608 608
609 pci_bus_write_config_byte (ibmphp_pci_bus, devfn, PCI_PRIMARY_BUS, func->busno); 609 pci_bus_write_config_byte(ibmphp_pci_bus, devfn, PCI_PRIMARY_BUS, func->busno);
610 610
611 /* _____________________For debugging purposes only __________________________ 611 /* _____________________For debugging purposes only __________________________
612 pci_bus_config_byte (ibmphp_pci_bus, devfn, PCI_PRIMARY_BUS, &pri_number); 612 pci_bus_config_byte(ibmphp_pci_bus, devfn, PCI_PRIMARY_BUS, &pri_number);
613 debug ("primary # written into the bridge is %x\n", pri_number); 613 debug("primary # written into the bridge is %x\n", pri_number);
614 ___________________________________________________________________________*/ 614 ___________________________________________________________________________*/
615 615
616 /* in EBDA, only get allocated 1 additional bus # per slot */ 616 /* in EBDA, only get allocated 1 additional bus # per slot */
617 sec_number = find_sec_number (func->busno, slotno); 617 sec_number = find_sec_number(func->busno, slotno);
618 if (sec_number == 0xff) { 618 if (sec_number == 0xff) {
619 err ("cannot allocate secondary bus number for the bridged device\n"); 619 err("cannot allocate secondary bus number for the bridged device\n");
620 return -EINVAL; 620 return -EINVAL;
621 } 621 }
622 622
623 debug ("after find_sec_number, the number we got is %x\n", sec_number); 623 debug("after find_sec_number, the number we got is %x\n", sec_number);
624 debug ("AFTER FIND_SEC_NUMBER, func->busno IS %x\n", func->busno); 624 debug("AFTER FIND_SEC_NUMBER, func->busno IS %x\n", func->busno);
625 625
626 pci_bus_write_config_byte (ibmphp_pci_bus, devfn, PCI_SECONDARY_BUS, sec_number); 626 pci_bus_write_config_byte(ibmphp_pci_bus, devfn, PCI_SECONDARY_BUS, sec_number);
627 627
628 /* __________________For debugging purposes only __________________________________ 628 /* __________________For debugging purposes only __________________________________
629 pci_bus_read_config_byte (ibmphp_pci_bus, devfn, PCI_SECONDARY_BUS, &sec_number); 629 pci_bus_read_config_byte(ibmphp_pci_bus, devfn, PCI_SECONDARY_BUS, &sec_number);
630 debug ("sec_number after write/read is %x\n", sec_number); 630 debug("sec_number after write/read is %x\n", sec_number);
631 ________________________________________________________________________________*/ 631 ________________________________________________________________________________*/
632 632
633 pci_bus_write_config_byte (ibmphp_pci_bus, devfn, PCI_SUBORDINATE_BUS, sec_number); 633 pci_bus_write_config_byte(ibmphp_pci_bus, devfn, PCI_SUBORDINATE_BUS, sec_number);
634 634
635 /* __________________For debugging purposes only ____________________________________ 635 /* __________________For debugging purposes only ____________________________________
636 pci_bus_read_config_byte (ibmphp_pci_bus, devfn, PCI_SUBORDINATE_BUS, &sec_number); 636 pci_bus_read_config_byte(ibmphp_pci_bus, devfn, PCI_SUBORDINATE_BUS, &sec_number);
637 debug ("subordinate number after write/read is %x\n", sec_number); 637 debug("subordinate number after write/read is %x\n", sec_number);
638 __________________________________________________________________________________*/ 638 __________________________________________________________________________________*/
639 639
640 pci_bus_write_config_byte (ibmphp_pci_bus, devfn, PCI_CACHE_LINE_SIZE, CACHE); 640 pci_bus_write_config_byte(ibmphp_pci_bus, devfn, PCI_CACHE_LINE_SIZE, CACHE);
641 pci_bus_write_config_byte (ibmphp_pci_bus, devfn, PCI_LATENCY_TIMER, LATENCY); 641 pci_bus_write_config_byte(ibmphp_pci_bus, devfn, PCI_LATENCY_TIMER, LATENCY);
642 pci_bus_write_config_byte (ibmphp_pci_bus, devfn, PCI_SEC_LATENCY_TIMER, LATENCY); 642 pci_bus_write_config_byte(ibmphp_pci_bus, devfn, PCI_SEC_LATENCY_TIMER, LATENCY);
643 643
644 debug ("func->busno is %x\n", func->busno); 644 debug("func->busno is %x\n", func->busno);
645 debug ("sec_number after writing is %x\n", sec_number); 645 debug("sec_number after writing is %x\n", sec_number);
646 646
647 647
648 /* !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! 648 /* !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
@@ -652,29 +652,29 @@ static int configure_bridge (struct pci_func **func_passed, u8 slotno)
652 652
653 /* First we need to allocate mem/io for the bridge itself in case it needs it */ 653 /* First we need to allocate mem/io for the bridge itself in case it needs it */
654 for (count = 0; address[count]; count++) { /* for 2 BARs */ 654 for (count = 0; address[count]; count++) { /* for 2 BARs */
655 pci_bus_write_config_dword (ibmphp_pci_bus, devfn, address[count], 0xFFFFFFFF); 655 pci_bus_write_config_dword(ibmphp_pci_bus, devfn, address[count], 0xFFFFFFFF);
656 pci_bus_read_config_dword (ibmphp_pci_bus, devfn, address[count], &bar[count]); 656 pci_bus_read_config_dword(ibmphp_pci_bus, devfn, address[count], &bar[count]);
657 657
658 if (!bar[count]) { 658 if (!bar[count]) {
659 /* This BAR is not implemented */ 659 /* This BAR is not implemented */
660 debug ("so we come here then, eh?, count = %d\n", count); 660 debug("so we come here then, eh?, count = %d\n", count);
661 continue; 661 continue;
662 } 662 }
663 // tmp_bar = bar[count]; 663 // tmp_bar = bar[count];
664 664
665 debug ("Bar %d wants %x\n", count, bar[count]); 665 debug("Bar %d wants %x\n", count, bar[count]);
666 666
667 if (bar[count] & PCI_BASE_ADDRESS_SPACE_IO) { 667 if (bar[count] & PCI_BASE_ADDRESS_SPACE_IO) {
668 /* This is IO */ 668 /* This is IO */
669 len[count] = bar[count] & 0xFFFFFFFC; 669 len[count] = bar[count] & 0xFFFFFFFC;
670 len[count] = ~len[count] + 1; 670 len[count] = ~len[count] + 1;
671 671
672 debug ("len[count] in IO = %x\n", len[count]); 672 debug("len[count] in IO = %x\n", len[count]);
673 673
674 bus_io[count] = kzalloc(sizeof(struct resource_node), GFP_KERNEL); 674 bus_io[count] = kzalloc(sizeof(struct resource_node), GFP_KERNEL);
675 675
676 if (!bus_io[count]) { 676 if (!bus_io[count]) {
677 err ("out of system memory\n"); 677 err("out of system memory\n");
678 retval = -ENOMEM; 678 retval = -ENOMEM;
679 goto error; 679 goto error;
680 } 680 }
@@ -683,17 +683,17 @@ static int configure_bridge (struct pci_func **func_passed, u8 slotno)
683 bus_io[count]->devfunc = PCI_DEVFN(func->device, 683 bus_io[count]->devfunc = PCI_DEVFN(func->device,
684 func->function); 684 func->function);
685 bus_io[count]->len = len[count]; 685 bus_io[count]->len = len[count];
686 if (ibmphp_check_resource (bus_io[count], 0) == 0) { 686 if (ibmphp_check_resource(bus_io[count], 0) == 0) {
687 ibmphp_add_resource (bus_io[count]); 687 ibmphp_add_resource(bus_io[count]);
688 func->io[count] = bus_io[count]; 688 func->io[count] = bus_io[count];
689 } else { 689 } else {
690 err ("cannot allocate requested io for bus %x, device %x, len %x\n", 690 err("cannot allocate requested io for bus %x, device %x, len %x\n",
691 func->busno, func->device, len[count]); 691 func->busno, func->device, len[count]);
692 kfree (bus_io[count]); 692 kfree(bus_io[count]);
693 return -EIO; 693 return -EIO;
694 } 694 }
695 695
696 pci_bus_write_config_dword (ibmphp_pci_bus, devfn, address[count], func->io[count]->start); 696 pci_bus_write_config_dword(ibmphp_pci_bus, devfn, address[count], func->io[count]->start);
697 697
698 } else { 698 } else {
699 /* This is Memory */ 699 /* This is Memory */
@@ -702,11 +702,11 @@ static int configure_bridge (struct pci_func **func_passed, u8 slotno)
702 len[count] = bar[count] & 0xFFFFFFF0; 702 len[count] = bar[count] & 0xFFFFFFF0;
703 len[count] = ~len[count] + 1; 703 len[count] = ~len[count] + 1;
704 704
705 debug ("len[count] in PFMEM = %x\n", len[count]); 705 debug("len[count] in PFMEM = %x\n", len[count]);
706 706
707 bus_pfmem[count] = kzalloc(sizeof(struct resource_node), GFP_KERNEL); 707 bus_pfmem[count] = kzalloc(sizeof(struct resource_node), GFP_KERNEL);
708 if (!bus_pfmem[count]) { 708 if (!bus_pfmem[count]) {
709 err ("out of system memory\n"); 709 err("out of system memory\n");
710 retval = -ENOMEM; 710 retval = -ENOMEM;
711 goto error; 711 goto error;
712 } 712 }
@@ -716,13 +716,13 @@ static int configure_bridge (struct pci_func **func_passed, u8 slotno)
716 func->function); 716 func->function);
717 bus_pfmem[count]->len = len[count]; 717 bus_pfmem[count]->len = len[count];
718 bus_pfmem[count]->fromMem = 0; 718 bus_pfmem[count]->fromMem = 0;
719 if (ibmphp_check_resource (bus_pfmem[count], 0) == 0) { 719 if (ibmphp_check_resource(bus_pfmem[count], 0) == 0) {
720 ibmphp_add_resource (bus_pfmem[count]); 720 ibmphp_add_resource(bus_pfmem[count]);
721 func->pfmem[count] = bus_pfmem[count]; 721 func->pfmem[count] = bus_pfmem[count];
722 } else { 722 } else {
723 mem_tmp = kzalloc(sizeof(*mem_tmp), GFP_KERNEL); 723 mem_tmp = kzalloc(sizeof(*mem_tmp), GFP_KERNEL);
724 if (!mem_tmp) { 724 if (!mem_tmp) {
725 err ("out of system memory\n"); 725 err("out of system memory\n");
726 retval = -ENOMEM; 726 retval = -ENOMEM;
727 goto error; 727 goto error;
728 } 728 }
@@ -730,28 +730,28 @@ static int configure_bridge (struct pci_func **func_passed, u8 slotno)
730 mem_tmp->busno = bus_pfmem[count]->busno; 730 mem_tmp->busno = bus_pfmem[count]->busno;
731 mem_tmp->devfunc = bus_pfmem[count]->devfunc; 731 mem_tmp->devfunc = bus_pfmem[count]->devfunc;
732 mem_tmp->len = bus_pfmem[count]->len; 732 mem_tmp->len = bus_pfmem[count]->len;
733 if (ibmphp_check_resource (mem_tmp, 0) == 0) { 733 if (ibmphp_check_resource(mem_tmp, 0) == 0) {
734 ibmphp_add_resource (mem_tmp); 734 ibmphp_add_resource(mem_tmp);
735 bus_pfmem[count]->fromMem = 1; 735 bus_pfmem[count]->fromMem = 1;
736 bus_pfmem[count]->rangeno = mem_tmp->rangeno; 736 bus_pfmem[count]->rangeno = mem_tmp->rangeno;
737 ibmphp_add_pfmem_from_mem (bus_pfmem[count]); 737 ibmphp_add_pfmem_from_mem(bus_pfmem[count]);
738 func->pfmem[count] = bus_pfmem[count]; 738 func->pfmem[count] = bus_pfmem[count];
739 } else { 739 } else {
740 err ("cannot allocate requested pfmem for bus %x, device %x, len %x\n", 740 err("cannot allocate requested pfmem for bus %x, device %x, len %x\n",
741 func->busno, func->device, len[count]); 741 func->busno, func->device, len[count]);
742 kfree (mem_tmp); 742 kfree(mem_tmp);
743 kfree (bus_pfmem[count]); 743 kfree(bus_pfmem[count]);
744 return -EIO; 744 return -EIO;
745 } 745 }
746 } 746 }
747 747
748 pci_bus_write_config_dword (ibmphp_pci_bus, devfn, address[count], func->pfmem[count]->start); 748 pci_bus_write_config_dword(ibmphp_pci_bus, devfn, address[count], func->pfmem[count]->start);
749 749
750 if (bar[count] & PCI_BASE_ADDRESS_MEM_TYPE_64) { 750 if (bar[count] & PCI_BASE_ADDRESS_MEM_TYPE_64) {
751 /* takes up another dword */ 751 /* takes up another dword */
752 count += 1; 752 count += 1;
753 /* on the 2nd dword, write all 0s, since we can't handle them n.e.ways */ 753 /* on the 2nd dword, write all 0s, since we can't handle them n.e.ways */
754 pci_bus_write_config_dword (ibmphp_pci_bus, devfn, address[count], 0x00000000); 754 pci_bus_write_config_dword(ibmphp_pci_bus, devfn, address[count], 0x00000000);
755 755
756 } 756 }
757 } else { 757 } else {
@@ -759,11 +759,11 @@ static int configure_bridge (struct pci_func **func_passed, u8 slotno)
759 len[count] = bar[count] & 0xFFFFFFF0; 759 len[count] = bar[count] & 0xFFFFFFF0;
760 len[count] = ~len[count] + 1; 760 len[count] = ~len[count] + 1;
761 761
762 debug ("len[count] in Memory is %x\n", len[count]); 762 debug("len[count] in Memory is %x\n", len[count]);
763 763
764 bus_mem[count] = kzalloc(sizeof(struct resource_node), GFP_KERNEL); 764 bus_mem[count] = kzalloc(sizeof(struct resource_node), GFP_KERNEL);
765 if (!bus_mem[count]) { 765 if (!bus_mem[count]) {
766 err ("out of system memory\n"); 766 err("out of system memory\n");
767 retval = -ENOMEM; 767 retval = -ENOMEM;
768 goto error; 768 goto error;
769 } 769 }
@@ -772,23 +772,23 @@ static int configure_bridge (struct pci_func **func_passed, u8 slotno)
772 bus_mem[count]->devfunc = PCI_DEVFN(func->device, 772 bus_mem[count]->devfunc = PCI_DEVFN(func->device,
773 func->function); 773 func->function);
774 bus_mem[count]->len = len[count]; 774 bus_mem[count]->len = len[count];
775 if (ibmphp_check_resource (bus_mem[count], 0) == 0) { 775 if (ibmphp_check_resource(bus_mem[count], 0) == 0) {
776 ibmphp_add_resource (bus_mem[count]); 776 ibmphp_add_resource(bus_mem[count]);
777 func->mem[count] = bus_mem[count]; 777 func->mem[count] = bus_mem[count];
778 } else { 778 } else {
779 err ("cannot allocate requested mem for bus %x, device %x, len %x\n", 779 err("cannot allocate requested mem for bus %x, device %x, len %x\n",
780 func->busno, func->device, len[count]); 780 func->busno, func->device, len[count]);
781 kfree (bus_mem[count]); 781 kfree(bus_mem[count]);
782 return -EIO; 782 return -EIO;
783 } 783 }
784 784
785 pci_bus_write_config_dword (ibmphp_pci_bus, devfn, address[count], func->mem[count]->start); 785 pci_bus_write_config_dword(ibmphp_pci_bus, devfn, address[count], func->mem[count]->start);
786 786
787 if (bar[count] & PCI_BASE_ADDRESS_MEM_TYPE_64) { 787 if (bar[count] & PCI_BASE_ADDRESS_MEM_TYPE_64) {
788 /* takes up another dword */ 788 /* takes up another dword */
789 count += 1; 789 count += 1;
790 /* on the 2nd dword, write all 0s, since we can't handle them n.e.ways */ 790 /* on the 2nd dword, write all 0s, since we can't handle them n.e.ways */
791 pci_bus_write_config_dword (ibmphp_pci_bus, devfn, address[count], 0x00000000); 791 pci_bus_write_config_dword(ibmphp_pci_bus, devfn, address[count], 0x00000000);
792 792
793 } 793 }
794 } 794 }
@@ -796,45 +796,45 @@ static int configure_bridge (struct pci_func **func_passed, u8 slotno)
796 } /* end of for */ 796 } /* end of for */
797 797
798 /* Now need to see how much space the devices behind the bridge needed */ 798 /* Now need to see how much space the devices behind the bridge needed */
799 amount_needed = scan_behind_bridge (func, sec_number); 799 amount_needed = scan_behind_bridge(func, sec_number);
800 if (amount_needed == NULL) 800 if (amount_needed == NULL)
801 return -ENOMEM; 801 return -ENOMEM;
802 802
803 ibmphp_pci_bus->number = func->busno; 803 ibmphp_pci_bus->number = func->busno;
804 debug ("after coming back from scan_behind_bridge\n"); 804 debug("after coming back from scan_behind_bridge\n");
805 debug ("amount_needed->not_correct = %x\n", amount_needed->not_correct); 805 debug("amount_needed->not_correct = %x\n", amount_needed->not_correct);
806 debug ("amount_needed->io = %x\n", amount_needed->io); 806 debug("amount_needed->io = %x\n", amount_needed->io);
807 debug ("amount_needed->mem = %x\n", amount_needed->mem); 807 debug("amount_needed->mem = %x\n", amount_needed->mem);
808 debug ("amount_needed->pfmem = %x\n", amount_needed->pfmem); 808 debug("amount_needed->pfmem = %x\n", amount_needed->pfmem);
809 809
810 if (amount_needed->not_correct) { 810 if (amount_needed->not_correct) {
811 debug ("amount_needed is not correct\n"); 811 debug("amount_needed is not correct\n");
812 for (count = 0; address[count]; count++) { 812 for (count = 0; address[count]; count++) {
813 /* for 2 BARs */ 813 /* for 2 BARs */
814 if (bus_io[count]) { 814 if (bus_io[count]) {
815 ibmphp_remove_resource (bus_io[count]); 815 ibmphp_remove_resource(bus_io[count]);
816 func->io[count] = NULL; 816 func->io[count] = NULL;
817 } else if (bus_pfmem[count]) { 817 } else if (bus_pfmem[count]) {
818 ibmphp_remove_resource (bus_pfmem[count]); 818 ibmphp_remove_resource(bus_pfmem[count]);
819 func->pfmem[count] = NULL; 819 func->pfmem[count] = NULL;
820 } else if (bus_mem[count]) { 820 } else if (bus_mem[count]) {
821 ibmphp_remove_resource (bus_mem[count]); 821 ibmphp_remove_resource(bus_mem[count]);
822 func->mem[count] = NULL; 822 func->mem[count] = NULL;
823 } 823 }
824 } 824 }
825 kfree (amount_needed); 825 kfree(amount_needed);
826 return -ENODEV; 826 return -ENODEV;
827 } 827 }
828 828
829 if (!amount_needed->io) { 829 if (!amount_needed->io) {
830 debug ("it doesn't want IO?\n"); 830 debug("it doesn't want IO?\n");
831 flag_io = 1; 831 flag_io = 1;
832 } else { 832 } else {
833 debug ("it wants %x IO behind the bridge\n", amount_needed->io); 833 debug("it wants %x IO behind the bridge\n", amount_needed->io);
834 io = kzalloc(sizeof(*io), GFP_KERNEL); 834 io = kzalloc(sizeof(*io), GFP_KERNEL);
835 835
836 if (!io) { 836 if (!io) {
837 err ("out of system memory\n"); 837 err("out of system memory\n");
838 retval = -ENOMEM; 838 retval = -ENOMEM;
839 goto error; 839 goto error;
840 } 840 }
@@ -842,21 +842,21 @@ static int configure_bridge (struct pci_func **func_passed, u8 slotno)
842 io->busno = func->busno; 842 io->busno = func->busno;
843 io->devfunc = PCI_DEVFN(func->device, func->function); 843 io->devfunc = PCI_DEVFN(func->device, func->function);
844 io->len = amount_needed->io; 844 io->len = amount_needed->io;
845 if (ibmphp_check_resource (io, 1) == 0) { 845 if (ibmphp_check_resource(io, 1) == 0) {
846 debug ("were we able to add io\n"); 846 debug("were we able to add io\n");
847 ibmphp_add_resource (io); 847 ibmphp_add_resource(io);
848 flag_io = 1; 848 flag_io = 1;
849 } 849 }
850 } 850 }
851 851
852 if (!amount_needed->mem) { 852 if (!amount_needed->mem) {
853 debug ("it doesn't want n.e.memory?\n"); 853 debug("it doesn't want n.e.memory?\n");
854 flag_mem = 1; 854 flag_mem = 1;
855 } else { 855 } else {
856 debug ("it wants %x memory behind the bridge\n", amount_needed->mem); 856 debug("it wants %x memory behind the bridge\n", amount_needed->mem);
857 mem = kzalloc(sizeof(*mem), GFP_KERNEL); 857 mem = kzalloc(sizeof(*mem), GFP_KERNEL);
858 if (!mem) { 858 if (!mem) {
859 err ("out of system memory\n"); 859 err("out of system memory\n");
860 retval = -ENOMEM; 860 retval = -ENOMEM;
861 goto error; 861 goto error;
862 } 862 }
@@ -864,21 +864,21 @@ static int configure_bridge (struct pci_func **func_passed, u8 slotno)
864 mem->busno = func->busno; 864 mem->busno = func->busno;
865 mem->devfunc = PCI_DEVFN(func->device, func->function); 865 mem->devfunc = PCI_DEVFN(func->device, func->function);
866 mem->len = amount_needed->mem; 866 mem->len = amount_needed->mem;
867 if (ibmphp_check_resource (mem, 1) == 0) { 867 if (ibmphp_check_resource(mem, 1) == 0) {
868 ibmphp_add_resource (mem); 868 ibmphp_add_resource(mem);
869 flag_mem = 1; 869 flag_mem = 1;
870 debug ("were we able to add mem\n"); 870 debug("were we able to add mem\n");
871 } 871 }
872 } 872 }
873 873
874 if (!amount_needed->pfmem) { 874 if (!amount_needed->pfmem) {
875 debug ("it doesn't want n.e.pfmem mem?\n"); 875 debug("it doesn't want n.e.pfmem mem?\n");
876 flag_pfmem = 1; 876 flag_pfmem = 1;
877 } else { 877 } else {
878 debug ("it wants %x pfmemory behind the bridge\n", amount_needed->pfmem); 878 debug("it wants %x pfmemory behind the bridge\n", amount_needed->pfmem);
879 pfmem = kzalloc(sizeof(*pfmem), GFP_KERNEL); 879 pfmem = kzalloc(sizeof(*pfmem), GFP_KERNEL);
880 if (!pfmem) { 880 if (!pfmem) {
881 err ("out of system memory\n"); 881 err("out of system memory\n");
882 retval = -ENOMEM; 882 retval = -ENOMEM;
883 goto error; 883 goto error;
884 } 884 }
@@ -887,13 +887,13 @@ static int configure_bridge (struct pci_func **func_passed, u8 slotno)
887 pfmem->devfunc = PCI_DEVFN(func->device, func->function); 887 pfmem->devfunc = PCI_DEVFN(func->device, func->function);
888 pfmem->len = amount_needed->pfmem; 888 pfmem->len = amount_needed->pfmem;
889 pfmem->fromMem = 0; 889 pfmem->fromMem = 0;
890 if (ibmphp_check_resource (pfmem, 1) == 0) { 890 if (ibmphp_check_resource(pfmem, 1) == 0) {
891 ibmphp_add_resource (pfmem); 891 ibmphp_add_resource(pfmem);
892 flag_pfmem = 1; 892 flag_pfmem = 1;
893 } else { 893 } else {
894 mem_tmp = kzalloc(sizeof(*mem_tmp), GFP_KERNEL); 894 mem_tmp = kzalloc(sizeof(*mem_tmp), GFP_KERNEL);
895 if (!mem_tmp) { 895 if (!mem_tmp) {
896 err ("out of system memory\n"); 896 err("out of system memory\n");
897 retval = -ENOMEM; 897 retval = -ENOMEM;
898 goto error; 898 goto error;
899 } 899 }
@@ -901,18 +901,18 @@ static int configure_bridge (struct pci_func **func_passed, u8 slotno)
901 mem_tmp->busno = pfmem->busno; 901 mem_tmp->busno = pfmem->busno;
902 mem_tmp->devfunc = pfmem->devfunc; 902 mem_tmp->devfunc = pfmem->devfunc;
903 mem_tmp->len = pfmem->len; 903 mem_tmp->len = pfmem->len;
904 if (ibmphp_check_resource (mem_tmp, 1) == 0) { 904 if (ibmphp_check_resource(mem_tmp, 1) == 0) {
905 ibmphp_add_resource (mem_tmp); 905 ibmphp_add_resource(mem_tmp);
906 pfmem->fromMem = 1; 906 pfmem->fromMem = 1;
907 pfmem->rangeno = mem_tmp->rangeno; 907 pfmem->rangeno = mem_tmp->rangeno;
908 ibmphp_add_pfmem_from_mem (pfmem); 908 ibmphp_add_pfmem_from_mem(pfmem);
909 flag_pfmem = 1; 909 flag_pfmem = 1;
910 } 910 }
911 } 911 }
912 } 912 }
913 913
914 debug ("b4 if (flag_io && flag_mem && flag_pfmem)\n"); 914 debug("b4 if (flag_io && flag_mem && flag_pfmem)\n");
915 debug ("flag_io = %x, flag_mem = %x, flag_pfmem = %x\n", flag_io, flag_mem, flag_pfmem); 915 debug("flag_io = %x, flag_mem = %x, flag_pfmem = %x\n", flag_io, flag_mem, flag_pfmem);
916 916
917 if (flag_io && flag_mem && flag_pfmem) { 917 if (flag_io && flag_mem && flag_pfmem) {
918 /* If on bootup, there was a bridged card in this slot, 918 /* If on bootup, there was a bridged card in this slot,
@@ -920,127 +920,127 @@ static int configure_bridge (struct pci_func **func_passed, u8 slotno)
920 * back again, there's no way for us to remove the bus 920 * back again, there's no way for us to remove the bus
921 * struct, so no need to kmalloc, can use existing node 921 * struct, so no need to kmalloc, can use existing node
922 */ 922 */
923 bus = ibmphp_find_res_bus (sec_number); 923 bus = ibmphp_find_res_bus(sec_number);
924 if (!bus) { 924 if (!bus) {
925 bus = kzalloc(sizeof(*bus), GFP_KERNEL); 925 bus = kzalloc(sizeof(*bus), GFP_KERNEL);
926 if (!bus) { 926 if (!bus) {
927 err ("out of system memory\n"); 927 err("out of system memory\n");
928 retval = -ENOMEM; 928 retval = -ENOMEM;
929 goto error; 929 goto error;
930 } 930 }
931 bus->busno = sec_number; 931 bus->busno = sec_number;
932 debug ("b4 adding new bus\n"); 932 debug("b4 adding new bus\n");
933 rc = add_new_bus (bus, io, mem, pfmem, func->busno); 933 rc = add_new_bus(bus, io, mem, pfmem, func->busno);
934 } else if (!(bus->rangeIO) && !(bus->rangeMem) && !(bus->rangePFMem)) 934 } else if (!(bus->rangeIO) && !(bus->rangeMem) && !(bus->rangePFMem))
935 rc = add_new_bus (bus, io, mem, pfmem, 0xFF); 935 rc = add_new_bus(bus, io, mem, pfmem, 0xFF);
936 else { 936 else {
937 err ("expected bus structure not empty?\n"); 937 err("expected bus structure not empty?\n");
938 retval = -EIO; 938 retval = -EIO;
939 goto error; 939 goto error;
940 } 940 }
941 if (rc) { 941 if (rc) {
942 if (rc == -ENOMEM) { 942 if (rc == -ENOMEM) {
943 ibmphp_remove_bus (bus, func->busno); 943 ibmphp_remove_bus(bus, func->busno);
944 kfree (amount_needed); 944 kfree(amount_needed);
945 return rc; 945 return rc;
946 } 946 }
947 retval = rc; 947 retval = rc;
948 goto error; 948 goto error;
949 } 949 }
950 pci_bus_read_config_byte (ibmphp_pci_bus, devfn, PCI_IO_BASE, &io_base); 950 pci_bus_read_config_byte(ibmphp_pci_bus, devfn, PCI_IO_BASE, &io_base);
951 pci_bus_read_config_word (ibmphp_pci_bus, devfn, PCI_PREF_MEMORY_BASE, &pfmem_base); 951 pci_bus_read_config_word(ibmphp_pci_bus, devfn, PCI_PREF_MEMORY_BASE, &pfmem_base);
952 952
953 if ((io_base & PCI_IO_RANGE_TYPE_MASK) == PCI_IO_RANGE_TYPE_32) { 953 if ((io_base & PCI_IO_RANGE_TYPE_MASK) == PCI_IO_RANGE_TYPE_32) {
954 debug ("io 32\n"); 954 debug("io 32\n");
955 need_io_upper = 1; 955 need_io_upper = 1;
956 } 956 }
957 if ((pfmem_base & PCI_PREF_RANGE_TYPE_MASK) == PCI_PREF_RANGE_TYPE_64) { 957 if ((pfmem_base & PCI_PREF_RANGE_TYPE_MASK) == PCI_PREF_RANGE_TYPE_64) {
958 debug ("pfmem 64\n"); 958 debug("pfmem 64\n");
959 need_pfmem_upper = 1; 959 need_pfmem_upper = 1;
960 } 960 }
961 961
962 if (bus->noIORanges) { 962 if (bus->noIORanges) {
963 pci_bus_write_config_byte (ibmphp_pci_bus, devfn, PCI_IO_BASE, 0x00 | bus->rangeIO->start >> 8); 963 pci_bus_write_config_byte(ibmphp_pci_bus, devfn, PCI_IO_BASE, 0x00 | bus->rangeIO->start >> 8);
964 pci_bus_write_config_byte (ibmphp_pci_bus, devfn, PCI_IO_LIMIT, 0x00 | bus->rangeIO->end >> 8); 964 pci_bus_write_config_byte(ibmphp_pci_bus, devfn, PCI_IO_LIMIT, 0x00 | bus->rangeIO->end >> 8);
965 965
966 /* _______________This is for debugging purposes only ____________________ 966 /* _______________This is for debugging purposes only ____________________
967 pci_bus_read_config_byte (ibmphp_pci_bus, devfn, PCI_IO_BASE, &temp); 967 pci_bus_read_config_byte(ibmphp_pci_bus, devfn, PCI_IO_BASE, &temp);
968 debug ("io_base = %x\n", (temp & PCI_IO_RANGE_TYPE_MASK) << 8); 968 debug("io_base = %x\n", (temp & PCI_IO_RANGE_TYPE_MASK) << 8);
969 pci_bus_read_config_byte (ibmphp_pci_bus, devfn, PCI_IO_LIMIT, &temp); 969 pci_bus_read_config_byte(ibmphp_pci_bus, devfn, PCI_IO_LIMIT, &temp);
970 debug ("io_limit = %x\n", (temp & PCI_IO_RANGE_TYPE_MASK) << 8); 970 debug("io_limit = %x\n", (temp & PCI_IO_RANGE_TYPE_MASK) << 8);
971 ________________________________________________________________________*/ 971 ________________________________________________________________________*/
972 972
973 if (need_io_upper) { /* since can't support n.e.ways */ 973 if (need_io_upper) { /* since can't support n.e.ways */
974 pci_bus_write_config_word (ibmphp_pci_bus, devfn, PCI_IO_BASE_UPPER16, 0x0000); 974 pci_bus_write_config_word(ibmphp_pci_bus, devfn, PCI_IO_BASE_UPPER16, 0x0000);
975 pci_bus_write_config_word (ibmphp_pci_bus, devfn, PCI_IO_LIMIT_UPPER16, 0x0000); 975 pci_bus_write_config_word(ibmphp_pci_bus, devfn, PCI_IO_LIMIT_UPPER16, 0x0000);
976 } 976 }
977 } else { 977 } else {
978 pci_bus_write_config_byte (ibmphp_pci_bus, devfn, PCI_IO_BASE, 0x00); 978 pci_bus_write_config_byte(ibmphp_pci_bus, devfn, PCI_IO_BASE, 0x00);
979 pci_bus_write_config_byte (ibmphp_pci_bus, devfn, PCI_IO_LIMIT, 0x00); 979 pci_bus_write_config_byte(ibmphp_pci_bus, devfn, PCI_IO_LIMIT, 0x00);
980 } 980 }
981 981
982 if (bus->noMemRanges) { 982 if (bus->noMemRanges) {
983 pci_bus_write_config_word (ibmphp_pci_bus, devfn, PCI_MEMORY_BASE, 0x0000 | bus->rangeMem->start >> 16); 983 pci_bus_write_config_word(ibmphp_pci_bus, devfn, PCI_MEMORY_BASE, 0x0000 | bus->rangeMem->start >> 16);
984 pci_bus_write_config_word (ibmphp_pci_bus, devfn, PCI_MEMORY_LIMIT, 0x0000 | bus->rangeMem->end >> 16); 984 pci_bus_write_config_word(ibmphp_pci_bus, devfn, PCI_MEMORY_LIMIT, 0x0000 | bus->rangeMem->end >> 16);
985 985
986 /* ____________________This is for debugging purposes only ________________________ 986 /* ____________________This is for debugging purposes only ________________________
987 pci_bus_read_config_word (ibmphp_pci_bus, devfn, PCI_MEMORY_BASE, &temp); 987 pci_bus_read_config_word(ibmphp_pci_bus, devfn, PCI_MEMORY_BASE, &temp);
988 debug ("mem_base = %x\n", (temp & PCI_MEMORY_RANGE_TYPE_MASK) << 16); 988 debug("mem_base = %x\n", (temp & PCI_MEMORY_RANGE_TYPE_MASK) << 16);
989 pci_bus_read_config_word (ibmphp_pci_bus, devfn, PCI_MEMORY_LIMIT, &temp); 989 pci_bus_read_config_word(ibmphp_pci_bus, devfn, PCI_MEMORY_LIMIT, &temp);
990 debug ("mem_limit = %x\n", (temp & PCI_MEMORY_RANGE_TYPE_MASK) << 16); 990 debug("mem_limit = %x\n", (temp & PCI_MEMORY_RANGE_TYPE_MASK) << 16);
991 __________________________________________________________________________________*/ 991 __________________________________________________________________________________*/
992 992
993 } else { 993 } else {
994 pci_bus_write_config_word (ibmphp_pci_bus, devfn, PCI_MEMORY_BASE, 0xffff); 994 pci_bus_write_config_word(ibmphp_pci_bus, devfn, PCI_MEMORY_BASE, 0xffff);
995 pci_bus_write_config_word (ibmphp_pci_bus, devfn, PCI_MEMORY_LIMIT, 0x0000); 995 pci_bus_write_config_word(ibmphp_pci_bus, devfn, PCI_MEMORY_LIMIT, 0x0000);
996 } 996 }
997 if (bus->noPFMemRanges) { 997 if (bus->noPFMemRanges) {
998 pci_bus_write_config_word (ibmphp_pci_bus, devfn, PCI_PREF_MEMORY_BASE, 0x0000 | bus->rangePFMem->start >> 16); 998 pci_bus_write_config_word(ibmphp_pci_bus, devfn, PCI_PREF_MEMORY_BASE, 0x0000 | bus->rangePFMem->start >> 16);
999 pci_bus_write_config_word (ibmphp_pci_bus, devfn, PCI_PREF_MEMORY_LIMIT, 0x0000 | bus->rangePFMem->end >> 16); 999 pci_bus_write_config_word(ibmphp_pci_bus, devfn, PCI_PREF_MEMORY_LIMIT, 0x0000 | bus->rangePFMem->end >> 16);
1000 1000
1001 /* __________________________This is for debugging purposes only _______________________ 1001 /* __________________________This is for debugging purposes only _______________________
1002 pci_bus_read_config_word (ibmphp_pci_bus, devfn, PCI_PREF_MEMORY_BASE, &temp); 1002 pci_bus_read_config_word(ibmphp_pci_bus, devfn, PCI_PREF_MEMORY_BASE, &temp);
1003 debug ("pfmem_base = %x", (temp & PCI_MEMORY_RANGE_TYPE_MASK) << 16); 1003 debug("pfmem_base = %x", (temp & PCI_MEMORY_RANGE_TYPE_MASK) << 16);
1004 pci_bus_read_config_word (ibmphp_pci_bus, devfn, PCI_PREF_MEMORY_LIMIT, &temp); 1004 pci_bus_read_config_word(ibmphp_pci_bus, devfn, PCI_PREF_MEMORY_LIMIT, &temp);
1005 debug ("pfmem_limit = %x\n", (temp & PCI_MEMORY_RANGE_TYPE_MASK) << 16); 1005 debug("pfmem_limit = %x\n", (temp & PCI_MEMORY_RANGE_TYPE_MASK) << 16);
1006 ______________________________________________________________________________________*/ 1006 ______________________________________________________________________________________*/
1007 1007
1008 if (need_pfmem_upper) { /* since can't support n.e.ways */ 1008 if (need_pfmem_upper) { /* since can't support n.e.ways */
1009 pci_bus_write_config_dword (ibmphp_pci_bus, devfn, PCI_PREF_BASE_UPPER32, 0x00000000); 1009 pci_bus_write_config_dword(ibmphp_pci_bus, devfn, PCI_PREF_BASE_UPPER32, 0x00000000);
1010 pci_bus_write_config_dword (ibmphp_pci_bus, devfn, PCI_PREF_LIMIT_UPPER32, 0x00000000); 1010 pci_bus_write_config_dword(ibmphp_pci_bus, devfn, PCI_PREF_LIMIT_UPPER32, 0x00000000);
1011 } 1011 }
1012 } else { 1012 } else {
1013 pci_bus_write_config_word (ibmphp_pci_bus, devfn, PCI_PREF_MEMORY_BASE, 0xffff); 1013 pci_bus_write_config_word(ibmphp_pci_bus, devfn, PCI_PREF_MEMORY_BASE, 0xffff);
1014 pci_bus_write_config_word (ibmphp_pci_bus, devfn, PCI_PREF_MEMORY_LIMIT, 0x0000); 1014 pci_bus_write_config_word(ibmphp_pci_bus, devfn, PCI_PREF_MEMORY_LIMIT, 0x0000);
1015 } 1015 }
1016 1016
1017 debug ("b4 writing control information\n"); 1017 debug("b4 writing control information\n");
1018 1018
1019 pci_bus_read_config_byte (ibmphp_pci_bus, devfn, PCI_INTERRUPT_PIN, &irq); 1019 pci_bus_read_config_byte(ibmphp_pci_bus, devfn, PCI_INTERRUPT_PIN, &irq);
1020 if ((irq > 0x00) && (irq < 0x05)) 1020 if ((irq > 0x00) && (irq < 0x05))
1021 pci_bus_write_config_byte (ibmphp_pci_bus, devfn, PCI_INTERRUPT_LINE, func->irq[irq - 1]); 1021 pci_bus_write_config_byte(ibmphp_pci_bus, devfn, PCI_INTERRUPT_LINE, func->irq[irq - 1]);
1022 /* 1022 /*
1023 pci_bus_write_config_byte (ibmphp_pci_bus, devfn, PCI_BRIDGE_CONTROL, ctrl); 1023 pci_bus_write_config_byte(ibmphp_pci_bus, devfn, PCI_BRIDGE_CONTROL, ctrl);
1024 pci_bus_write_config_byte (ibmphp_pci_bus, devfn, PCI_BRIDGE_CONTROL, PCI_BRIDGE_CTL_PARITY); 1024 pci_bus_write_config_byte(ibmphp_pci_bus, devfn, PCI_BRIDGE_CONTROL, PCI_BRIDGE_CTL_PARITY);
1025 pci_bus_write_config_byte (ibmphp_pci_bus, devfn, PCI_BRIDGE_CONTROL, PCI_BRIDGE_CTL_SERR); 1025 pci_bus_write_config_byte(ibmphp_pci_bus, devfn, PCI_BRIDGE_CONTROL, PCI_BRIDGE_CTL_SERR);
1026 */ 1026 */
1027 1027
1028 pci_bus_write_config_word (ibmphp_pci_bus, devfn, PCI_COMMAND, DEVICEENABLE); 1028 pci_bus_write_config_word(ibmphp_pci_bus, devfn, PCI_COMMAND, DEVICEENABLE);
1029 pci_bus_write_config_word (ibmphp_pci_bus, devfn, PCI_BRIDGE_CONTROL, 0x07); 1029 pci_bus_write_config_word(ibmphp_pci_bus, devfn, PCI_BRIDGE_CONTROL, 0x07);
1030 for (i = 0; i < 32; i++) { 1030 for (i = 0; i < 32; i++) {
1031 if (amount_needed->devices[i]) { 1031 if (amount_needed->devices[i]) {
1032 debug ("device where devices[i] is 1 = %x\n", i); 1032 debug("device where devices[i] is 1 = %x\n", i);
1033 func->devices[i] = 1; 1033 func->devices[i] = 1;
1034 } 1034 }
1035 } 1035 }
1036 func->bus = 1; /* For unconfiguring, to indicate it's PPB */ 1036 func->bus = 1; /* For unconfiguring, to indicate it's PPB */
1037 func_passed = &func; 1037 func_passed = &func;
1038 debug ("func->busno b4 returning is %x\n", func->busno); 1038 debug("func->busno b4 returning is %x\n", func->busno);
1039 debug ("func->busno b4 returning in the other structure is %x\n", (*func_passed)->busno); 1039 debug("func->busno b4 returning in the other structure is %x\n", (*func_passed)->busno);
1040 kfree (amount_needed); 1040 kfree(amount_needed);
1041 return 0; 1041 return 0;
1042 } else { 1042 } else {
1043 err ("Configuring bridge was unsuccessful...\n"); 1043 err("Configuring bridge was unsuccessful...\n");
1044 mem_tmp = NULL; 1044 mem_tmp = NULL;
1045 retval = -EIO; 1045 retval = -EIO;
1046 goto error; 1046 goto error;
@@ -1049,20 +1049,20 @@ static int configure_bridge (struct pci_func **func_passed, u8 slotno)
1049error: 1049error:
1050 kfree(amount_needed); 1050 kfree(amount_needed);
1051 if (pfmem) 1051 if (pfmem)
1052 ibmphp_remove_resource (pfmem); 1052 ibmphp_remove_resource(pfmem);
1053 if (io) 1053 if (io)
1054 ibmphp_remove_resource (io); 1054 ibmphp_remove_resource(io);
1055 if (mem) 1055 if (mem)
1056 ibmphp_remove_resource (mem); 1056 ibmphp_remove_resource(mem);
1057 for (i = 0; i < 2; i++) { /* for 2 BARs */ 1057 for (i = 0; i < 2; i++) { /* for 2 BARs */
1058 if (bus_io[i]) { 1058 if (bus_io[i]) {
1059 ibmphp_remove_resource (bus_io[i]); 1059 ibmphp_remove_resource(bus_io[i]);
1060 func->io[i] = NULL; 1060 func->io[i] = NULL;
1061 } else if (bus_pfmem[i]) { 1061 } else if (bus_pfmem[i]) {
1062 ibmphp_remove_resource (bus_pfmem[i]); 1062 ibmphp_remove_resource(bus_pfmem[i]);
1063 func->pfmem[i] = NULL; 1063 func->pfmem[i] = NULL;
1064 } else if (bus_mem[i]) { 1064 } else if (bus_mem[i]) {
1065 ibmphp_remove_resource (bus_mem[i]); 1065 ibmphp_remove_resource(bus_mem[i]);
1066 func->mem[i] = NULL; 1066 func->mem[i] = NULL;
1067 } 1067 }
1068 } 1068 }
@@ -1075,7 +1075,7 @@ error:
1075 * Input: bridge function 1075 * Input: bridge function
1076 * Output: amount of resources needed 1076 * Output: amount of resources needed
1077 *****************************************************************************/ 1077 *****************************************************************************/
1078static struct res_needed *scan_behind_bridge (struct pci_func *func, u8 busno) 1078static struct res_needed *scan_behind_bridge(struct pci_func *func, u8 busno)
1079{ 1079{
1080 int count, len[6]; 1080 int count, len[6];
1081 u16 vendor_id; 1081 u16 vendor_id;
@@ -1102,36 +1102,36 @@ static struct res_needed *scan_behind_bridge (struct pci_func *func, u8 busno)
1102 1102
1103 ibmphp_pci_bus->number = busno; 1103 ibmphp_pci_bus->number = busno;
1104 1104
1105 debug ("the bus_no behind the bridge is %x\n", busno); 1105 debug("the bus_no behind the bridge is %x\n", busno);
1106 debug ("scanning devices behind the bridge...\n"); 1106 debug("scanning devices behind the bridge...\n");
1107 for (device = 0; device < 32; device++) { 1107 for (device = 0; device < 32; device++) {
1108 amount->devices[device] = 0; 1108 amount->devices[device] = 0;
1109 for (function = 0; function < 8; function++) { 1109 for (function = 0; function < 8; function++) {
1110 devfn = PCI_DEVFN(device, function); 1110 devfn = PCI_DEVFN(device, function);
1111 1111
1112 pci_bus_read_config_word (ibmphp_pci_bus, devfn, PCI_VENDOR_ID, &vendor_id); 1112 pci_bus_read_config_word(ibmphp_pci_bus, devfn, PCI_VENDOR_ID, &vendor_id);
1113 1113
1114 if (vendor_id != PCI_VENDOR_ID_NOTVALID) { 1114 if (vendor_id != PCI_VENDOR_ID_NOTVALID) {
1115 /* found correct device!!! */ 1115 /* found correct device!!! */
1116 howmany++; 1116 howmany++;
1117 1117
1118 pci_bus_read_config_byte (ibmphp_pci_bus, devfn, PCI_HEADER_TYPE, &hdr_type); 1118 pci_bus_read_config_byte(ibmphp_pci_bus, devfn, PCI_HEADER_TYPE, &hdr_type);
1119 pci_bus_read_config_dword (ibmphp_pci_bus, devfn, PCI_CLASS_REVISION, &class); 1119 pci_bus_read_config_dword(ibmphp_pci_bus, devfn, PCI_CLASS_REVISION, &class);
1120 1120
1121 debug ("hdr_type behind the bridge is %x\n", hdr_type); 1121 debug("hdr_type behind the bridge is %x\n", hdr_type);
1122 if ((hdr_type & 0x7f) == PCI_HEADER_TYPE_BRIDGE) { 1122 if ((hdr_type & 0x7f) == PCI_HEADER_TYPE_BRIDGE) {
1123 err ("embedded bridges not supported for hot-plugging.\n"); 1123 err("embedded bridges not supported for hot-plugging.\n");
1124 amount->not_correct = 1; 1124 amount->not_correct = 1;
1125 return amount; 1125 return amount;
1126 } 1126 }
1127 1127
1128 class >>= 8; /* to take revision out, class = class.subclass.prog i/f */ 1128 class >>= 8; /* to take revision out, class = class.subclass.prog i/f */
1129 if (class == PCI_CLASS_NOT_DEFINED_VGA) { 1129 if (class == PCI_CLASS_NOT_DEFINED_VGA) {
1130 err ("The device %x is VGA compatible and as is not supported for hot plugging. Please choose another device.\n", device); 1130 err("The device %x is VGA compatible and as is not supported for hot plugging. Please choose another device.\n", device);
1131 amount->not_correct = 1; 1131 amount->not_correct = 1;
1132 return amount; 1132 return amount;
1133 } else if (class == PCI_CLASS_DISPLAY_VGA) { 1133 } else if (class == PCI_CLASS_DISPLAY_VGA) {
1134 err ("The device %x is not supported for hot plugging. Please choose another device.\n", device); 1134 err("The device %x is not supported for hot plugging. Please choose another device.\n", device);
1135 amount->not_correct = 1; 1135 amount->not_correct = 1;
1136 return amount; 1136 return amount;
1137 } 1137 }
@@ -1141,23 +1141,23 @@ static struct res_needed *scan_behind_bridge (struct pci_func *func, u8 busno)
1141 for (count = 0; address[count]; count++) { 1141 for (count = 0; address[count]; count++) {
1142 /* for 6 BARs */ 1142 /* for 6 BARs */
1143 /* 1143 /*
1144 pci_bus_read_config_byte (ibmphp_pci_bus, devfn, address[count], &tmp); 1144 pci_bus_read_config_byte(ibmphp_pci_bus, devfn, address[count], &tmp);
1145 if (tmp & 0x01) // IO 1145 if (tmp & 0x01) // IO
1146 pci_bus_write_config_dword (ibmphp_pci_bus, devfn, address[count], 0xFFFFFFFD); 1146 pci_bus_write_config_dword(ibmphp_pci_bus, devfn, address[count], 0xFFFFFFFD);
1147 else // MEMORY 1147 else // MEMORY
1148 pci_bus_write_config_dword (ibmphp_pci_bus, devfn, address[count], 0xFFFFFFFF); 1148 pci_bus_write_config_dword(ibmphp_pci_bus, devfn, address[count], 0xFFFFFFFF);
1149 */ 1149 */
1150 pci_bus_write_config_dword (ibmphp_pci_bus, devfn, address[count], 0xFFFFFFFF); 1150 pci_bus_write_config_dword(ibmphp_pci_bus, devfn, address[count], 0xFFFFFFFF);
1151 pci_bus_read_config_dword (ibmphp_pci_bus, devfn, address[count], &bar[count]); 1151 pci_bus_read_config_dword(ibmphp_pci_bus, devfn, address[count], &bar[count]);
1152 1152
1153 debug ("what is bar[count]? %x, count = %d\n", bar[count], count); 1153 debug("what is bar[count]? %x, count = %d\n", bar[count], count);
1154 1154
1155 if (!bar[count]) /* This BAR is not implemented */ 1155 if (!bar[count]) /* This BAR is not implemented */
1156 continue; 1156 continue;
1157 1157
1158 //tmp_bar = bar[count]; 1158 //tmp_bar = bar[count];
1159 1159
1160 debug ("count %d device %x function %x wants %x resources\n", count, device, function, bar[count]); 1160 debug("count %d device %x function %x wants %x resources\n", count, device, function, bar[count]);
1161 1161
1162 if (bar[count] & PCI_BASE_ADDRESS_SPACE_IO) { 1162 if (bar[count] & PCI_BASE_ADDRESS_SPACE_IO) {
1163 /* This is IO */ 1163 /* This is IO */
@@ -1211,7 +1211,7 @@ static struct res_needed *scan_behind_bridge (struct pci_func *func, u8 busno)
1211 * Change: we also call these functions even if we configured the card ourselves (i.e., not 1211 * Change: we also call these functions even if we configured the card ourselves (i.e., not
1212 * the bootup case), since it should work same way 1212 * the bootup case), since it should work same way
1213 */ 1213 */
1214static int unconfigure_boot_device (u8 busno, u8 device, u8 function) 1214static int unconfigure_boot_device(u8 busno, u8 device, u8 function)
1215{ 1215{
1216 u32 start_address; 1216 u32 start_address;
1217 u32 address[] = { 1217 u32 address[] = {
@@ -1234,30 +1234,30 @@ static int unconfigure_boot_device (u8 busno, u8 device, u8 function)
1234 u32 tmp_address; 1234 u32 tmp_address;
1235 unsigned int devfn; 1235 unsigned int devfn;
1236 1236
1237 debug ("%s - enter\n", __func__); 1237 debug("%s - enter\n", __func__);
1238 1238
1239 bus = ibmphp_find_res_bus (busno); 1239 bus = ibmphp_find_res_bus(busno);
1240 if (!bus) { 1240 if (!bus) {
1241 debug ("cannot find corresponding bus.\n"); 1241 debug("cannot find corresponding bus.\n");
1242 return -EINVAL; 1242 return -EINVAL;
1243 } 1243 }
1244 1244
1245 devfn = PCI_DEVFN(device, function); 1245 devfn = PCI_DEVFN(device, function);
1246 ibmphp_pci_bus->number = busno; 1246 ibmphp_pci_bus->number = busno;
1247 for (count = 0; address[count]; count++) { /* for 6 BARs */ 1247 for (count = 0; address[count]; count++) { /* for 6 BARs */
1248 pci_bus_read_config_dword (ibmphp_pci_bus, devfn, address[count], &start_address); 1248 pci_bus_read_config_dword(ibmphp_pci_bus, devfn, address[count], &start_address);
1249 1249
1250 /* We can do this here, b/c by that time the device driver of the card has been stopped */ 1250 /* We can do this here, b/c by that time the device driver of the card has been stopped */
1251 1251
1252 pci_bus_write_config_dword (ibmphp_pci_bus, devfn, address[count], 0xFFFFFFFF); 1252 pci_bus_write_config_dword(ibmphp_pci_bus, devfn, address[count], 0xFFFFFFFF);
1253 pci_bus_read_config_dword (ibmphp_pci_bus, devfn, address[count], &size); 1253 pci_bus_read_config_dword(ibmphp_pci_bus, devfn, address[count], &size);
1254 pci_bus_write_config_dword (ibmphp_pci_bus, devfn, address[count], start_address); 1254 pci_bus_write_config_dword(ibmphp_pci_bus, devfn, address[count], start_address);
1255 1255
1256 debug ("start_address is %x\n", start_address); 1256 debug("start_address is %x\n", start_address);
1257 debug ("busno, device, function %x %x %x\n", busno, device, function); 1257 debug("busno, device, function %x %x %x\n", busno, device, function);
1258 if (!size) { 1258 if (!size) {
1259 /* This BAR is not implemented */ 1259 /* This BAR is not implemented */
1260 debug ("is this bar no implemented?, count = %d\n", count); 1260 debug("is this bar no implemented?, count = %d\n", count);
1261 continue; 1261 continue;
1262 } 1262 }
1263 tmp_address = start_address; 1263 tmp_address = start_address;
@@ -1267,24 +1267,24 @@ static int unconfigure_boot_device (u8 busno, u8 device, u8 function)
1267 size = size & 0xFFFFFFFC; 1267 size = size & 0xFFFFFFFC;
1268 size = ~size + 1; 1268 size = ~size + 1;
1269 end_address = start_address + size - 1; 1269 end_address = start_address + size - 1;
1270 if (ibmphp_find_resource (bus, start_address, &io, IO) < 0) { 1270 if (ibmphp_find_resource(bus, start_address, &io, IO) < 0) {
1271 err ("cannot find corresponding IO resource to remove\n"); 1271 err("cannot find corresponding IO resource to remove\n");
1272 return -EIO; 1272 return -EIO;
1273 } 1273 }
1274 debug ("io->start = %x\n", io->start); 1274 debug("io->start = %x\n", io->start);
1275 temp_end = io->end; 1275 temp_end = io->end;
1276 start_address = io->end + 1; 1276 start_address = io->end + 1;
1277 ibmphp_remove_resource (io); 1277 ibmphp_remove_resource(io);
1278 /* This is needed b/c of the old I/O restrictions in the BIOS */ 1278 /* This is needed b/c of the old I/O restrictions in the BIOS */
1279 while (temp_end < end_address) { 1279 while (temp_end < end_address) {
1280 if (ibmphp_find_resource (bus, start_address, &io, IO) < 0) { 1280 if (ibmphp_find_resource(bus, start_address, &io, IO) < 0) {
1281 err ("cannot find corresponding IO resource to remove\n"); 1281 err("cannot find corresponding IO resource to remove\n");
1282 return -EIO; 1282 return -EIO;
1283 } 1283 }
1284 debug ("io->start = %x\n", io->start); 1284 debug("io->start = %x\n", io->start);
1285 temp_end = io->end; 1285 temp_end = io->end;
1286 start_address = io->end + 1; 1286 start_address = io->end + 1;
1287 ibmphp_remove_resource (io); 1287 ibmphp_remove_resource(io);
1288 } 1288 }
1289 1289
1290 /* ????????? DO WE NEED TO WRITE ANYTHING INTO THE PCI CONFIG SPACE BACK ?????????? */ 1290 /* ????????? DO WE NEED TO WRITE ANYTHING INTO THE PCI CONFIG SPACE BACK ?????????? */
@@ -1292,29 +1292,29 @@ static int unconfigure_boot_device (u8 busno, u8 device, u8 function)
1292 /* This is Memory */ 1292 /* This is Memory */
1293 if (start_address & PCI_BASE_ADDRESS_MEM_PREFETCH) { 1293 if (start_address & PCI_BASE_ADDRESS_MEM_PREFETCH) {
1294 /* pfmem */ 1294 /* pfmem */
1295 debug ("start address of pfmem is %x\n", start_address); 1295 debug("start address of pfmem is %x\n", start_address);
1296 start_address &= PCI_BASE_ADDRESS_MEM_MASK; 1296 start_address &= PCI_BASE_ADDRESS_MEM_MASK;
1297 1297
1298 if (ibmphp_find_resource (bus, start_address, &pfmem, PFMEM) < 0) { 1298 if (ibmphp_find_resource(bus, start_address, &pfmem, PFMEM) < 0) {
1299 err ("cannot find corresponding PFMEM resource to remove\n"); 1299 err("cannot find corresponding PFMEM resource to remove\n");
1300 return -EIO; 1300 return -EIO;
1301 } 1301 }
1302 if (pfmem) { 1302 if (pfmem) {
1303 debug ("pfmem->start = %x\n", pfmem->start); 1303 debug("pfmem->start = %x\n", pfmem->start);
1304 1304
1305 ibmphp_remove_resource(pfmem); 1305 ibmphp_remove_resource(pfmem);
1306 } 1306 }
1307 } else { 1307 } else {
1308 /* regular memory */ 1308 /* regular memory */
1309 debug ("start address of mem is %x\n", start_address); 1309 debug("start address of mem is %x\n", start_address);
1310 start_address &= PCI_BASE_ADDRESS_MEM_MASK; 1310 start_address &= PCI_BASE_ADDRESS_MEM_MASK;
1311 1311
1312 if (ibmphp_find_resource (bus, start_address, &mem, MEM) < 0) { 1312 if (ibmphp_find_resource(bus, start_address, &mem, MEM) < 0) {
1313 err ("cannot find corresponding MEM resource to remove\n"); 1313 err("cannot find corresponding MEM resource to remove\n");
1314 return -EIO; 1314 return -EIO;
1315 } 1315 }
1316 if (mem) { 1316 if (mem) {
1317 debug ("mem->start = %x\n", mem->start); 1317 debug("mem->start = %x\n", mem->start);
1318 1318
1319 ibmphp_remove_resource(mem); 1319 ibmphp_remove_resource(mem);
1320 } 1320 }
@@ -1329,7 +1329,7 @@ static int unconfigure_boot_device (u8 busno, u8 device, u8 function)
1329 return 0; 1329 return 0;
1330} 1330}
1331 1331
1332static int unconfigure_boot_bridge (u8 busno, u8 device, u8 function) 1332static int unconfigure_boot_bridge(u8 busno, u8 device, u8 function)
1333{ 1333{
1334 int count; 1334 int count;
1335 int bus_no, pri_no, sub_no, sec_no = 0; 1335 int bus_no, pri_no, sub_no, sec_no = 0;
@@ -1349,40 +1349,40 @@ static int unconfigure_boot_bridge (u8 busno, u8 device, u8 function)
1349 devfn = PCI_DEVFN(device, function); 1349 devfn = PCI_DEVFN(device, function);
1350 ibmphp_pci_bus->number = busno; 1350 ibmphp_pci_bus->number = busno;
1351 bus_no = (int) busno; 1351 bus_no = (int) busno;
1352 debug ("busno is %x\n", busno); 1352 debug("busno is %x\n", busno);
1353 pci_bus_read_config_byte (ibmphp_pci_bus, devfn, PCI_PRIMARY_BUS, &pri_number); 1353 pci_bus_read_config_byte(ibmphp_pci_bus, devfn, PCI_PRIMARY_BUS, &pri_number);
1354 debug ("%s - busno = %x, primary_number = %x\n", __func__, busno, pri_number); 1354 debug("%s - busno = %x, primary_number = %x\n", __func__, busno, pri_number);
1355 1355
1356 pci_bus_read_config_byte (ibmphp_pci_bus, devfn, PCI_SECONDARY_BUS, &sec_number); 1356 pci_bus_read_config_byte(ibmphp_pci_bus, devfn, PCI_SECONDARY_BUS, &sec_number);
1357 debug ("sec_number is %x\n", sec_number); 1357 debug("sec_number is %x\n", sec_number);
1358 sec_no = (int) sec_number; 1358 sec_no = (int) sec_number;
1359 pri_no = (int) pri_number; 1359 pri_no = (int) pri_number;
1360 if (pri_no != bus_no) { 1360 if (pri_no != bus_no) {
1361 err ("primary numbers in our structures and pci config space don't match.\n"); 1361 err("primary numbers in our structures and pci config space don't match.\n");
1362 return -EINVAL; 1362 return -EINVAL;
1363 } 1363 }
1364 1364
1365 pci_bus_read_config_byte (ibmphp_pci_bus, devfn, PCI_SUBORDINATE_BUS, &sub_number); 1365 pci_bus_read_config_byte(ibmphp_pci_bus, devfn, PCI_SUBORDINATE_BUS, &sub_number);
1366 sub_no = (int) sub_number; 1366 sub_no = (int) sub_number;
1367 debug ("sub_no is %d, sec_no is %d\n", sub_no, sec_no); 1367 debug("sub_no is %d, sec_no is %d\n", sub_no, sec_no);
1368 if (sec_no != sub_number) { 1368 if (sec_no != sub_number) {
1369 err ("there're more buses behind this bridge. Hot removal is not supported. Please choose another card\n"); 1369 err("there're more buses behind this bridge. Hot removal is not supported. Please choose another card\n");
1370 return -ENODEV; 1370 return -ENODEV;
1371 } 1371 }
1372 1372
1373 bus = ibmphp_find_res_bus (sec_number); 1373 bus = ibmphp_find_res_bus(sec_number);
1374 if (!bus) { 1374 if (!bus) {
1375 err ("cannot find Bus structure for the bridged device\n"); 1375 err("cannot find Bus structure for the bridged device\n");
1376 return -EINVAL; 1376 return -EINVAL;
1377 } 1377 }
1378 debug("bus->busno is %x\n", bus->busno); 1378 debug("bus->busno is %x\n", bus->busno);
1379 debug("sec_number is %x\n", sec_number); 1379 debug("sec_number is %x\n", sec_number);
1380 1380
1381 ibmphp_remove_bus (bus, busno); 1381 ibmphp_remove_bus(bus, busno);
1382 1382
1383 for (count = 0; address[count]; count++) { 1383 for (count = 0; address[count]; count++) {
1384 /* for 2 BARs */ 1384 /* for 2 BARs */
1385 pci_bus_read_config_dword (ibmphp_pci_bus, devfn, address[count], &start_address); 1385 pci_bus_read_config_dword(ibmphp_pci_bus, devfn, address[count], &start_address);
1386 1386
1387 if (!start_address) { 1387 if (!start_address) {
1388 /* This BAR is not implemented */ 1388 /* This BAR is not implemented */
@@ -1394,14 +1394,14 @@ static int unconfigure_boot_bridge (u8 busno, u8 device, u8 function)
1394 if (start_address & PCI_BASE_ADDRESS_SPACE_IO) { 1394 if (start_address & PCI_BASE_ADDRESS_SPACE_IO) {
1395 /* This is IO */ 1395 /* This is IO */
1396 start_address &= PCI_BASE_ADDRESS_IO_MASK; 1396 start_address &= PCI_BASE_ADDRESS_IO_MASK;
1397 if (ibmphp_find_resource (bus, start_address, &io, IO) < 0) { 1397 if (ibmphp_find_resource(bus, start_address, &io, IO) < 0) {
1398 err ("cannot find corresponding IO resource to remove\n"); 1398 err("cannot find corresponding IO resource to remove\n");
1399 return -EIO; 1399 return -EIO;
1400 } 1400 }
1401 if (io) 1401 if (io)
1402 debug ("io->start = %x\n", io->start); 1402 debug("io->start = %x\n", io->start);
1403 1403
1404 ibmphp_remove_resource (io); 1404 ibmphp_remove_resource(io);
1405 1405
1406 /* ????????? DO WE NEED TO WRITE ANYTHING INTO THE PCI CONFIG SPACE BACK ?????????? */ 1406 /* ????????? DO WE NEED TO WRITE ANYTHING INTO THE PCI CONFIG SPACE BACK ?????????? */
1407 } else { 1407 } else {
@@ -1409,24 +1409,24 @@ static int unconfigure_boot_bridge (u8 busno, u8 device, u8 function)
1409 if (start_address & PCI_BASE_ADDRESS_MEM_PREFETCH) { 1409 if (start_address & PCI_BASE_ADDRESS_MEM_PREFETCH) {
1410 /* pfmem */ 1410 /* pfmem */
1411 start_address &= PCI_BASE_ADDRESS_MEM_MASK; 1411 start_address &= PCI_BASE_ADDRESS_MEM_MASK;
1412 if (ibmphp_find_resource (bus, start_address, &pfmem, PFMEM) < 0) { 1412 if (ibmphp_find_resource(bus, start_address, &pfmem, PFMEM) < 0) {
1413 err ("cannot find corresponding PFMEM resource to remove\n"); 1413 err("cannot find corresponding PFMEM resource to remove\n");
1414 return -EINVAL; 1414 return -EINVAL;
1415 } 1415 }
1416 if (pfmem) { 1416 if (pfmem) {
1417 debug ("pfmem->start = %x\n", pfmem->start); 1417 debug("pfmem->start = %x\n", pfmem->start);
1418 1418
1419 ibmphp_remove_resource(pfmem); 1419 ibmphp_remove_resource(pfmem);
1420 } 1420 }
1421 } else { 1421 } else {
1422 /* regular memory */ 1422 /* regular memory */
1423 start_address &= PCI_BASE_ADDRESS_MEM_MASK; 1423 start_address &= PCI_BASE_ADDRESS_MEM_MASK;
1424 if (ibmphp_find_resource (bus, start_address, &mem, MEM) < 0) { 1424 if (ibmphp_find_resource(bus, start_address, &mem, MEM) < 0) {
1425 err ("cannot find corresponding MEM resource to remove\n"); 1425 err("cannot find corresponding MEM resource to remove\n");
1426 return -EINVAL; 1426 return -EINVAL;
1427 } 1427 }
1428 if (mem) { 1428 if (mem) {
1429 debug ("mem->start = %x\n", mem->start); 1429 debug("mem->start = %x\n", mem->start);
1430 1430
1431 ibmphp_remove_resource(mem); 1431 ibmphp_remove_resource(mem);
1432 } 1432 }
@@ -1437,11 +1437,11 @@ static int unconfigure_boot_bridge (u8 busno, u8 device, u8 function)
1437 } 1437 }
1438 } /* end of mem */ 1438 } /* end of mem */
1439 } /* end of for */ 1439 } /* end of for */
1440 debug ("%s - exiting, returning success\n", __func__); 1440 debug("%s - exiting, returning success\n", __func__);
1441 return 0; 1441 return 0;
1442} 1442}
1443 1443
1444static int unconfigure_boot_card (struct slot *slot_cur) 1444static int unconfigure_boot_card(struct slot *slot_cur)
1445{ 1445{
1446 u16 vendor_id; 1446 u16 vendor_id;
1447 u32 class; 1447 u32 class;
@@ -1453,57 +1453,57 @@ static int unconfigure_boot_card (struct slot *slot_cur)
1453 unsigned int devfn; 1453 unsigned int devfn;
1454 u8 valid_device = 0x00; /* To see if we are ever able to find valid device and read it */ 1454 u8 valid_device = 0x00; /* To see if we are ever able to find valid device and read it */
1455 1455
1456 debug ("%s - enter\n", __func__); 1456 debug("%s - enter\n", __func__);
1457 1457
1458 device = slot_cur->device; 1458 device = slot_cur->device;
1459 busno = slot_cur->bus; 1459 busno = slot_cur->bus;
1460 1460
1461 debug ("b4 for loop, device is %x\n", device); 1461 debug("b4 for loop, device is %x\n", device);
1462 /* For every function on the card */ 1462 /* For every function on the card */
1463 for (function = 0x0; function < 0x08; function++) { 1463 for (function = 0x0; function < 0x08; function++) {
1464 devfn = PCI_DEVFN(device, function); 1464 devfn = PCI_DEVFN(device, function);
1465 ibmphp_pci_bus->number = busno; 1465 ibmphp_pci_bus->number = busno;
1466 1466
1467 pci_bus_read_config_word (ibmphp_pci_bus, devfn, PCI_VENDOR_ID, &vendor_id); 1467 pci_bus_read_config_word(ibmphp_pci_bus, devfn, PCI_VENDOR_ID, &vendor_id);
1468 1468
1469 if (vendor_id != PCI_VENDOR_ID_NOTVALID) { 1469 if (vendor_id != PCI_VENDOR_ID_NOTVALID) {
1470 /* found correct device!!! */ 1470 /* found correct device!!! */
1471 ++valid_device; 1471 ++valid_device;
1472 1472
1473 debug ("%s - found correct device\n", __func__); 1473 debug("%s - found correct device\n", __func__);
1474 1474
1475 /* header: x x x x x x x x 1475 /* header: x x x x x x x x
1476 * | |___________|=> 1=PPB bridge, 0=normal device, 2=CardBus Bridge 1476 * | |___________|=> 1=PPB bridge, 0=normal device, 2=CardBus Bridge
1477 * |_=> 0 = single function device, 1 = multi-function device 1477 * |_=> 0 = single function device, 1 = multi-function device
1478 */ 1478 */
1479 1479
1480 pci_bus_read_config_byte (ibmphp_pci_bus, devfn, PCI_HEADER_TYPE, &hdr_type); 1480 pci_bus_read_config_byte(ibmphp_pci_bus, devfn, PCI_HEADER_TYPE, &hdr_type);
1481 pci_bus_read_config_dword (ibmphp_pci_bus, devfn, PCI_CLASS_REVISION, &class); 1481 pci_bus_read_config_dword(ibmphp_pci_bus, devfn, PCI_CLASS_REVISION, &class);
1482 1482
1483 debug ("hdr_type %x, class %x\n", hdr_type, class); 1483 debug("hdr_type %x, class %x\n", hdr_type, class);
1484 class >>= 8; /* to take revision out, class = class.subclass.prog i/f */ 1484 class >>= 8; /* to take revision out, class = class.subclass.prog i/f */
1485 if (class == PCI_CLASS_NOT_DEFINED_VGA) { 1485 if (class == PCI_CLASS_NOT_DEFINED_VGA) {
1486 err ("The device %x function %x is VGA compatible and is not supported for hot removing. Please choose another device.\n", device, function); 1486 err("The device %x function %x is VGA compatible and is not supported for hot removing. Please choose another device.\n", device, function);
1487 return -ENODEV; 1487 return -ENODEV;
1488 } else if (class == PCI_CLASS_DISPLAY_VGA) { 1488 } else if (class == PCI_CLASS_DISPLAY_VGA) {
1489 err ("The device %x function %x is not supported for hot removing. Please choose another device.\n", device, function); 1489 err("The device %x function %x is not supported for hot removing. Please choose another device.\n", device, function);
1490 return -ENODEV; 1490 return -ENODEV;
1491 } 1491 }
1492 1492
1493 switch (hdr_type) { 1493 switch (hdr_type) {
1494 case PCI_HEADER_TYPE_NORMAL: 1494 case PCI_HEADER_TYPE_NORMAL:
1495 rc = unconfigure_boot_device (busno, device, function); 1495 rc = unconfigure_boot_device(busno, device, function);
1496 if (rc) { 1496 if (rc) {
1497 err ("was not able to unconfigure device %x func %x on bus %x. bailing out...\n", 1497 err("was not able to unconfigure device %x func %x on bus %x. bailing out...\n",
1498 device, function, busno); 1498 device, function, busno);
1499 return rc; 1499 return rc;
1500 } 1500 }
1501 function = 0x8; 1501 function = 0x8;
1502 break; 1502 break;
1503 case PCI_HEADER_TYPE_MULTIDEVICE: 1503 case PCI_HEADER_TYPE_MULTIDEVICE:
1504 rc = unconfigure_boot_device (busno, device, function); 1504 rc = unconfigure_boot_device(busno, device, function);
1505 if (rc) { 1505 if (rc) {
1506 err ("was not able to unconfigure device %x func %x on bus %x. bailing out...\n", 1506 err("was not able to unconfigure device %x func %x on bus %x. bailing out...\n",
1507 device, function, busno); 1507 device, function, busno);
1508 return rc; 1508 return rc;
1509 } 1509 }
@@ -1511,12 +1511,12 @@ static int unconfigure_boot_card (struct slot *slot_cur)
1511 case PCI_HEADER_TYPE_BRIDGE: 1511 case PCI_HEADER_TYPE_BRIDGE:
1512 class >>= 8; 1512 class >>= 8;
1513 if (class != PCI_CLASS_BRIDGE_PCI) { 1513 if (class != PCI_CLASS_BRIDGE_PCI) {
1514 err ("This device %x function %x is not PCI-to-PCI bridge, and is not supported for hot-removing. Please try another card.\n", device, function); 1514 err("This device %x function %x is not PCI-to-PCI bridge, and is not supported for hot-removing. Please try another card.\n", device, function);
1515 return -ENODEV; 1515 return -ENODEV;
1516 } 1516 }
1517 rc = unconfigure_boot_bridge (busno, device, function); 1517 rc = unconfigure_boot_bridge(busno, device, function);
1518 if (rc != 0) { 1518 if (rc != 0) {
1519 err ("was not able to hot-remove PPB properly.\n"); 1519 err("was not able to hot-remove PPB properly.\n");
1520 return rc; 1520 return rc;
1521 } 1521 }
1522 1522
@@ -1525,17 +1525,17 @@ static int unconfigure_boot_card (struct slot *slot_cur)
1525 case PCI_HEADER_TYPE_MULTIBRIDGE: 1525 case PCI_HEADER_TYPE_MULTIBRIDGE:
1526 class >>= 8; 1526 class >>= 8;
1527 if (class != PCI_CLASS_BRIDGE_PCI) { 1527 if (class != PCI_CLASS_BRIDGE_PCI) {
1528 err ("This device %x function %x is not PCI-to-PCI bridge, and is not supported for hot-removing. Please try another card.\n", device, function); 1528 err("This device %x function %x is not PCI-to-PCI bridge, and is not supported for hot-removing. Please try another card.\n", device, function);
1529 return -ENODEV; 1529 return -ENODEV;
1530 } 1530 }
1531 rc = unconfigure_boot_bridge (busno, device, function); 1531 rc = unconfigure_boot_bridge(busno, device, function);
1532 if (rc != 0) { 1532 if (rc != 0) {
1533 err ("was not able to hot-remove PPB properly.\n"); 1533 err("was not able to hot-remove PPB properly.\n");
1534 return rc; 1534 return rc;
1535 } 1535 }
1536 break; 1536 break;
1537 default: 1537 default:
1538 err ("MAJOR PROBLEM!!!! Cannot read device's header\n"); 1538 err("MAJOR PROBLEM!!!! Cannot read device's header\n");
1539 return -1; 1539 return -1;
1540 break; 1540 break;
1541 } /* end of switch */ 1541 } /* end of switch */
@@ -1543,7 +1543,7 @@ static int unconfigure_boot_card (struct slot *slot_cur)
1543 } /* end of for */ 1543 } /* end of for */
1544 1544
1545 if (!valid_device) { 1545 if (!valid_device) {
1546 err ("Could not find device to unconfigure. Or could not read the card.\n"); 1546 err("Could not find device to unconfigure. Or could not read the card.\n");
1547 return -1; 1547 return -1;
1548 } 1548 }
1549 return 0; 1549 return 0;
@@ -1558,7 +1558,7 @@ static int unconfigure_boot_card (struct slot *slot_cur)
1558 * !!!!!!!!!!!!!!!!!!!!!!!!!FOR BUSES!!!!!!!!!!!! 1558 * !!!!!!!!!!!!!!!!!!!!!!!!!FOR BUSES!!!!!!!!!!!!
1559 * Returns: 0, -1, -ENODEV 1559 * Returns: 0, -1, -ENODEV
1560 */ 1560 */
1561int ibmphp_unconfigure_card (struct slot **slot_cur, int the_end) 1561int ibmphp_unconfigure_card(struct slot **slot_cur, int the_end)
1562{ 1562{
1563 int i; 1563 int i;
1564 int count; 1564 int count;
@@ -1567,11 +1567,11 @@ int ibmphp_unconfigure_card (struct slot **slot_cur, int the_end)
1567 struct pci_func *cur_func = NULL; 1567 struct pci_func *cur_func = NULL;
1568 struct pci_func *temp_func; 1568 struct pci_func *temp_func;
1569 1569
1570 debug ("%s - enter\n", __func__); 1570 debug("%s - enter\n", __func__);
1571 1571
1572 if (!the_end) { 1572 if (!the_end) {
1573 /* Need to unconfigure the card */ 1573 /* Need to unconfigure the card */
1574 rc = unconfigure_boot_card (sl); 1574 rc = unconfigure_boot_card(sl);
1575 if ((rc == -ENODEV) || (rc == -EIO) || (rc == -EINVAL)) { 1575 if ((rc == -ENODEV) || (rc == -EIO) || (rc == -EINVAL)) {
1576 /* In all other cases, will still need to get rid of func structure if it exists */ 1576 /* In all other cases, will still need to get rid of func structure if it exists */
1577 return rc; 1577 return rc;
@@ -1591,34 +1591,34 @@ int ibmphp_unconfigure_card (struct slot **slot_cur, int the_end)
1591 1591
1592 for (i = 0; i < count; i++) { 1592 for (i = 0; i < count; i++) {
1593 if (cur_func->io[i]) { 1593 if (cur_func->io[i]) {
1594 debug ("io[%d] exists\n", i); 1594 debug("io[%d] exists\n", i);
1595 if (the_end > 0) 1595 if (the_end > 0)
1596 ibmphp_remove_resource (cur_func->io[i]); 1596 ibmphp_remove_resource(cur_func->io[i]);
1597 cur_func->io[i] = NULL; 1597 cur_func->io[i] = NULL;
1598 } 1598 }
1599 if (cur_func->mem[i]) { 1599 if (cur_func->mem[i]) {
1600 debug ("mem[%d] exists\n", i); 1600 debug("mem[%d] exists\n", i);
1601 if (the_end > 0) 1601 if (the_end > 0)
1602 ibmphp_remove_resource (cur_func->mem[i]); 1602 ibmphp_remove_resource(cur_func->mem[i]);
1603 cur_func->mem[i] = NULL; 1603 cur_func->mem[i] = NULL;
1604 } 1604 }
1605 if (cur_func->pfmem[i]) { 1605 if (cur_func->pfmem[i]) {
1606 debug ("pfmem[%d] exists\n", i); 1606 debug("pfmem[%d] exists\n", i);
1607 if (the_end > 0) 1607 if (the_end > 0)
1608 ibmphp_remove_resource (cur_func->pfmem[i]); 1608 ibmphp_remove_resource(cur_func->pfmem[i]);
1609 cur_func->pfmem[i] = NULL; 1609 cur_func->pfmem[i] = NULL;
1610 } 1610 }
1611 } 1611 }
1612 1612
1613 temp_func = cur_func->next; 1613 temp_func = cur_func->next;
1614 kfree (cur_func); 1614 kfree(cur_func);
1615 cur_func = temp_func; 1615 cur_func = temp_func;
1616 } 1616 }
1617 } 1617 }
1618 1618
1619 sl->func = NULL; 1619 sl->func = NULL;
1620 *slot_cur = sl; 1620 *slot_cur = sl;
1621 debug ("%s - exit\n", __func__); 1621 debug("%s - exit\n", __func__);
1622 return 0; 1622 return 0;
1623} 1623}
1624 1624
@@ -1630,7 +1630,7 @@ int ibmphp_unconfigure_card (struct slot **slot_cur, int the_end)
1630 * Output: bus added to the correct spot 1630 * Output: bus added to the correct spot
1631 * 0, -1, error 1631 * 0, -1, error
1632 */ 1632 */
1633static int add_new_bus (struct bus_node *bus, struct resource_node *io, struct resource_node *mem, struct resource_node *pfmem, u8 parent_busno) 1633static int add_new_bus(struct bus_node *bus, struct resource_node *io, struct resource_node *mem, struct resource_node *pfmem, u8 parent_busno)
1634{ 1634{
1635 struct range_node *io_range = NULL; 1635 struct range_node *io_range = NULL;
1636 struct range_node *mem_range = NULL; 1636 struct range_node *mem_range = NULL;
@@ -1639,18 +1639,18 @@ static int add_new_bus (struct bus_node *bus, struct resource_node *io, struct r
1639 1639
1640 /* Trying to find the parent bus number */ 1640 /* Trying to find the parent bus number */
1641 if (parent_busno != 0xFF) { 1641 if (parent_busno != 0xFF) {
1642 cur_bus = ibmphp_find_res_bus (parent_busno); 1642 cur_bus = ibmphp_find_res_bus(parent_busno);
1643 if (!cur_bus) { 1643 if (!cur_bus) {
1644 err ("strange, cannot find bus which is supposed to be at the system... something is terribly wrong...\n"); 1644 err("strange, cannot find bus which is supposed to be at the system... something is terribly wrong...\n");
1645 return -ENODEV; 1645 return -ENODEV;
1646 } 1646 }
1647 1647
1648 list_add (&bus->bus_list, &cur_bus->bus_list); 1648 list_add(&bus->bus_list, &cur_bus->bus_list);
1649 } 1649 }
1650 if (io) { 1650 if (io) {
1651 io_range = kzalloc(sizeof(*io_range), GFP_KERNEL); 1651 io_range = kzalloc(sizeof(*io_range), GFP_KERNEL);
1652 if (!io_range) { 1652 if (!io_range) {
1653 err ("out of system memory\n"); 1653 err("out of system memory\n");
1654 return -ENOMEM; 1654 return -ENOMEM;
1655 } 1655 }
1656 io_range->start = io->start; 1656 io_range->start = io->start;
@@ -1662,7 +1662,7 @@ static int add_new_bus (struct bus_node *bus, struct resource_node *io, struct r
1662 if (mem) { 1662 if (mem) {
1663 mem_range = kzalloc(sizeof(*mem_range), GFP_KERNEL); 1663 mem_range = kzalloc(sizeof(*mem_range), GFP_KERNEL);
1664 if (!mem_range) { 1664 if (!mem_range) {
1665 err ("out of system memory\n"); 1665 err("out of system memory\n");
1666 return -ENOMEM; 1666 return -ENOMEM;
1667 } 1667 }
1668 mem_range->start = mem->start; 1668 mem_range->start = mem->start;
@@ -1674,7 +1674,7 @@ static int add_new_bus (struct bus_node *bus, struct resource_node *io, struct r
1674 if (pfmem) { 1674 if (pfmem) {
1675 pfmem_range = kzalloc(sizeof(*pfmem_range), GFP_KERNEL); 1675 pfmem_range = kzalloc(sizeof(*pfmem_range), GFP_KERNEL);
1676 if (!pfmem_range) { 1676 if (!pfmem_range) {
1677 err ("out of system memory\n"); 1677 err("out of system memory\n");
1678 return -ENOMEM; 1678 return -ENOMEM;
1679 } 1679 }
1680 pfmem_range->start = pfmem->start; 1680 pfmem_range->start = pfmem->start;
@@ -1691,27 +1691,27 @@ static int add_new_bus (struct bus_node *bus, struct resource_node *io, struct r
1691 * Parameters: bus_number of the primary bus 1691 * Parameters: bus_number of the primary bus
1692 * Returns: bus_number of the secondary bus or 0xff in case of failure 1692 * Returns: bus_number of the secondary bus or 0xff in case of failure
1693 */ 1693 */
1694static u8 find_sec_number (u8 primary_busno, u8 slotno) 1694static u8 find_sec_number(u8 primary_busno, u8 slotno)
1695{ 1695{
1696 int min, max; 1696 int min, max;
1697 u8 busno; 1697 u8 busno;
1698 struct bus_info *bus; 1698 struct bus_info *bus;
1699 struct bus_node *bus_cur; 1699 struct bus_node *bus_cur;
1700 1700
1701 bus = ibmphp_find_same_bus_num (primary_busno); 1701 bus = ibmphp_find_same_bus_num(primary_busno);
1702 if (!bus) { 1702 if (!bus) {
1703 err ("cannot get slot range of the bus from the BIOS\n"); 1703 err("cannot get slot range of the bus from the BIOS\n");
1704 return 0xff; 1704 return 0xff;
1705 } 1705 }
1706 max = bus->slot_max; 1706 max = bus->slot_max;
1707 min = bus->slot_min; 1707 min = bus->slot_min;
1708 if ((slotno > max) || (slotno < min)) { 1708 if ((slotno > max) || (slotno < min)) {
1709 err ("got the wrong range\n"); 1709 err("got the wrong range\n");
1710 return 0xff; 1710 return 0xff;
1711 } 1711 }
1712 busno = (u8) (slotno - (u8) min); 1712 busno = (u8) (slotno - (u8) min);
1713 busno += primary_busno + 0x01; 1713 busno += primary_busno + 0x01;
1714 bus_cur = ibmphp_find_res_bus (busno); 1714 bus_cur = ibmphp_find_res_bus(busno);
1715 /* either there is no such bus number, or there are no ranges, which 1715 /* either there is no such bus number, or there are no ranges, which
1716 * can only happen if we removed the bridged device in previous load 1716 * can only happen if we removed the bridged device in previous load
1717 * of the driver, and now only have the skeleton bus struct 1717 * of the driver, and now only have the skeleton bus struct
diff --git a/drivers/pci/hotplug/ibmphp_res.c b/drivers/pci/hotplug/ibmphp_res.c
index b5f2851e8cbe..aee6e41001e1 100644
--- a/drivers/pci/hotplug/ibmphp_res.c
+++ b/drivers/pci/hotplug/ibmphp_res.c
@@ -36,28 +36,28 @@
36 36
37static int flags = 0; /* for testing */ 37static int flags = 0; /* for testing */
38 38
39static void update_resources (struct bus_node *bus_cur, int type, int rangeno); 39static void update_resources(struct bus_node *bus_cur, int type, int rangeno);
40static int once_over (void); 40static int once_over(void);
41static int remove_ranges (struct bus_node *, struct bus_node *); 41static int remove_ranges(struct bus_node *, struct bus_node *);
42static int update_bridge_ranges (struct bus_node **); 42static int update_bridge_ranges(struct bus_node **);
43static int add_bus_range (int type, struct range_node *, struct bus_node *); 43static int add_bus_range(int type, struct range_node *, struct bus_node *);
44static void fix_resources (struct bus_node *); 44static void fix_resources(struct bus_node *);
45static struct bus_node *find_bus_wprev (u8, struct bus_node **, u8); 45static struct bus_node *find_bus_wprev(u8, struct bus_node **, u8);
46 46
47static LIST_HEAD(gbuses); 47static LIST_HEAD(gbuses);
48 48
49static struct bus_node * __init alloc_error_bus (struct ebda_pci_rsrc *curr, u8 busno, int flag) 49static struct bus_node * __init alloc_error_bus(struct ebda_pci_rsrc *curr, u8 busno, int flag)
50{ 50{
51 struct bus_node *newbus; 51 struct bus_node *newbus;
52 52
53 if (!(curr) && !(flag)) { 53 if (!(curr) && !(flag)) {
54 err ("NULL pointer passed\n"); 54 err("NULL pointer passed\n");
55 return NULL; 55 return NULL;
56 } 56 }
57 57
58 newbus = kzalloc(sizeof(struct bus_node), GFP_KERNEL); 58 newbus = kzalloc(sizeof(struct bus_node), GFP_KERNEL);
59 if (!newbus) { 59 if (!newbus) {
60 err ("out of system memory\n"); 60 err("out of system memory\n");
61 return NULL; 61 return NULL;
62 } 62 }
63 63
@@ -65,22 +65,22 @@ static struct bus_node * __init alloc_error_bus (struct ebda_pci_rsrc *curr, u8
65 newbus->busno = busno; 65 newbus->busno = busno;
66 else 66 else
67 newbus->busno = curr->bus_num; 67 newbus->busno = curr->bus_num;
68 list_add_tail (&newbus->bus_list, &gbuses); 68 list_add_tail(&newbus->bus_list, &gbuses);
69 return newbus; 69 return newbus;
70} 70}
71 71
72static struct resource_node * __init alloc_resources (struct ebda_pci_rsrc *curr) 72static struct resource_node * __init alloc_resources(struct ebda_pci_rsrc *curr)
73{ 73{
74 struct resource_node *rs; 74 struct resource_node *rs;
75 75
76 if (!curr) { 76 if (!curr) {
77 err ("NULL passed to allocate\n"); 77 err("NULL passed to allocate\n");
78 return NULL; 78 return NULL;
79 } 79 }
80 80
81 rs = kzalloc(sizeof(struct resource_node), GFP_KERNEL); 81 rs = kzalloc(sizeof(struct resource_node), GFP_KERNEL);
82 if (!rs) { 82 if (!rs) {
83 err ("out of system memory\n"); 83 err("out of system memory\n");
84 return NULL; 84 return NULL;
85 } 85 }
86 rs->busno = curr->bus_num; 86 rs->busno = curr->bus_num;
@@ -91,7 +91,7 @@ static struct resource_node * __init alloc_resources (struct ebda_pci_rsrc *curr
91 return rs; 91 return rs;
92} 92}
93 93
94static int __init alloc_bus_range (struct bus_node **new_bus, struct range_node **new_range, struct ebda_pci_rsrc *curr, int flag, u8 first_bus) 94static int __init alloc_bus_range(struct bus_node **new_bus, struct range_node **new_range, struct ebda_pci_rsrc *curr, int flag, u8 first_bus)
95{ 95{
96 struct bus_node *newbus; 96 struct bus_node *newbus;
97 struct range_node *newrange; 97 struct range_node *newrange;
@@ -100,7 +100,7 @@ static int __init alloc_bus_range (struct bus_node **new_bus, struct range_node
100 if (first_bus) { 100 if (first_bus) {
101 newbus = kzalloc(sizeof(struct bus_node), GFP_KERNEL); 101 newbus = kzalloc(sizeof(struct bus_node), GFP_KERNEL);
102 if (!newbus) { 102 if (!newbus) {
103 err ("out of system memory.\n"); 103 err("out of system memory.\n");
104 return -ENOMEM; 104 return -ENOMEM;
105 } 105 }
106 newbus->busno = curr->bus_num; 106 newbus->busno = curr->bus_num;
@@ -122,8 +122,8 @@ static int __init alloc_bus_range (struct bus_node **new_bus, struct range_node
122 newrange = kzalloc(sizeof(struct range_node), GFP_KERNEL); 122 newrange = kzalloc(sizeof(struct range_node), GFP_KERNEL);
123 if (!newrange) { 123 if (!newrange) {
124 if (first_bus) 124 if (first_bus)
125 kfree (newbus); 125 kfree(newbus);
126 err ("out of system memory\n"); 126 err("out of system memory\n");
127 return -ENOMEM; 127 return -ENOMEM;
128 } 128 }
129 newrange->start = curr->start_addr; 129 newrange->start = curr->start_addr;
@@ -133,8 +133,8 @@ static int __init alloc_bus_range (struct bus_node **new_bus, struct range_node
133 newrange->rangeno = 1; 133 newrange->rangeno = 1;
134 else { 134 else {
135 /* need to insert our range */ 135 /* need to insert our range */
136 add_bus_range (flag, newrange, newbus); 136 add_bus_range(flag, newrange, newbus);
137 debug ("%d resource Primary Bus inserted on bus %x [%x - %x]\n", flag, newbus->busno, newrange->start, newrange->end); 137 debug("%d resource Primary Bus inserted on bus %x [%x - %x]\n", flag, newbus->busno, newrange->start, newrange->end);
138 } 138 }
139 139
140 switch (flag) { 140 switch (flag) {
@@ -143,9 +143,9 @@ static int __init alloc_bus_range (struct bus_node **new_bus, struct range_node
143 if (first_bus) 143 if (first_bus)
144 newbus->noMemRanges = 1; 144 newbus->noMemRanges = 1;
145 else { 145 else {
146 debug ("First Memory Primary on bus %x, [%x - %x]\n", newbus->busno, newrange->start, newrange->end); 146 debug("First Memory Primary on bus %x, [%x - %x]\n", newbus->busno, newrange->start, newrange->end);
147 ++newbus->noMemRanges; 147 ++newbus->noMemRanges;
148 fix_resources (newbus); 148 fix_resources(newbus);
149 } 149 }
150 break; 150 break;
151 case IO: 151 case IO:
@@ -153,9 +153,9 @@ static int __init alloc_bus_range (struct bus_node **new_bus, struct range_node
153 if (first_bus) 153 if (first_bus)
154 newbus->noIORanges = 1; 154 newbus->noIORanges = 1;
155 else { 155 else {
156 debug ("First IO Primary on bus %x, [%x - %x]\n", newbus->busno, newrange->start, newrange->end); 156 debug("First IO Primary on bus %x, [%x - %x]\n", newbus->busno, newrange->start, newrange->end);
157 ++newbus->noIORanges; 157 ++newbus->noIORanges;
158 fix_resources (newbus); 158 fix_resources(newbus);
159 } 159 }
160 break; 160 break;
161 case PFMEM: 161 case PFMEM:
@@ -163,9 +163,9 @@ static int __init alloc_bus_range (struct bus_node **new_bus, struct range_node
163 if (first_bus) 163 if (first_bus)
164 newbus->noPFMemRanges = 1; 164 newbus->noPFMemRanges = 1;
165 else { 165 else {
166 debug ("1st PFMemory Primary on Bus %x [%x - %x]\n", newbus->busno, newrange->start, newrange->end); 166 debug("1st PFMemory Primary on Bus %x [%x - %x]\n", newbus->busno, newrange->start, newrange->end);
167 ++newbus->noPFMemRanges; 167 ++newbus->noPFMemRanges;
168 fix_resources (newbus); 168 fix_resources(newbus);
169 } 169 }
170 170
171 break; 171 break;
@@ -183,7 +183,7 @@ static int __init alloc_bus_range (struct bus_node **new_bus, struct range_node
183 * 2. If cannot allocate out of PFMem range, allocate from Mem ranges. PFmemFromMem 183 * 2. If cannot allocate out of PFMem range, allocate from Mem ranges. PFmemFromMem
184 * are not sorted. (no need since use mem node). To not change the entire code, we 184 * are not sorted. (no need since use mem node). To not change the entire code, we
185 * also add mem node whenever this case happens so as not to change 185 * also add mem node whenever this case happens so as not to change
186 * ibmphp_check_mem_resource etc (and since it really is taking Mem resource) 186 * ibmphp_check_mem_resource etc(and since it really is taking Mem resource)
187 */ 187 */
188 188
189/***************************************************************************** 189/*****************************************************************************
@@ -196,7 +196,7 @@ static int __init alloc_bus_range (struct bus_node **new_bus, struct range_node
196 * Input: ptr to the head of the resource list from EBDA 196 * Input: ptr to the head of the resource list from EBDA
197 * Output: 0, -1 or error codes 197 * Output: 0, -1 or error codes
198 ***************************************************************************/ 198 ***************************************************************************/
199int __init ibmphp_rsrc_init (void) 199int __init ibmphp_rsrc_init(void)
200{ 200{
201 struct ebda_pci_rsrc *curr; 201 struct ebda_pci_rsrc *curr;
202 struct range_node *newrange = NULL; 202 struct range_node *newrange = NULL;
@@ -212,7 +212,7 @@ int __init ibmphp_rsrc_init (void)
212 ebda_pci_rsrc_list) { 212 ebda_pci_rsrc_list) {
213 if (!(curr->rsrc_type & PCIDEVMASK)) { 213 if (!(curr->rsrc_type & PCIDEVMASK)) {
214 /* EBDA still lists non PCI devices, so ignore... */ 214 /* EBDA still lists non PCI devices, so ignore... */
215 debug ("this is not a PCI DEVICE in rsrc_init, please take care\n"); 215 debug("this is not a PCI DEVICE in rsrc_init, please take care\n");
216 // continue; 216 // continue;
217 } 217 }
218 218
@@ -221,17 +221,17 @@ int __init ibmphp_rsrc_init (void)
221 /* memory */ 221 /* memory */
222 if ((curr->rsrc_type & RESTYPE) == MMASK) { 222 if ((curr->rsrc_type & RESTYPE) == MMASK) {
223 /* no bus structure exists in place yet */ 223 /* no bus structure exists in place yet */
224 if (list_empty (&gbuses)) { 224 if (list_empty(&gbuses)) {
225 rc = alloc_bus_range(&newbus, &newrange, curr, MEM, 1); 225 rc = alloc_bus_range(&newbus, &newrange, curr, MEM, 1);
226 if (rc) 226 if (rc)
227 return rc; 227 return rc;
228 list_add_tail (&newbus->bus_list, &gbuses); 228 list_add_tail(&newbus->bus_list, &gbuses);
229 debug ("gbuses = NULL, Memory Primary Bus %x [%x - %x]\n", newbus->busno, newrange->start, newrange->end); 229 debug("gbuses = NULL, Memory Primary Bus %x [%x - %x]\n", newbus->busno, newrange->start, newrange->end);
230 } else { 230 } else {
231 bus_cur = find_bus_wprev (curr->bus_num, &bus_prev, 1); 231 bus_cur = find_bus_wprev(curr->bus_num, &bus_prev, 1);
232 /* found our bus */ 232 /* found our bus */
233 if (bus_cur) { 233 if (bus_cur) {
234 rc = alloc_bus_range (&bus_cur, &newrange, curr, MEM, 0); 234 rc = alloc_bus_range(&bus_cur, &newrange, curr, MEM, 0);
235 if (rc) 235 if (rc)
236 return rc; 236 return rc;
237 } else { 237 } else {
@@ -240,24 +240,24 @@ int __init ibmphp_rsrc_init (void)
240 if (rc) 240 if (rc)
241 return rc; 241 return rc;
242 242
243 list_add_tail (&newbus->bus_list, &gbuses); 243 list_add_tail(&newbus->bus_list, &gbuses);
244 debug ("New Bus, Memory Primary Bus %x [%x - %x]\n", newbus->busno, newrange->start, newrange->end); 244 debug("New Bus, Memory Primary Bus %x [%x - %x]\n", newbus->busno, newrange->start, newrange->end);
245 } 245 }
246 } 246 }
247 } else if ((curr->rsrc_type & RESTYPE) == PFMASK) { 247 } else if ((curr->rsrc_type & RESTYPE) == PFMASK) {
248 /* prefetchable memory */ 248 /* prefetchable memory */
249 if (list_empty (&gbuses)) { 249 if (list_empty(&gbuses)) {
250 /* no bus structure exists in place yet */ 250 /* no bus structure exists in place yet */
251 rc = alloc_bus_range(&newbus, &newrange, curr, PFMEM, 1); 251 rc = alloc_bus_range(&newbus, &newrange, curr, PFMEM, 1);
252 if (rc) 252 if (rc)
253 return rc; 253 return rc;
254 list_add_tail (&newbus->bus_list, &gbuses); 254 list_add_tail(&newbus->bus_list, &gbuses);
255 debug ("gbuses = NULL, PFMemory Primary Bus %x [%x - %x]\n", newbus->busno, newrange->start, newrange->end); 255 debug("gbuses = NULL, PFMemory Primary Bus %x [%x - %x]\n", newbus->busno, newrange->start, newrange->end);
256 } else { 256 } else {
257 bus_cur = find_bus_wprev (curr->bus_num, &bus_prev, 1); 257 bus_cur = find_bus_wprev(curr->bus_num, &bus_prev, 1);
258 if (bus_cur) { 258 if (bus_cur) {
259 /* found our bus */ 259 /* found our bus */
260 rc = alloc_bus_range (&bus_cur, &newrange, curr, PFMEM, 0); 260 rc = alloc_bus_range(&bus_cur, &newrange, curr, PFMEM, 0);
261 if (rc) 261 if (rc)
262 return rc; 262 return rc;
263 } else { 263 } else {
@@ -265,23 +265,23 @@ int __init ibmphp_rsrc_init (void)
265 rc = alloc_bus_range(&newbus, &newrange, curr, PFMEM, 1); 265 rc = alloc_bus_range(&newbus, &newrange, curr, PFMEM, 1);
266 if (rc) 266 if (rc)
267 return rc; 267 return rc;
268 list_add_tail (&newbus->bus_list, &gbuses); 268 list_add_tail(&newbus->bus_list, &gbuses);
269 debug ("1st Bus, PFMemory Primary Bus %x [%x - %x]\n", newbus->busno, newrange->start, newrange->end); 269 debug("1st Bus, PFMemory Primary Bus %x [%x - %x]\n", newbus->busno, newrange->start, newrange->end);
270 } 270 }
271 } 271 }
272 } else if ((curr->rsrc_type & RESTYPE) == IOMASK) { 272 } else if ((curr->rsrc_type & RESTYPE) == IOMASK) {
273 /* IO */ 273 /* IO */
274 if (list_empty (&gbuses)) { 274 if (list_empty(&gbuses)) {
275 /* no bus structure exists in place yet */ 275 /* no bus structure exists in place yet */
276 rc = alloc_bus_range(&newbus, &newrange, curr, IO, 1); 276 rc = alloc_bus_range(&newbus, &newrange, curr, IO, 1);
277 if (rc) 277 if (rc)
278 return rc; 278 return rc;
279 list_add_tail (&newbus->bus_list, &gbuses); 279 list_add_tail(&newbus->bus_list, &gbuses);
280 debug ("gbuses = NULL, IO Primary Bus %x [%x - %x]\n", newbus->busno, newrange->start, newrange->end); 280 debug("gbuses = NULL, IO Primary Bus %x [%x - %x]\n", newbus->busno, newrange->start, newrange->end);
281 } else { 281 } else {
282 bus_cur = find_bus_wprev (curr->bus_num, &bus_prev, 1); 282 bus_cur = find_bus_wprev(curr->bus_num, &bus_prev, 1);
283 if (bus_cur) { 283 if (bus_cur) {
284 rc = alloc_bus_range (&bus_cur, &newrange, curr, IO, 0); 284 rc = alloc_bus_range(&bus_cur, &newrange, curr, IO, 0);
285 if (rc) 285 if (rc)
286 return rc; 286 return rc;
287 } else { 287 } else {
@@ -289,8 +289,8 @@ int __init ibmphp_rsrc_init (void)
289 rc = alloc_bus_range(&newbus, &newrange, curr, IO, 1); 289 rc = alloc_bus_range(&newbus, &newrange, curr, IO, 1);
290 if (rc) 290 if (rc)
291 return rc; 291 return rc;
292 list_add_tail (&newbus->bus_list, &gbuses); 292 list_add_tail(&newbus->bus_list, &gbuses);
293 debug ("1st Bus, IO Primary Bus %x [%x - %x]\n", newbus->busno, newrange->start, newrange->end); 293 debug("1st Bus, IO Primary Bus %x [%x - %x]\n", newbus->busno, newrange->start, newrange->end);
294 } 294 }
295 } 295 }
296 296
@@ -302,7 +302,7 @@ int __init ibmphp_rsrc_init (void)
302 /* regular pci device resource */ 302 /* regular pci device resource */
303 if ((curr->rsrc_type & RESTYPE) == MMASK) { 303 if ((curr->rsrc_type & RESTYPE) == MMASK) {
304 /* Memory resource */ 304 /* Memory resource */
305 new_mem = alloc_resources (curr); 305 new_mem = alloc_resources(curr);
306 if (!new_mem) 306 if (!new_mem)
307 return -ENOMEM; 307 return -ENOMEM;
308 new_mem->type = MEM; 308 new_mem->type = MEM;
@@ -313,25 +313,25 @@ int __init ibmphp_rsrc_init (void)
313 * assign a -1 and then update once the range 313 * assign a -1 and then update once the range
314 * actually appears... 314 * actually appears...
315 */ 315 */
316 if (ibmphp_add_resource (new_mem) < 0) { 316 if (ibmphp_add_resource(new_mem) < 0) {
317 newbus = alloc_error_bus (curr, 0, 0); 317 newbus = alloc_error_bus(curr, 0, 0);
318 if (!newbus) 318 if (!newbus)
319 return -ENOMEM; 319 return -ENOMEM;
320 newbus->firstMem = new_mem; 320 newbus->firstMem = new_mem;
321 ++newbus->needMemUpdate; 321 ++newbus->needMemUpdate;
322 new_mem->rangeno = -1; 322 new_mem->rangeno = -1;
323 } 323 }
324 debug ("Memory resource for device %x, bus %x, [%x - %x]\n", new_mem->devfunc, new_mem->busno, new_mem->start, new_mem->end); 324 debug("Memory resource for device %x, bus %x, [%x - %x]\n", new_mem->devfunc, new_mem->busno, new_mem->start, new_mem->end);
325 325
326 } else if ((curr->rsrc_type & RESTYPE) == PFMASK) { 326 } else if ((curr->rsrc_type & RESTYPE) == PFMASK) {
327 /* PFMemory resource */ 327 /* PFMemory resource */
328 new_pfmem = alloc_resources (curr); 328 new_pfmem = alloc_resources(curr);
329 if (!new_pfmem) 329 if (!new_pfmem)
330 return -ENOMEM; 330 return -ENOMEM;
331 new_pfmem->type = PFMEM; 331 new_pfmem->type = PFMEM;
332 new_pfmem->fromMem = 0; 332 new_pfmem->fromMem = 0;
333 if (ibmphp_add_resource (new_pfmem) < 0) { 333 if (ibmphp_add_resource(new_pfmem) < 0) {
334 newbus = alloc_error_bus (curr, 0, 0); 334 newbus = alloc_error_bus(curr, 0, 0);
335 if (!newbus) 335 if (!newbus)
336 return -ENOMEM; 336 return -ENOMEM;
337 newbus->firstPFMem = new_pfmem; 337 newbus->firstPFMem = new_pfmem;
@@ -339,10 +339,10 @@ int __init ibmphp_rsrc_init (void)
339 new_pfmem->rangeno = -1; 339 new_pfmem->rangeno = -1;
340 } 340 }
341 341
342 debug ("PFMemory resource for device %x, bus %x, [%x - %x]\n", new_pfmem->devfunc, new_pfmem->busno, new_pfmem->start, new_pfmem->end); 342 debug("PFMemory resource for device %x, bus %x, [%x - %x]\n", new_pfmem->devfunc, new_pfmem->busno, new_pfmem->start, new_pfmem->end);
343 } else if ((curr->rsrc_type & RESTYPE) == IOMASK) { 343 } else if ((curr->rsrc_type & RESTYPE) == IOMASK) {
344 /* IO resource */ 344 /* IO resource */
345 new_io = alloc_resources (curr); 345 new_io = alloc_resources(curr);
346 if (!new_io) 346 if (!new_io)
347 return -ENOMEM; 347 return -ENOMEM;
348 new_io->type = IO; 348 new_io->type = IO;
@@ -354,26 +354,26 @@ int __init ibmphp_rsrc_init (void)
354 * Can assign a -1 and then update once the 354 * Can assign a -1 and then update once the
355 * range actually appears... 355 * range actually appears...
356 */ 356 */
357 if (ibmphp_add_resource (new_io) < 0) { 357 if (ibmphp_add_resource(new_io) < 0) {
358 newbus = alloc_error_bus (curr, 0, 0); 358 newbus = alloc_error_bus(curr, 0, 0);
359 if (!newbus) 359 if (!newbus)
360 return -ENOMEM; 360 return -ENOMEM;
361 newbus->firstIO = new_io; 361 newbus->firstIO = new_io;
362 ++newbus->needIOUpdate; 362 ++newbus->needIOUpdate;
363 new_io->rangeno = -1; 363 new_io->rangeno = -1;
364 } 364 }
365 debug ("IO resource for device %x, bus %x, [%x - %x]\n", new_io->devfunc, new_io->busno, new_io->start, new_io->end); 365 debug("IO resource for device %x, bus %x, [%x - %x]\n", new_io->devfunc, new_io->busno, new_io->start, new_io->end);
366 } 366 }
367 } 367 }
368 } 368 }
369 369
370 list_for_each_entry(bus_cur, &gbuses, bus_list) { 370 list_for_each_entry(bus_cur, &gbuses, bus_list) {
371 /* This is to get info about PPB resources, since EBDA doesn't put this info into the primary bus info */ 371 /* This is to get info about PPB resources, since EBDA doesn't put this info into the primary bus info */
372 rc = update_bridge_ranges (&bus_cur); 372 rc = update_bridge_ranges(&bus_cur);
373 if (rc) 373 if (rc)
374 return rc; 374 return rc;
375 } 375 }
376 return once_over (); /* This is to align ranges (so no -1) */ 376 return once_over(); /* This is to align ranges (so no -1) */
377} 377}
378 378
379/******************************************************************************** 379/********************************************************************************
@@ -384,7 +384,7 @@ int __init ibmphp_rsrc_init (void)
384 * Input: type of the resource, range to add, current bus 384 * Input: type of the resource, range to add, current bus
385 * Output: 0 or -1, bus and range ptrs 385 * Output: 0 or -1, bus and range ptrs
386 ********************************************************************************/ 386 ********************************************************************************/
387static int add_bus_range (int type, struct range_node *range, struct bus_node *bus_cur) 387static int add_bus_range(int type, struct range_node *range, struct bus_node *bus_cur)
388{ 388{
389 struct range_node *range_cur = NULL; 389 struct range_node *range_cur = NULL;
390 struct range_node *range_prev; 390 struct range_node *range_prev;
@@ -449,7 +449,7 @@ static int add_bus_range (int type, struct range_node *range, struct bus_node *b
449 range_cur = range_cur->next; 449 range_cur = range_cur->next;
450 } 450 }
451 451
452 update_resources (bus_cur, type, i_init + 1); 452 update_resources(bus_cur, type, i_init + 1);
453 return 0; 453 return 0;
454} 454}
455 455
@@ -459,7 +459,7 @@ static int add_bus_range (int type, struct range_node *range, struct bus_node *b
459 * 459 *
460 * Input: bus, type of the resource, the rangeno starting from which to update 460 * Input: bus, type of the resource, the rangeno starting from which to update
461 ******************************************************************************/ 461 ******************************************************************************/
462static void update_resources (struct bus_node *bus_cur, int type, int rangeno) 462static void update_resources(struct bus_node *bus_cur, int type, int rangeno)
463{ 463{
464 struct resource_node *res = NULL; 464 struct resource_node *res = NULL;
465 u8 eol = 0; /* end of list indicator */ 465 u8 eol = 0; /* end of list indicator */
@@ -503,9 +503,9 @@ static void update_resources (struct bus_node *bus_cur, int type, int rangeno)
503 } 503 }
504} 504}
505 505
506static void fix_me (struct resource_node *res, struct bus_node *bus_cur, struct range_node *range) 506static void fix_me(struct resource_node *res, struct bus_node *bus_cur, struct range_node *range)
507{ 507{
508 char * str = ""; 508 char *str = "";
509 switch (res->type) { 509 switch (res->type) {
510 case IO: 510 case IO:
511 str = "io"; 511 str = "io";
@@ -523,7 +523,7 @@ static void fix_me (struct resource_node *res, struct bus_node *bus_cur, struct
523 while (range) { 523 while (range) {
524 if ((res->start >= range->start) && (res->end <= range->end)) { 524 if ((res->start >= range->start) && (res->end <= range->end)) {
525 res->rangeno = range->rangeno; 525 res->rangeno = range->rangeno;
526 debug ("%s->rangeno in fix_resources is %d\n", str, res->rangeno); 526 debug("%s->rangeno in fix_resources is %d\n", str, res->rangeno);
527 switch (res->type) { 527 switch (res->type) {
528 case IO: 528 case IO:
529 --bus_cur->needIOUpdate; 529 --bus_cur->needIOUpdate;
@@ -558,27 +558,27 @@ static void fix_me (struct resource_node *res, struct bus_node *bus_cur, struct
558 * Input: current bus 558 * Input: current bus
559 * Output: none, list of resources for that bus are fixed if can be 559 * Output: none, list of resources for that bus are fixed if can be
560 *******************************************************************************/ 560 *******************************************************************************/
561static void fix_resources (struct bus_node *bus_cur) 561static void fix_resources(struct bus_node *bus_cur)
562{ 562{
563 struct range_node *range; 563 struct range_node *range;
564 struct resource_node *res; 564 struct resource_node *res;
565 565
566 debug ("%s - bus_cur->busno = %d\n", __func__, bus_cur->busno); 566 debug("%s - bus_cur->busno = %d\n", __func__, bus_cur->busno);
567 567
568 if (bus_cur->needIOUpdate) { 568 if (bus_cur->needIOUpdate) {
569 res = bus_cur->firstIO; 569 res = bus_cur->firstIO;
570 range = bus_cur->rangeIO; 570 range = bus_cur->rangeIO;
571 fix_me (res, bus_cur, range); 571 fix_me(res, bus_cur, range);
572 } 572 }
573 if (bus_cur->needMemUpdate) { 573 if (bus_cur->needMemUpdate) {
574 res = bus_cur->firstMem; 574 res = bus_cur->firstMem;
575 range = bus_cur->rangeMem; 575 range = bus_cur->rangeMem;
576 fix_me (res, bus_cur, range); 576 fix_me(res, bus_cur, range);
577 } 577 }
578 if (bus_cur->needPFMemUpdate) { 578 if (bus_cur->needPFMemUpdate) {
579 res = bus_cur->firstPFMem; 579 res = bus_cur->firstPFMem;
580 range = bus_cur->rangePFMem; 580 range = bus_cur->rangePFMem;
581 fix_me (res, bus_cur, range); 581 fix_me(res, bus_cur, range);
582 } 582 }
583} 583}
584 584
@@ -591,7 +591,7 @@ static void fix_resources (struct bus_node *bus_cur)
591 * Output: ptrs assigned (to the node) 591 * Output: ptrs assigned (to the node)
592 * 0 or -1 592 * 0 or -1
593 *******************************************************************************/ 593 *******************************************************************************/
594int ibmphp_add_resource (struct resource_node *res) 594int ibmphp_add_resource(struct resource_node *res)
595{ 595{
596 struct resource_node *res_cur; 596 struct resource_node *res_cur;
597 struct resource_node *res_prev; 597 struct resource_node *res_prev;
@@ -599,18 +599,18 @@ int ibmphp_add_resource (struct resource_node *res)
599 struct range_node *range_cur = NULL; 599 struct range_node *range_cur = NULL;
600 struct resource_node *res_start = NULL; 600 struct resource_node *res_start = NULL;
601 601
602 debug ("%s - enter\n", __func__); 602 debug("%s - enter\n", __func__);
603 603
604 if (!res) { 604 if (!res) {
605 err ("NULL passed to add\n"); 605 err("NULL passed to add\n");
606 return -ENODEV; 606 return -ENODEV;
607 } 607 }
608 608
609 bus_cur = find_bus_wprev (res->busno, NULL, 0); 609 bus_cur = find_bus_wprev(res->busno, NULL, 0);
610 610
611 if (!bus_cur) { 611 if (!bus_cur) {
612 /* didn't find a bus, something's wrong!!! */ 612 /* didn't find a bus, something's wrong!!! */
613 debug ("no bus in the system, either pci_dev's wrong or allocation failed\n"); 613 debug("no bus in the system, either pci_dev's wrong or allocation failed\n");
614 return -ENODEV; 614 return -ENODEV;
615 } 615 }
616 616
@@ -629,7 +629,7 @@ int ibmphp_add_resource (struct resource_node *res)
629 res_start = bus_cur->firstPFMem; 629 res_start = bus_cur->firstPFMem;
630 break; 630 break;
631 default: 631 default:
632 err ("cannot read the type of the resource to add... problem\n"); 632 err("cannot read the type of the resource to add... problem\n");
633 return -EINVAL; 633 return -EINVAL;
634 } 634 }
635 while (range_cur) { 635 while (range_cur) {
@@ -660,7 +660,7 @@ int ibmphp_add_resource (struct resource_node *res)
660 res->rangeno = -1; 660 res->rangeno = -1;
661 } 661 }
662 662
663 debug ("The range is %d\n", res->rangeno); 663 debug("The range is %d\n", res->rangeno);
664 if (!res_start) { 664 if (!res_start) {
665 /* no first{IO,Mem,Pfmem} on the bus, 1st IO/Mem/Pfmem resource ever */ 665 /* no first{IO,Mem,Pfmem} on the bus, 1st IO/Mem/Pfmem resource ever */
666 switch (res->type) { 666 switch (res->type) {
@@ -680,7 +680,7 @@ int ibmphp_add_resource (struct resource_node *res)
680 res_cur = res_start; 680 res_cur = res_start;
681 res_prev = NULL; 681 res_prev = NULL;
682 682
683 debug ("res_cur->rangeno is %d\n", res_cur->rangeno); 683 debug("res_cur->rangeno is %d\n", res_cur->rangeno);
684 684
685 while (res_cur) { 685 while (res_cur) {
686 if (res_cur->rangeno >= res->rangeno) 686 if (res_cur->rangeno >= res->rangeno)
@@ -694,7 +694,7 @@ int ibmphp_add_resource (struct resource_node *res)
694 694
695 if (!res_cur) { 695 if (!res_cur) {
696 /* at the end of the resource list */ 696 /* at the end of the resource list */
697 debug ("i should be here, [%x - %x]\n", res->start, res->end); 697 debug("i should be here, [%x - %x]\n", res->start, res->end);
698 res_prev->nextRange = res; 698 res_prev->nextRange = res;
699 res->next = NULL; 699 res->next = NULL;
700 res->nextRange = NULL; 700 res->nextRange = NULL;
@@ -762,7 +762,7 @@ int ibmphp_add_resource (struct resource_node *res)
762 } 762 }
763 } 763 }
764 764
765 debug ("%s - exit\n", __func__); 765 debug("%s - exit\n", __func__);
766 return 0; 766 return 0;
767} 767}
768 768
@@ -773,23 +773,23 @@ int ibmphp_add_resource (struct resource_node *res)
773 * Output: modified resource list 773 * Output: modified resource list
774 * 0 or error code 774 * 0 or error code
775 ****************************************************************************/ 775 ****************************************************************************/
776int ibmphp_remove_resource (struct resource_node *res) 776int ibmphp_remove_resource(struct resource_node *res)
777{ 777{
778 struct bus_node *bus_cur; 778 struct bus_node *bus_cur;
779 struct resource_node *res_cur = NULL; 779 struct resource_node *res_cur = NULL;
780 struct resource_node *res_prev; 780 struct resource_node *res_prev;
781 struct resource_node *mem_cur; 781 struct resource_node *mem_cur;
782 char * type = ""; 782 char *type = "";
783 783
784 if (!res) { 784 if (!res) {
785 err ("resource to remove is NULL\n"); 785 err("resource to remove is NULL\n");
786 return -ENODEV; 786 return -ENODEV;
787 } 787 }
788 788
789 bus_cur = find_bus_wprev (res->busno, NULL, 0); 789 bus_cur = find_bus_wprev(res->busno, NULL, 0);
790 790
791 if (!bus_cur) { 791 if (!bus_cur) {
792 err ("cannot find corresponding bus of the io resource to remove bailing out...\n"); 792 err("cannot find corresponding bus of the io resource to remove bailing out...\n");
793 return -ENODEV; 793 return -ENODEV;
794 } 794 }
795 795
@@ -807,7 +807,7 @@ int ibmphp_remove_resource (struct resource_node *res)
807 type = "pfmem"; 807 type = "pfmem";
808 break; 808 break;
809 default: 809 default:
810 err ("unknown type for resource to remove\n"); 810 err("unknown type for resource to remove\n");
811 return -EINVAL; 811 return -EINVAL;
812 } 812 }
813 res_prev = NULL; 813 res_prev = NULL;
@@ -845,16 +845,16 @@ int ibmphp_remove_resource (struct resource_node *res)
845 mem_cur = mem_cur->nextRange; 845 mem_cur = mem_cur->nextRange;
846 } 846 }
847 if (!mem_cur) { 847 if (!mem_cur) {
848 err ("cannot find corresponding mem node for pfmem...\n"); 848 err("cannot find corresponding mem node for pfmem...\n");
849 return -EINVAL; 849 return -EINVAL;
850 } 850 }
851 851
852 ibmphp_remove_resource (mem_cur); 852 ibmphp_remove_resource(mem_cur);
853 if (!res_prev) 853 if (!res_prev)
854 bus_cur->firstPFMemFromMem = res_cur->next; 854 bus_cur->firstPFMemFromMem = res_cur->next;
855 else 855 else
856 res_prev->next = res_cur->next; 856 res_prev->next = res_cur->next;
857 kfree (res_cur); 857 kfree(res_cur);
858 return 0; 858 return 0;
859 } 859 }
860 res_prev = res_cur; 860 res_prev = res_cur;
@@ -864,11 +864,11 @@ int ibmphp_remove_resource (struct resource_node *res)
864 res_cur = res_cur->nextRange; 864 res_cur = res_cur->nextRange;
865 } 865 }
866 if (!res_cur) { 866 if (!res_cur) {
867 err ("cannot find pfmem to delete...\n"); 867 err("cannot find pfmem to delete...\n");
868 return -EINVAL; 868 return -EINVAL;
869 } 869 }
870 } else { 870 } else {
871 err ("the %s resource is not in the list to be deleted...\n", type); 871 err("the %s resource is not in the list to be deleted...\n", type);
872 return -EINVAL; 872 return -EINVAL;
873 } 873 }
874 } 874 }
@@ -911,7 +911,7 @@ int ibmphp_remove_resource (struct resource_node *res)
911 break; 911 break;
912 } 912 }
913 } 913 }
914 kfree (res_cur); 914 kfree(res_cur);
915 return 0; 915 return 0;
916 } else { 916 } else {
917 if (res_cur->next) { 917 if (res_cur->next) {
@@ -926,14 +926,14 @@ int ibmphp_remove_resource (struct resource_node *res)
926 res_prev->next = NULL; 926 res_prev->next = NULL;
927 res_prev->nextRange = NULL; 927 res_prev->nextRange = NULL;
928 } 928 }
929 kfree (res_cur); 929 kfree(res_cur);
930 return 0; 930 return 0;
931 } 931 }
932 932
933 return 0; 933 return 0;
934} 934}
935 935
936static struct range_node *find_range (struct bus_node *bus_cur, struct resource_node *res) 936static struct range_node *find_range(struct bus_node *bus_cur, struct resource_node *res)
937{ 937{
938 struct range_node *range = NULL; 938 struct range_node *range = NULL;
939 939
@@ -948,7 +948,7 @@ static struct range_node *find_range (struct bus_node *bus_cur, struct resource_
948 range = bus_cur->rangePFMem; 948 range = bus_cur->rangePFMem;
949 break; 949 break;
950 default: 950 default:
951 err ("cannot read resource type in find_range\n"); 951 err("cannot read resource type in find_range\n");
952 } 952 }
953 953
954 while (range) { 954 while (range) {
@@ -968,7 +968,7 @@ static struct range_node *find_range (struct bus_node *bus_cur, struct resource_
968 * Output: the correct start and end address are inputted into the resource node, 968 * Output: the correct start and end address are inputted into the resource node,
969 * 0 or -EINVAL 969 * 0 or -EINVAL
970 *****************************************************************************/ 970 *****************************************************************************/
971int ibmphp_check_resource (struct resource_node *res, u8 bridge) 971int ibmphp_check_resource(struct resource_node *res, u8 bridge)
972{ 972{
973 struct bus_node *bus_cur; 973 struct bus_node *bus_cur;
974 struct range_node *range = NULL; 974 struct range_node *range = NULL;
@@ -992,16 +992,16 @@ int ibmphp_check_resource (struct resource_node *res, u8 bridge)
992 } else 992 } else
993 tmp_divide = res->len; 993 tmp_divide = res->len;
994 994
995 bus_cur = find_bus_wprev (res->busno, NULL, 0); 995 bus_cur = find_bus_wprev(res->busno, NULL, 0);
996 996
997 if (!bus_cur) { 997 if (!bus_cur) {
998 /* didn't find a bus, something's wrong!!! */ 998 /* didn't find a bus, something's wrong!!! */
999 debug ("no bus in the system, either pci_dev's wrong or allocation failed\n"); 999 debug("no bus in the system, either pci_dev's wrong or allocation failed\n");
1000 return -EINVAL; 1000 return -EINVAL;
1001 } 1001 }
1002 1002
1003 debug ("%s - enter\n", __func__); 1003 debug("%s - enter\n", __func__);
1004 debug ("bus_cur->busno is %d\n", bus_cur->busno); 1004 debug("bus_cur->busno is %d\n", bus_cur->busno);
1005 1005
1006 /* This is a quick fix to not mess up with the code very much. i.e., 1006 /* This is a quick fix to not mess up with the code very much. i.e.,
1007 * 2000-2fff, len = 1000, but when we compare, we need it to be fff */ 1007 * 2000-2fff, len = 1000, but when we compare, we need it to be fff */
@@ -1021,17 +1021,17 @@ int ibmphp_check_resource (struct resource_node *res, u8 bridge)
1021 noranges = bus_cur->noPFMemRanges; 1021 noranges = bus_cur->noPFMemRanges;
1022 break; 1022 break;
1023 default: 1023 default:
1024 err ("wrong type of resource to check\n"); 1024 err("wrong type of resource to check\n");
1025 return -EINVAL; 1025 return -EINVAL;
1026 } 1026 }
1027 res_prev = NULL; 1027 res_prev = NULL;
1028 1028
1029 while (res_cur) { 1029 while (res_cur) {
1030 range = find_range (bus_cur, res_cur); 1030 range = find_range(bus_cur, res_cur);
1031 debug ("%s - rangeno = %d\n", __func__, res_cur->rangeno); 1031 debug("%s - rangeno = %d\n", __func__, res_cur->rangeno);
1032 1032
1033 if (!range) { 1033 if (!range) {
1034 err ("no range for the device exists... bailing out...\n"); 1034 err("no range for the device exists... bailing out...\n");
1035 return -EINVAL; 1035 return -EINVAL;
1036 } 1036 }
1037 1037
@@ -1041,7 +1041,7 @@ int ibmphp_check_resource (struct resource_node *res, u8 bridge)
1041 len_tmp = res_cur->start - 1 - range->start; 1041 len_tmp = res_cur->start - 1 - range->start;
1042 1042
1043 if ((res_cur->start != range->start) && (len_tmp >= res->len)) { 1043 if ((res_cur->start != range->start) && (len_tmp >= res->len)) {
1044 debug ("len_tmp = %x\n", len_tmp); 1044 debug("len_tmp = %x\n", len_tmp);
1045 1045
1046 if ((len_tmp < len_cur) || (len_cur == 0)) { 1046 if ((len_tmp < len_cur) || (len_cur == 0)) {
1047 1047
@@ -1069,7 +1069,7 @@ int ibmphp_check_resource (struct resource_node *res, u8 bridge)
1069 } 1069 }
1070 1070
1071 if (flag && len_cur == res->len) { 1071 if (flag && len_cur == res->len) {
1072 debug ("but we are not here, right?\n"); 1072 debug("but we are not here, right?\n");
1073 res->start = start_cur; 1073 res->start = start_cur;
1074 res->len += 1; /* To restore the balance */ 1074 res->len += 1; /* To restore the balance */
1075 res->end = res->start + res->len - 1; 1075 res->end = res->start + res->len - 1;
@@ -1083,7 +1083,7 @@ int ibmphp_check_resource (struct resource_node *res, u8 bridge)
1083 len_tmp = range->end - (res_cur->end + 1); 1083 len_tmp = range->end - (res_cur->end + 1);
1084 1084
1085 if ((range->end != res_cur->end) && (len_tmp >= res->len)) { 1085 if ((range->end != res_cur->end) && (len_tmp >= res->len)) {
1086 debug ("len_tmp = %x\n", len_tmp); 1086 debug("len_tmp = %x\n", len_tmp);
1087 if ((len_tmp < len_cur) || (len_cur == 0)) { 1087 if ((len_tmp < len_cur) || (len_cur == 0)) {
1088 1088
1089 if (((res_cur->end + 1) % tmp_divide) == 0) { 1089 if (((res_cur->end + 1) % tmp_divide) == 0) {
@@ -1259,7 +1259,7 @@ int ibmphp_check_resource (struct resource_node *res, u8 bridge)
1259 1259
1260 if ((!range) && (len_cur == 0)) { 1260 if ((!range) && (len_cur == 0)) {
1261 /* have gone through the list of devices and ranges and haven't found n.e.thing */ 1261 /* have gone through the list of devices and ranges and haven't found n.e.thing */
1262 err ("no appropriate range.. bailing out...\n"); 1262 err("no appropriate range.. bailing out...\n");
1263 return -EINVAL; 1263 return -EINVAL;
1264 } else if (len_cur) { 1264 } else if (len_cur) {
1265 res->start = start_cur; 1265 res->start = start_cur;
@@ -1270,7 +1270,7 @@ int ibmphp_check_resource (struct resource_node *res, u8 bridge)
1270 } 1270 }
1271 1271
1272 if (!res_cur) { 1272 if (!res_cur) {
1273 debug ("prev->rangeno = %d, noranges = %d\n", res_prev->rangeno, noranges); 1273 debug("prev->rangeno = %d, noranges = %d\n", res_prev->rangeno, noranges);
1274 if (res_prev->rangeno < noranges) { 1274 if (res_prev->rangeno < noranges) {
1275 /* if there're more ranges out there to check */ 1275 /* if there're more ranges out there to check */
1276 switch (res->type) { 1276 switch (res->type) {
@@ -1325,7 +1325,7 @@ int ibmphp_check_resource (struct resource_node *res, u8 bridge)
1325 1325
1326 if ((!range) && (len_cur == 0)) { 1326 if ((!range) && (len_cur == 0)) {
1327 /* have gone through the list of devices and ranges and haven't found n.e.thing */ 1327 /* have gone through the list of devices and ranges and haven't found n.e.thing */
1328 err ("no appropriate range.. bailing out...\n"); 1328 err("no appropriate range.. bailing out...\n");
1329 return -EINVAL; 1329 return -EINVAL;
1330 } else if (len_cur) { 1330 } else if (len_cur) {
1331 res->start = start_cur; 1331 res->start = start_cur;
@@ -1342,7 +1342,7 @@ int ibmphp_check_resource (struct resource_node *res, u8 bridge)
1342 return 0; 1342 return 0;
1343 } else { 1343 } else {
1344 /* have gone through the list of devices and haven't found n.e.thing */ 1344 /* have gone through the list of devices and haven't found n.e.thing */
1345 err ("no appropriate range.. bailing out...\n"); 1345 err("no appropriate range.. bailing out...\n");
1346 return -EINVAL; 1346 return -EINVAL;
1347 } 1347 }
1348 } 1348 }
@@ -1356,23 +1356,23 @@ int ibmphp_check_resource (struct resource_node *res, u8 bridge)
1356 * Input: Bus 1356 * Input: Bus
1357 * Output: 0, -ENODEV 1357 * Output: 0, -ENODEV
1358 ********************************************************************************/ 1358 ********************************************************************************/
1359int ibmphp_remove_bus (struct bus_node *bus, u8 parent_busno) 1359int ibmphp_remove_bus(struct bus_node *bus, u8 parent_busno)
1360{ 1360{
1361 struct resource_node *res_cur; 1361 struct resource_node *res_cur;
1362 struct resource_node *res_tmp; 1362 struct resource_node *res_tmp;
1363 struct bus_node *prev_bus; 1363 struct bus_node *prev_bus;
1364 int rc; 1364 int rc;
1365 1365
1366 prev_bus = find_bus_wprev (parent_busno, NULL, 0); 1366 prev_bus = find_bus_wprev(parent_busno, NULL, 0);
1367 1367
1368 if (!prev_bus) { 1368 if (!prev_bus) {
1369 debug ("something terribly wrong. Cannot find parent bus to the one to remove\n"); 1369 debug("something terribly wrong. Cannot find parent bus to the one to remove\n");
1370 return -ENODEV; 1370 return -ENODEV;
1371 } 1371 }
1372 1372
1373 debug ("In ibmphp_remove_bus... prev_bus->busno is %x\n", prev_bus->busno); 1373 debug("In ibmphp_remove_bus... prev_bus->busno is %x\n", prev_bus->busno);
1374 1374
1375 rc = remove_ranges (bus, prev_bus); 1375 rc = remove_ranges(bus, prev_bus);
1376 if (rc) 1376 if (rc)
1377 return rc; 1377 return rc;
1378 1378
@@ -1384,7 +1384,7 @@ int ibmphp_remove_bus (struct bus_node *bus, u8 parent_busno)
1384 res_cur = res_cur->next; 1384 res_cur = res_cur->next;
1385 else 1385 else
1386 res_cur = res_cur->nextRange; 1386 res_cur = res_cur->nextRange;
1387 kfree (res_tmp); 1387 kfree(res_tmp);
1388 res_tmp = NULL; 1388 res_tmp = NULL;
1389 } 1389 }
1390 bus->firstIO = NULL; 1390 bus->firstIO = NULL;
@@ -1397,7 +1397,7 @@ int ibmphp_remove_bus (struct bus_node *bus, u8 parent_busno)
1397 res_cur = res_cur->next; 1397 res_cur = res_cur->next;
1398 else 1398 else
1399 res_cur = res_cur->nextRange; 1399 res_cur = res_cur->nextRange;
1400 kfree (res_tmp); 1400 kfree(res_tmp);
1401 res_tmp = NULL; 1401 res_tmp = NULL;
1402 } 1402 }
1403 bus->firstMem = NULL; 1403 bus->firstMem = NULL;
@@ -1410,7 +1410,7 @@ int ibmphp_remove_bus (struct bus_node *bus, u8 parent_busno)
1410 res_cur = res_cur->next; 1410 res_cur = res_cur->next;
1411 else 1411 else
1412 res_cur = res_cur->nextRange; 1412 res_cur = res_cur->nextRange;
1413 kfree (res_tmp); 1413 kfree(res_tmp);
1414 res_tmp = NULL; 1414 res_tmp = NULL;
1415 } 1415 }
1416 bus->firstPFMem = NULL; 1416 bus->firstPFMem = NULL;
@@ -1422,14 +1422,14 @@ int ibmphp_remove_bus (struct bus_node *bus, u8 parent_busno)
1422 res_tmp = res_cur; 1422 res_tmp = res_cur;
1423 res_cur = res_cur->next; 1423 res_cur = res_cur->next;
1424 1424
1425 kfree (res_tmp); 1425 kfree(res_tmp);
1426 res_tmp = NULL; 1426 res_tmp = NULL;
1427 } 1427 }
1428 bus->firstPFMemFromMem = NULL; 1428 bus->firstPFMemFromMem = NULL;
1429 } 1429 }
1430 1430
1431 list_del (&bus->bus_list); 1431 list_del(&bus->bus_list);
1432 kfree (bus); 1432 kfree(bus);
1433 return 0; 1433 return 0;
1434} 1434}
1435 1435
@@ -1439,7 +1439,7 @@ int ibmphp_remove_bus (struct bus_node *bus, u8 parent_busno)
1439 * Input: current bus, previous bus 1439 * Input: current bus, previous bus
1440 * Output: 0, -EINVAL 1440 * Output: 0, -EINVAL
1441 ******************************************************************************/ 1441 ******************************************************************************/
1442static int remove_ranges (struct bus_node *bus_cur, struct bus_node *bus_prev) 1442static int remove_ranges(struct bus_node *bus_cur, struct bus_node *bus_prev)
1443{ 1443{
1444 struct range_node *range_cur; 1444 struct range_node *range_cur;
1445 struct range_node *range_tmp; 1445 struct range_node *range_tmp;
@@ -1449,13 +1449,13 @@ static int remove_ranges (struct bus_node *bus_cur, struct bus_node *bus_prev)
1449 if (bus_cur->noIORanges) { 1449 if (bus_cur->noIORanges) {
1450 range_cur = bus_cur->rangeIO; 1450 range_cur = bus_cur->rangeIO;
1451 for (i = 0; i < bus_cur->noIORanges; i++) { 1451 for (i = 0; i < bus_cur->noIORanges; i++) {
1452 if (ibmphp_find_resource (bus_prev, range_cur->start, &res, IO) < 0) 1452 if (ibmphp_find_resource(bus_prev, range_cur->start, &res, IO) < 0)
1453 return -EINVAL; 1453 return -EINVAL;
1454 ibmphp_remove_resource (res); 1454 ibmphp_remove_resource(res);
1455 1455
1456 range_tmp = range_cur; 1456 range_tmp = range_cur;
1457 range_cur = range_cur->next; 1457 range_cur = range_cur->next;
1458 kfree (range_tmp); 1458 kfree(range_tmp);
1459 range_tmp = NULL; 1459 range_tmp = NULL;
1460 } 1460 }
1461 bus_cur->rangeIO = NULL; 1461 bus_cur->rangeIO = NULL;
@@ -1463,13 +1463,13 @@ static int remove_ranges (struct bus_node *bus_cur, struct bus_node *bus_prev)
1463 if (bus_cur->noMemRanges) { 1463 if (bus_cur->noMemRanges) {
1464 range_cur = bus_cur->rangeMem; 1464 range_cur = bus_cur->rangeMem;
1465 for (i = 0; i < bus_cur->noMemRanges; i++) { 1465 for (i = 0; i < bus_cur->noMemRanges; i++) {
1466 if (ibmphp_find_resource (bus_prev, range_cur->start, &res, MEM) < 0) 1466 if (ibmphp_find_resource(bus_prev, range_cur->start, &res, MEM) < 0)
1467 return -EINVAL; 1467 return -EINVAL;
1468 1468
1469 ibmphp_remove_resource (res); 1469 ibmphp_remove_resource(res);
1470 range_tmp = range_cur; 1470 range_tmp = range_cur;
1471 range_cur = range_cur->next; 1471 range_cur = range_cur->next;
1472 kfree (range_tmp); 1472 kfree(range_tmp);
1473 range_tmp = NULL; 1473 range_tmp = NULL;
1474 } 1474 }
1475 bus_cur->rangeMem = NULL; 1475 bus_cur->rangeMem = NULL;
@@ -1477,13 +1477,13 @@ static int remove_ranges (struct bus_node *bus_cur, struct bus_node *bus_prev)
1477 if (bus_cur->noPFMemRanges) { 1477 if (bus_cur->noPFMemRanges) {
1478 range_cur = bus_cur->rangePFMem; 1478 range_cur = bus_cur->rangePFMem;
1479 for (i = 0; i < bus_cur->noPFMemRanges; i++) { 1479 for (i = 0; i < bus_cur->noPFMemRanges; i++) {
1480 if (ibmphp_find_resource (bus_prev, range_cur->start, &res, PFMEM) < 0) 1480 if (ibmphp_find_resource(bus_prev, range_cur->start, &res, PFMEM) < 0)
1481 return -EINVAL; 1481 return -EINVAL;
1482 1482
1483 ibmphp_remove_resource (res); 1483 ibmphp_remove_resource(res);
1484 range_tmp = range_cur; 1484 range_tmp = range_cur;
1485 range_cur = range_cur->next; 1485 range_cur = range_cur->next;
1486 kfree (range_tmp); 1486 kfree(range_tmp);
1487 range_tmp = NULL; 1487 range_tmp = NULL;
1488 } 1488 }
1489 bus_cur->rangePFMem = NULL; 1489 bus_cur->rangePFMem = NULL;
@@ -1495,13 +1495,13 @@ static int remove_ranges (struct bus_node *bus_cur, struct bus_node *bus_prev)
1495 * find the resource node in the bus 1495 * find the resource node in the bus
1496 * Input: Resource needed, start address of the resource, type of resource 1496 * Input: Resource needed, start address of the resource, type of resource
1497 */ 1497 */
1498int ibmphp_find_resource (struct bus_node *bus, u32 start_address, struct resource_node **res, int flag) 1498int ibmphp_find_resource(struct bus_node *bus, u32 start_address, struct resource_node **res, int flag)
1499{ 1499{
1500 struct resource_node *res_cur = NULL; 1500 struct resource_node *res_cur = NULL;
1501 char * type = ""; 1501 char *type = "";
1502 1502
1503 if (!bus) { 1503 if (!bus) {
1504 err ("The bus passed in NULL to find resource\n"); 1504 err("The bus passed in NULL to find resource\n");
1505 return -ENODEV; 1505 return -ENODEV;
1506 } 1506 }
1507 1507
@@ -1519,7 +1519,7 @@ int ibmphp_find_resource (struct bus_node *bus, u32 start_address, struct resour
1519 type = "pfmem"; 1519 type = "pfmem";
1520 break; 1520 break;
1521 default: 1521 default:
1522 err ("wrong type of flag\n"); 1522 err("wrong type of flag\n");
1523 return -EINVAL; 1523 return -EINVAL;
1524 } 1524 }
1525 1525
@@ -1545,17 +1545,17 @@ int ibmphp_find_resource (struct bus_node *bus, u32 start_address, struct resour
1545 res_cur = res_cur->next; 1545 res_cur = res_cur->next;
1546 } 1546 }
1547 if (!res_cur) { 1547 if (!res_cur) {
1548 debug ("SOS...cannot find %s resource in the bus.\n", type); 1548 debug("SOS...cannot find %s resource in the bus.\n", type);
1549 return -EINVAL; 1549 return -EINVAL;
1550 } 1550 }
1551 } else { 1551 } else {
1552 debug ("SOS... cannot find %s resource in the bus.\n", type); 1552 debug("SOS... cannot find %s resource in the bus.\n", type);
1553 return -EINVAL; 1553 return -EINVAL;
1554 } 1554 }
1555 } 1555 }
1556 1556
1557 if (*res) 1557 if (*res)
1558 debug ("*res->start = %x\n", (*res)->start); 1558 debug("*res->start = %x\n", (*res)->start);
1559 1559
1560 return 0; 1560 return 0;
1561} 1561}
@@ -1566,7 +1566,7 @@ int ibmphp_find_resource (struct bus_node *bus, u32 start_address, struct resour
1566 * Parameters: none 1566 * Parameters: none
1567 * Returns: none 1567 * Returns: none
1568 ***********************************************************************/ 1568 ***********************************************************************/
1569void ibmphp_free_resources (void) 1569void ibmphp_free_resources(void)
1570{ 1570{
1571 struct bus_node *bus_cur = NULL, *next; 1571 struct bus_node *bus_cur = NULL, *next;
1572 struct bus_node *bus_tmp; 1572 struct bus_node *bus_tmp;
@@ -1585,7 +1585,7 @@ void ibmphp_free_resources (void)
1585 break; 1585 break;
1586 range_tmp = range_cur; 1586 range_tmp = range_cur;
1587 range_cur = range_cur->next; 1587 range_cur = range_cur->next;
1588 kfree (range_tmp); 1588 kfree(range_tmp);
1589 range_tmp = NULL; 1589 range_tmp = NULL;
1590 } 1590 }
1591 } 1591 }
@@ -1596,7 +1596,7 @@ void ibmphp_free_resources (void)
1596 break; 1596 break;
1597 range_tmp = range_cur; 1597 range_tmp = range_cur;
1598 range_cur = range_cur->next; 1598 range_cur = range_cur->next;
1599 kfree (range_tmp); 1599 kfree(range_tmp);
1600 range_tmp = NULL; 1600 range_tmp = NULL;
1601 } 1601 }
1602 } 1602 }
@@ -1607,7 +1607,7 @@ void ibmphp_free_resources (void)
1607 break; 1607 break;
1608 range_tmp = range_cur; 1608 range_tmp = range_cur;
1609 range_cur = range_cur->next; 1609 range_cur = range_cur->next;
1610 kfree (range_tmp); 1610 kfree(range_tmp);
1611 range_tmp = NULL; 1611 range_tmp = NULL;
1612 } 1612 }
1613 } 1613 }
@@ -1620,7 +1620,7 @@ void ibmphp_free_resources (void)
1620 res_cur = res_cur->next; 1620 res_cur = res_cur->next;
1621 else 1621 else
1622 res_cur = res_cur->nextRange; 1622 res_cur = res_cur->nextRange;
1623 kfree (res_tmp); 1623 kfree(res_tmp);
1624 res_tmp = NULL; 1624 res_tmp = NULL;
1625 } 1625 }
1626 bus_cur->firstIO = NULL; 1626 bus_cur->firstIO = NULL;
@@ -1633,7 +1633,7 @@ void ibmphp_free_resources (void)
1633 res_cur = res_cur->next; 1633 res_cur = res_cur->next;
1634 else 1634 else
1635 res_cur = res_cur->nextRange; 1635 res_cur = res_cur->nextRange;
1636 kfree (res_tmp); 1636 kfree(res_tmp);
1637 res_tmp = NULL; 1637 res_tmp = NULL;
1638 } 1638 }
1639 bus_cur->firstMem = NULL; 1639 bus_cur->firstMem = NULL;
@@ -1646,7 +1646,7 @@ void ibmphp_free_resources (void)
1646 res_cur = res_cur->next; 1646 res_cur = res_cur->next;
1647 else 1647 else
1648 res_cur = res_cur->nextRange; 1648 res_cur = res_cur->nextRange;
1649 kfree (res_tmp); 1649 kfree(res_tmp);
1650 res_tmp = NULL; 1650 res_tmp = NULL;
1651 } 1651 }
1652 bus_cur->firstPFMem = NULL; 1652 bus_cur->firstPFMem = NULL;
@@ -1658,15 +1658,15 @@ void ibmphp_free_resources (void)
1658 res_tmp = res_cur; 1658 res_tmp = res_cur;
1659 res_cur = res_cur->next; 1659 res_cur = res_cur->next;
1660 1660
1661 kfree (res_tmp); 1661 kfree(res_tmp);
1662 res_tmp = NULL; 1662 res_tmp = NULL;
1663 } 1663 }
1664 bus_cur->firstPFMemFromMem = NULL; 1664 bus_cur->firstPFMemFromMem = NULL;
1665 } 1665 }
1666 1666
1667 bus_tmp = bus_cur; 1667 bus_tmp = bus_cur;
1668 list_del (&bus_cur->bus_list); 1668 list_del(&bus_cur->bus_list);
1669 kfree (bus_tmp); 1669 kfree(bus_tmp);
1670 bus_tmp = NULL; 1670 bus_tmp = NULL;
1671 } 1671 }
1672} 1672}
@@ -1679,7 +1679,7 @@ void ibmphp_free_resources (void)
1679 * a new Mem node 1679 * a new Mem node
1680 * This routine is called right after initialization 1680 * This routine is called right after initialization
1681 *******************************************************************************/ 1681 *******************************************************************************/
1682static int __init once_over (void) 1682static int __init once_over(void)
1683{ 1683{
1684 struct resource_node *pfmem_cur; 1684 struct resource_node *pfmem_cur;
1685 struct resource_node *pfmem_prev; 1685 struct resource_node *pfmem_prev;
@@ -1708,7 +1708,7 @@ static int __init once_over (void)
1708 1708
1709 mem = kzalloc(sizeof(struct resource_node), GFP_KERNEL); 1709 mem = kzalloc(sizeof(struct resource_node), GFP_KERNEL);
1710 if (!mem) { 1710 if (!mem) {
1711 err ("out of system memory\n"); 1711 err("out of system memory\n");
1712 return -ENOMEM; 1712 return -ENOMEM;
1713 } 1713 }
1714 mem->type = MEM; 1714 mem->type = MEM;
@@ -1717,8 +1717,8 @@ static int __init once_over (void)
1717 mem->start = pfmem_cur->start; 1717 mem->start = pfmem_cur->start;
1718 mem->end = pfmem_cur->end; 1718 mem->end = pfmem_cur->end;
1719 mem->len = pfmem_cur->len; 1719 mem->len = pfmem_cur->len;
1720 if (ibmphp_add_resource (mem) < 0) 1720 if (ibmphp_add_resource(mem) < 0)
1721 err ("Trouble...trouble... EBDA allocated pfmem from mem, but system doesn't display it has this space... unless not PCI device...\n"); 1721 err("Trouble...trouble... EBDA allocated pfmem from mem, but system doesn't display it has this space... unless not PCI device...\n");
1722 pfmem_cur->rangeno = mem->rangeno; 1722 pfmem_cur->rangeno = mem->rangeno;
1723 } /* end for pfmem */ 1723 } /* end for pfmem */
1724 } /* end if */ 1724 } /* end if */
@@ -1726,12 +1726,12 @@ static int __init once_over (void)
1726 return 0; 1726 return 0;
1727} 1727}
1728 1728
1729int ibmphp_add_pfmem_from_mem (struct resource_node *pfmem) 1729int ibmphp_add_pfmem_from_mem(struct resource_node *pfmem)
1730{ 1730{
1731 struct bus_node *bus_cur = find_bus_wprev (pfmem->busno, NULL, 0); 1731 struct bus_node *bus_cur = find_bus_wprev(pfmem->busno, NULL, 0);
1732 1732
1733 if (!bus_cur) { 1733 if (!bus_cur) {
1734 err ("cannot find bus of pfmem to add...\n"); 1734 err("cannot find bus of pfmem to add...\n");
1735 return -ENODEV; 1735 return -ENODEV;
1736 } 1736 }
1737 1737
@@ -1751,12 +1751,12 @@ int ibmphp_add_pfmem_from_mem (struct resource_node *pfmem)
1751 * Parameters: bus_number 1751 * Parameters: bus_number
1752 * Returns: Bus pointer or NULL 1752 * Returns: Bus pointer or NULL
1753 */ 1753 */
1754struct bus_node *ibmphp_find_res_bus (u8 bus_number) 1754struct bus_node *ibmphp_find_res_bus(u8 bus_number)
1755{ 1755{
1756 return find_bus_wprev (bus_number, NULL, 0); 1756 return find_bus_wprev(bus_number, NULL, 0);
1757} 1757}
1758 1758
1759static struct bus_node *find_bus_wprev (u8 bus_number, struct bus_node **prev, u8 flag) 1759static struct bus_node *find_bus_wprev(u8 bus_number, struct bus_node **prev, u8 flag)
1760{ 1760{
1761 struct bus_node *bus_cur; 1761 struct bus_node *bus_cur;
1762 1762
@@ -1770,17 +1770,17 @@ static struct bus_node *find_bus_wprev (u8 bus_number, struct bus_node **prev, u
1770 return NULL; 1770 return NULL;
1771} 1771}
1772 1772
1773void ibmphp_print_test (void) 1773void ibmphp_print_test(void)
1774{ 1774{
1775 int i = 0; 1775 int i = 0;
1776 struct bus_node *bus_cur = NULL; 1776 struct bus_node *bus_cur = NULL;
1777 struct range_node *range; 1777 struct range_node *range;
1778 struct resource_node *res; 1778 struct resource_node *res;
1779 1779
1780 debug_pci ("*****************START**********************\n"); 1780 debug_pci("*****************START**********************\n");
1781 1781
1782 if ((!list_empty(&gbuses)) && flags) { 1782 if ((!list_empty(&gbuses)) && flags) {
1783 err ("The GBUSES is not NULL?!?!?!?!?\n"); 1783 err("The GBUSES is not NULL?!?!?!?!?\n");
1784 return; 1784 return;
1785 } 1785 }
1786 1786
@@ -1793,42 +1793,42 @@ void ibmphp_print_test (void)
1793 if (bus_cur->rangeIO) { 1793 if (bus_cur->rangeIO) {
1794 range = bus_cur->rangeIO; 1794 range = bus_cur->rangeIO;
1795 for (i = 0; i < bus_cur->noIORanges; i++) { 1795 for (i = 0; i < bus_cur->noIORanges; i++) {
1796 debug_pci ("rangeno is %d\n", range->rangeno); 1796 debug_pci("rangeno is %d\n", range->rangeno);
1797 debug_pci ("[%x - %x]\n", range->start, range->end); 1797 debug_pci("[%x - %x]\n", range->start, range->end);
1798 range = range->next; 1798 range = range->next;
1799 } 1799 }
1800 } 1800 }
1801 1801
1802 debug_pci ("The Mem Ranges are as follows:\n"); 1802 debug_pci("The Mem Ranges are as follows:\n");
1803 if (bus_cur->rangeMem) { 1803 if (bus_cur->rangeMem) {
1804 range = bus_cur->rangeMem; 1804 range = bus_cur->rangeMem;
1805 for (i = 0; i < bus_cur->noMemRanges; i++) { 1805 for (i = 0; i < bus_cur->noMemRanges; i++) {
1806 debug_pci ("rangeno is %d\n", range->rangeno); 1806 debug_pci("rangeno is %d\n", range->rangeno);
1807 debug_pci ("[%x - %x]\n", range->start, range->end); 1807 debug_pci("[%x - %x]\n", range->start, range->end);
1808 range = range->next; 1808 range = range->next;
1809 } 1809 }
1810 } 1810 }
1811 1811
1812 debug_pci ("The PFMem Ranges are as follows:\n"); 1812 debug_pci("The PFMem Ranges are as follows:\n");
1813 1813
1814 if (bus_cur->rangePFMem) { 1814 if (bus_cur->rangePFMem) {
1815 range = bus_cur->rangePFMem; 1815 range = bus_cur->rangePFMem;
1816 for (i = 0; i < bus_cur->noPFMemRanges; i++) { 1816 for (i = 0; i < bus_cur->noPFMemRanges; i++) {
1817 debug_pci ("rangeno is %d\n", range->rangeno); 1817 debug_pci("rangeno is %d\n", range->rangeno);
1818 debug_pci ("[%x - %x]\n", range->start, range->end); 1818 debug_pci("[%x - %x]\n", range->start, range->end);
1819 range = range->next; 1819 range = range->next;
1820 } 1820 }
1821 } 1821 }
1822 1822
1823 debug_pci ("The resources on this bus are as follows\n"); 1823 debug_pci("The resources on this bus are as follows\n");
1824 1824
1825 debug_pci ("IO...\n"); 1825 debug_pci("IO...\n");
1826 if (bus_cur->firstIO) { 1826 if (bus_cur->firstIO) {
1827 res = bus_cur->firstIO; 1827 res = bus_cur->firstIO;
1828 while (res) { 1828 while (res) {
1829 debug_pci ("The range # is %d\n", res->rangeno); 1829 debug_pci("The range # is %d\n", res->rangeno);
1830 debug_pci ("The bus, devfnc is %d, %x\n", res->busno, res->devfunc); 1830 debug_pci("The bus, devfnc is %d, %x\n", res->busno, res->devfunc);
1831 debug_pci ("[%x - %x], len=%x\n", res->start, res->end, res->len); 1831 debug_pci("[%x - %x], len=%x\n", res->start, res->end, res->len);
1832 if (res->next) 1832 if (res->next)
1833 res = res->next; 1833 res = res->next;
1834 else if (res->nextRange) 1834 else if (res->nextRange)
@@ -1837,13 +1837,13 @@ void ibmphp_print_test (void)
1837 break; 1837 break;
1838 } 1838 }
1839 } 1839 }
1840 debug_pci ("Mem...\n"); 1840 debug_pci("Mem...\n");
1841 if (bus_cur->firstMem) { 1841 if (bus_cur->firstMem) {
1842 res = bus_cur->firstMem; 1842 res = bus_cur->firstMem;
1843 while (res) { 1843 while (res) {
1844 debug_pci ("The range # is %d\n", res->rangeno); 1844 debug_pci("The range # is %d\n", res->rangeno);
1845 debug_pci ("The bus, devfnc is %d, %x\n", res->busno, res->devfunc); 1845 debug_pci("The bus, devfnc is %d, %x\n", res->busno, res->devfunc);
1846 debug_pci ("[%x - %x], len=%x\n", res->start, res->end, res->len); 1846 debug_pci("[%x - %x], len=%x\n", res->start, res->end, res->len);
1847 if (res->next) 1847 if (res->next)
1848 res = res->next; 1848 res = res->next;
1849 else if (res->nextRange) 1849 else if (res->nextRange)
@@ -1852,13 +1852,13 @@ void ibmphp_print_test (void)
1852 break; 1852 break;
1853 } 1853 }
1854 } 1854 }
1855 debug_pci ("PFMem...\n"); 1855 debug_pci("PFMem...\n");
1856 if (bus_cur->firstPFMem) { 1856 if (bus_cur->firstPFMem) {
1857 res = bus_cur->firstPFMem; 1857 res = bus_cur->firstPFMem;
1858 while (res) { 1858 while (res) {
1859 debug_pci ("The range # is %d\n", res->rangeno); 1859 debug_pci("The range # is %d\n", res->rangeno);
1860 debug_pci ("The bus, devfnc is %d, %x\n", res->busno, res->devfunc); 1860 debug_pci("The bus, devfnc is %d, %x\n", res->busno, res->devfunc);
1861 debug_pci ("[%x - %x], len=%x\n", res->start, res->end, res->len); 1861 debug_pci("[%x - %x], len=%x\n", res->start, res->end, res->len);
1862 if (res->next) 1862 if (res->next)
1863 res = res->next; 1863 res = res->next;
1864 else if (res->nextRange) 1864 else if (res->nextRange)
@@ -1868,23 +1868,23 @@ void ibmphp_print_test (void)
1868 } 1868 }
1869 } 1869 }
1870 1870
1871 debug_pci ("PFMemFromMem...\n"); 1871 debug_pci("PFMemFromMem...\n");
1872 if (bus_cur->firstPFMemFromMem) { 1872 if (bus_cur->firstPFMemFromMem) {
1873 res = bus_cur->firstPFMemFromMem; 1873 res = bus_cur->firstPFMemFromMem;
1874 while (res) { 1874 while (res) {
1875 debug_pci ("The range # is %d\n", res->rangeno); 1875 debug_pci("The range # is %d\n", res->rangeno);
1876 debug_pci ("The bus, devfnc is %d, %x\n", res->busno, res->devfunc); 1876 debug_pci("The bus, devfnc is %d, %x\n", res->busno, res->devfunc);
1877 debug_pci ("[%x - %x], len=%x\n", res->start, res->end, res->len); 1877 debug_pci("[%x - %x], len=%x\n", res->start, res->end, res->len);
1878 res = res->next; 1878 res = res->next;
1879 } 1879 }
1880 } 1880 }
1881 } 1881 }
1882 debug_pci ("***********************END***********************\n"); 1882 debug_pci("***********************END***********************\n");
1883} 1883}
1884 1884
1885static int range_exists_already (struct range_node * range, struct bus_node * bus_cur, u8 type) 1885static int range_exists_already(struct range_node *range, struct bus_node *bus_cur, u8 type)
1886{ 1886{
1887 struct range_node * range_cur = NULL; 1887 struct range_node *range_cur = NULL;
1888 switch (type) { 1888 switch (type) {
1889 case IO: 1889 case IO:
1890 range_cur = bus_cur->rangeIO; 1890 range_cur = bus_cur->rangeIO;
@@ -1896,7 +1896,7 @@ static int range_exists_already (struct range_node * range, struct bus_node * bu
1896 range_cur = bus_cur->rangePFMem; 1896 range_cur = bus_cur->rangePFMem;
1897 break; 1897 break;
1898 default: 1898 default:
1899 err ("wrong type passed to find out if range already exists\n"); 1899 err("wrong type passed to find out if range already exists\n");
1900 return -ENODEV; 1900 return -ENODEV;
1901 } 1901 }
1902 1902
@@ -1923,7 +1923,7 @@ static int range_exists_already (struct range_node * range, struct bus_node * bu
1923 * behind them All these are TO DO. 1923 * behind them All these are TO DO.
1924 * Also need to add more error checkings... (from fnc returns etc) 1924 * Also need to add more error checkings... (from fnc returns etc)
1925 */ 1925 */
1926static int __init update_bridge_ranges (struct bus_node **bus) 1926static int __init update_bridge_ranges(struct bus_node **bus)
1927{ 1927{
1928 u8 sec_busno, device, function, hdr_type, start_io_address, end_io_address; 1928 u8 sec_busno, device, function, hdr_type, start_io_address, end_io_address;
1929 u16 vendor_id, upper_io_start, upper_io_end, start_mem_address, end_mem_address; 1929 u16 vendor_id, upper_io_start, upper_io_end, start_mem_address, end_mem_address;
@@ -1941,17 +1941,17 @@ static int __init update_bridge_ranges (struct bus_node **bus)
1941 return -ENODEV; 1941 return -ENODEV;
1942 ibmphp_pci_bus->number = bus_cur->busno; 1942 ibmphp_pci_bus->number = bus_cur->busno;
1943 1943
1944 debug ("inside %s\n", __func__); 1944 debug("inside %s\n", __func__);
1945 debug ("bus_cur->busno = %x\n", bus_cur->busno); 1945 debug("bus_cur->busno = %x\n", bus_cur->busno);
1946 1946
1947 for (device = 0; device < 32; device++) { 1947 for (device = 0; device < 32; device++) {
1948 for (function = 0x00; function < 0x08; function++) { 1948 for (function = 0x00; function < 0x08; function++) {
1949 devfn = PCI_DEVFN(device, function); 1949 devfn = PCI_DEVFN(device, function);
1950 pci_bus_read_config_word (ibmphp_pci_bus, devfn, PCI_VENDOR_ID, &vendor_id); 1950 pci_bus_read_config_word(ibmphp_pci_bus, devfn, PCI_VENDOR_ID, &vendor_id);
1951 1951
1952 if (vendor_id != PCI_VENDOR_ID_NOTVALID) { 1952 if (vendor_id != PCI_VENDOR_ID_NOTVALID) {
1953 /* found correct device!!! */ 1953 /* found correct device!!! */
1954 pci_bus_read_config_byte (ibmphp_pci_bus, devfn, PCI_HEADER_TYPE, &hdr_type); 1954 pci_bus_read_config_byte(ibmphp_pci_bus, devfn, PCI_HEADER_TYPE, &hdr_type);
1955 1955
1956 switch (hdr_type) { 1956 switch (hdr_type) {
1957 case PCI_HEADER_TYPE_NORMAL: 1957 case PCI_HEADER_TYPE_NORMAL:
@@ -1970,18 +1970,18 @@ static int __init update_bridge_ranges (struct bus_node **bus)
1970 temp++; 1970 temp++;
1971 } 1971 }
1972 */ 1972 */
1973 pci_bus_read_config_byte (ibmphp_pci_bus, devfn, PCI_SECONDARY_BUS, &sec_busno); 1973 pci_bus_read_config_byte(ibmphp_pci_bus, devfn, PCI_SECONDARY_BUS, &sec_busno);
1974 bus_sec = find_bus_wprev (sec_busno, NULL, 0); 1974 bus_sec = find_bus_wprev(sec_busno, NULL, 0);
1975 /* this bus structure doesn't exist yet, PPB was configured during previous loading of ibmphp */ 1975 /* this bus structure doesn't exist yet, PPB was configured during previous loading of ibmphp */
1976 if (!bus_sec) { 1976 if (!bus_sec) {
1977 bus_sec = alloc_error_bus (NULL, sec_busno, 1); 1977 bus_sec = alloc_error_bus(NULL, sec_busno, 1);
1978 /* the rest will be populated during NVRAM call */ 1978 /* the rest will be populated during NVRAM call */
1979 return 0; 1979 return 0;
1980 } 1980 }
1981 pci_bus_read_config_byte (ibmphp_pci_bus, devfn, PCI_IO_BASE, &start_io_address); 1981 pci_bus_read_config_byte(ibmphp_pci_bus, devfn, PCI_IO_BASE, &start_io_address);
1982 pci_bus_read_config_byte (ibmphp_pci_bus, devfn, PCI_IO_LIMIT, &end_io_address); 1982 pci_bus_read_config_byte(ibmphp_pci_bus, devfn, PCI_IO_LIMIT, &end_io_address);
1983 pci_bus_read_config_word (ibmphp_pci_bus, devfn, PCI_IO_BASE_UPPER16, &upper_io_start); 1983 pci_bus_read_config_word(ibmphp_pci_bus, devfn, PCI_IO_BASE_UPPER16, &upper_io_start);
1984 pci_bus_read_config_word (ibmphp_pci_bus, devfn, PCI_IO_LIMIT_UPPER16, &upper_io_end); 1984 pci_bus_read_config_word(ibmphp_pci_bus, devfn, PCI_IO_LIMIT_UPPER16, &upper_io_end);
1985 start_address = (start_io_address & PCI_IO_RANGE_MASK) << 8; 1985 start_address = (start_io_address & PCI_IO_RANGE_MASK) << 8;
1986 start_address |= (upper_io_start << 16); 1986 start_address |= (upper_io_start << 16);
1987 end_address = (end_io_address & PCI_IO_RANGE_MASK) << 8; 1987 end_address = (end_io_address & PCI_IO_RANGE_MASK) << 8;
@@ -1990,18 +1990,18 @@ static int __init update_bridge_ranges (struct bus_node **bus)
1990 if ((start_address) && (start_address <= end_address)) { 1990 if ((start_address) && (start_address <= end_address)) {
1991 range = kzalloc(sizeof(struct range_node), GFP_KERNEL); 1991 range = kzalloc(sizeof(struct range_node), GFP_KERNEL);
1992 if (!range) { 1992 if (!range) {
1993 err ("out of system memory\n"); 1993 err("out of system memory\n");
1994 return -ENOMEM; 1994 return -ENOMEM;
1995 } 1995 }
1996 range->start = start_address; 1996 range->start = start_address;
1997 range->end = end_address + 0xfff; 1997 range->end = end_address + 0xfff;
1998 1998
1999 if (bus_sec->noIORanges > 0) { 1999 if (bus_sec->noIORanges > 0) {
2000 if (!range_exists_already (range, bus_sec, IO)) { 2000 if (!range_exists_already(range, bus_sec, IO)) {
2001 add_bus_range (IO, range, bus_sec); 2001 add_bus_range(IO, range, bus_sec);
2002 ++bus_sec->noIORanges; 2002 ++bus_sec->noIORanges;
2003 } else { 2003 } else {
2004 kfree (range); 2004 kfree(range);
2005 range = NULL; 2005 range = NULL;
2006 } 2006 }
2007 } else { 2007 } else {
@@ -2010,13 +2010,13 @@ static int __init update_bridge_ranges (struct bus_node **bus)
2010 bus_sec->rangeIO = range; 2010 bus_sec->rangeIO = range;
2011 ++bus_sec->noIORanges; 2011 ++bus_sec->noIORanges;
2012 } 2012 }
2013 fix_resources (bus_sec); 2013 fix_resources(bus_sec);
2014 2014
2015 if (ibmphp_find_resource (bus_cur, start_address, &io, IO)) { 2015 if (ibmphp_find_resource(bus_cur, start_address, &io, IO)) {
2016 io = kzalloc(sizeof(struct resource_node), GFP_KERNEL); 2016 io = kzalloc(sizeof(struct resource_node), GFP_KERNEL);
2017 if (!io) { 2017 if (!io) {
2018 kfree (range); 2018 kfree(range);
2019 err ("out of system memory\n"); 2019 err("out of system memory\n");
2020 return -ENOMEM; 2020 return -ENOMEM;
2021 } 2021 }
2022 io->type = IO; 2022 io->type = IO;
@@ -2025,12 +2025,12 @@ static int __init update_bridge_ranges (struct bus_node **bus)
2025 io->start = start_address; 2025 io->start = start_address;
2026 io->end = end_address + 0xfff; 2026 io->end = end_address + 0xfff;
2027 io->len = io->end - io->start + 1; 2027 io->len = io->end - io->start + 1;
2028 ibmphp_add_resource (io); 2028 ibmphp_add_resource(io);
2029 } 2029 }
2030 } 2030 }
2031 2031
2032 pci_bus_read_config_word (ibmphp_pci_bus, devfn, PCI_MEMORY_BASE, &start_mem_address); 2032 pci_bus_read_config_word(ibmphp_pci_bus, devfn, PCI_MEMORY_BASE, &start_mem_address);
2033 pci_bus_read_config_word (ibmphp_pci_bus, devfn, PCI_MEMORY_LIMIT, &end_mem_address); 2033 pci_bus_read_config_word(ibmphp_pci_bus, devfn, PCI_MEMORY_LIMIT, &end_mem_address);
2034 2034
2035 start_address = 0x00000000 | (start_mem_address & PCI_MEMORY_RANGE_MASK) << 16; 2035 start_address = 0x00000000 | (start_mem_address & PCI_MEMORY_RANGE_MASK) << 16;
2036 end_address = 0x00000000 | (end_mem_address & PCI_MEMORY_RANGE_MASK) << 16; 2036 end_address = 0x00000000 | (end_mem_address & PCI_MEMORY_RANGE_MASK) << 16;
@@ -2039,18 +2039,18 @@ static int __init update_bridge_ranges (struct bus_node **bus)
2039 2039
2040 range = kzalloc(sizeof(struct range_node), GFP_KERNEL); 2040 range = kzalloc(sizeof(struct range_node), GFP_KERNEL);
2041 if (!range) { 2041 if (!range) {
2042 err ("out of system memory\n"); 2042 err("out of system memory\n");
2043 return -ENOMEM; 2043 return -ENOMEM;
2044 } 2044 }
2045 range->start = start_address; 2045 range->start = start_address;
2046 range->end = end_address + 0xfffff; 2046 range->end = end_address + 0xfffff;
2047 2047
2048 if (bus_sec->noMemRanges > 0) { 2048 if (bus_sec->noMemRanges > 0) {
2049 if (!range_exists_already (range, bus_sec, MEM)) { 2049 if (!range_exists_already(range, bus_sec, MEM)) {
2050 add_bus_range (MEM, range, bus_sec); 2050 add_bus_range(MEM, range, bus_sec);
2051 ++bus_sec->noMemRanges; 2051 ++bus_sec->noMemRanges;
2052 } else { 2052 } else {
2053 kfree (range); 2053 kfree(range);
2054 range = NULL; 2054 range = NULL;
2055 } 2055 }
2056 } else { 2056 } else {
@@ -2060,13 +2060,13 @@ static int __init update_bridge_ranges (struct bus_node **bus)
2060 ++bus_sec->noMemRanges; 2060 ++bus_sec->noMemRanges;
2061 } 2061 }
2062 2062
2063 fix_resources (bus_sec); 2063 fix_resources(bus_sec);
2064 2064
2065 if (ibmphp_find_resource (bus_cur, start_address, &mem, MEM)) { 2065 if (ibmphp_find_resource(bus_cur, start_address, &mem, MEM)) {
2066 mem = kzalloc(sizeof(struct resource_node), GFP_KERNEL); 2066 mem = kzalloc(sizeof(struct resource_node), GFP_KERNEL);
2067 if (!mem) { 2067 if (!mem) {
2068 kfree (range); 2068 kfree(range);
2069 err ("out of system memory\n"); 2069 err("out of system memory\n");
2070 return -ENOMEM; 2070 return -ENOMEM;
2071 } 2071 }
2072 mem->type = MEM; 2072 mem->type = MEM;
@@ -2075,13 +2075,13 @@ static int __init update_bridge_ranges (struct bus_node **bus)
2075 mem->start = start_address; 2075 mem->start = start_address;
2076 mem->end = end_address + 0xfffff; 2076 mem->end = end_address + 0xfffff;
2077 mem->len = mem->end - mem->start + 1; 2077 mem->len = mem->end - mem->start + 1;
2078 ibmphp_add_resource (mem); 2078 ibmphp_add_resource(mem);
2079 } 2079 }
2080 } 2080 }
2081 pci_bus_read_config_word (ibmphp_pci_bus, devfn, PCI_PREF_MEMORY_BASE, &start_mem_address); 2081 pci_bus_read_config_word(ibmphp_pci_bus, devfn, PCI_PREF_MEMORY_BASE, &start_mem_address);
2082 pci_bus_read_config_word (ibmphp_pci_bus, devfn, PCI_PREF_MEMORY_LIMIT, &end_mem_address); 2082 pci_bus_read_config_word(ibmphp_pci_bus, devfn, PCI_PREF_MEMORY_LIMIT, &end_mem_address);
2083 pci_bus_read_config_dword (ibmphp_pci_bus, devfn, PCI_PREF_BASE_UPPER32, &upper_start); 2083 pci_bus_read_config_dword(ibmphp_pci_bus, devfn, PCI_PREF_BASE_UPPER32, &upper_start);
2084 pci_bus_read_config_dword (ibmphp_pci_bus, devfn, PCI_PREF_LIMIT_UPPER32, &upper_end); 2084 pci_bus_read_config_dword(ibmphp_pci_bus, devfn, PCI_PREF_LIMIT_UPPER32, &upper_end);
2085 start_address = 0x00000000 | (start_mem_address & PCI_MEMORY_RANGE_MASK) << 16; 2085 start_address = 0x00000000 | (start_mem_address & PCI_MEMORY_RANGE_MASK) << 16;
2086 end_address = 0x00000000 | (end_mem_address & PCI_MEMORY_RANGE_MASK) << 16; 2086 end_address = 0x00000000 | (end_mem_address & PCI_MEMORY_RANGE_MASK) << 16;
2087#if BITS_PER_LONG == 64 2087#if BITS_PER_LONG == 64
@@ -2093,18 +2093,18 @@ static int __init update_bridge_ranges (struct bus_node **bus)
2093 2093
2094 range = kzalloc(sizeof(struct range_node), GFP_KERNEL); 2094 range = kzalloc(sizeof(struct range_node), GFP_KERNEL);
2095 if (!range) { 2095 if (!range) {
2096 err ("out of system memory\n"); 2096 err("out of system memory\n");
2097 return -ENOMEM; 2097 return -ENOMEM;
2098 } 2098 }
2099 range->start = start_address; 2099 range->start = start_address;
2100 range->end = end_address + 0xfffff; 2100 range->end = end_address + 0xfffff;
2101 2101
2102 if (bus_sec->noPFMemRanges > 0) { 2102 if (bus_sec->noPFMemRanges > 0) {
2103 if (!range_exists_already (range, bus_sec, PFMEM)) { 2103 if (!range_exists_already(range, bus_sec, PFMEM)) {
2104 add_bus_range (PFMEM, range, bus_sec); 2104 add_bus_range(PFMEM, range, bus_sec);
2105 ++bus_sec->noPFMemRanges; 2105 ++bus_sec->noPFMemRanges;
2106 } else { 2106 } else {
2107 kfree (range); 2107 kfree(range);
2108 range = NULL; 2108 range = NULL;
2109 } 2109 }
2110 } else { 2110 } else {
@@ -2114,12 +2114,12 @@ static int __init update_bridge_ranges (struct bus_node **bus)
2114 ++bus_sec->noPFMemRanges; 2114 ++bus_sec->noPFMemRanges;
2115 } 2115 }
2116 2116
2117 fix_resources (bus_sec); 2117 fix_resources(bus_sec);
2118 if (ibmphp_find_resource (bus_cur, start_address, &pfmem, PFMEM)) { 2118 if (ibmphp_find_resource(bus_cur, start_address, &pfmem, PFMEM)) {
2119 pfmem = kzalloc(sizeof(struct resource_node), GFP_KERNEL); 2119 pfmem = kzalloc(sizeof(struct resource_node), GFP_KERNEL);
2120 if (!pfmem) { 2120 if (!pfmem) {
2121 kfree (range); 2121 kfree(range);
2122 err ("out of system memory\n"); 2122 err("out of system memory\n");
2123 return -ENOMEM; 2123 return -ENOMEM;
2124 } 2124 }
2125 pfmem->type = PFMEM; 2125 pfmem->type = PFMEM;
@@ -2130,7 +2130,7 @@ static int __init update_bridge_ranges (struct bus_node **bus)
2130 pfmem->len = pfmem->end - pfmem->start + 1; 2130 pfmem->len = pfmem->end - pfmem->start + 1;
2131 pfmem->fromMem = 0; 2131 pfmem->fromMem = 0;
2132 2132
2133 ibmphp_add_resource (pfmem); 2133 ibmphp_add_resource(pfmem);
2134 } 2134 }
2135 } 2135 }
2136 break; 2136 break;
diff --git a/drivers/pci/hotplug/pci_hotplug_core.c b/drivers/pci/hotplug/pci_hotplug_core.c
index fcd5e73c5b48..9acd1997c6fe 100644
--- a/drivers/pci/hotplug/pci_hotplug_core.c
+++ b/drivers/pci/hotplug/pci_hotplug_core.c
@@ -45,10 +45,10 @@
45 45
46#define MY_NAME "pci_hotplug" 46#define MY_NAME "pci_hotplug"
47 47
48#define dbg(fmt, arg...) do { if (debug) printk(KERN_DEBUG "%s: %s: " fmt , MY_NAME , __func__ , ## arg); } while (0) 48#define dbg(fmt, arg...) do { if (debug) printk(KERN_DEBUG "%s: %s: " fmt, MY_NAME, __func__, ## arg); } while (0)
49#define err(format, arg...) printk(KERN_ERR "%s: " format , MY_NAME , ## arg) 49#define err(format, arg...) printk(KERN_ERR "%s: " format, MY_NAME, ## arg)
50#define info(format, arg...) printk(KERN_INFO "%s: " format , MY_NAME , ## arg) 50#define info(format, arg...) printk(KERN_INFO "%s: " format, MY_NAME, ## arg)
51#define warn(format, arg...) printk(KERN_WARNING "%s: " format , MY_NAME , ## arg) 51#define warn(format, arg...) printk(KERN_WARNING "%s: " format, MY_NAME, ## arg)
52 52
53 53
54/* local variables */ 54/* local variables */
@@ -226,7 +226,7 @@ static ssize_t test_write_file(struct pci_slot *pci_slot, const char *buf,
226 u32 test; 226 u32 test;
227 int retval = 0; 227 int retval = 0;
228 228
229 ltest = simple_strtoul (buf, NULL, 10); 229 ltest = simple_strtoul(buf, NULL, 10);
230 test = (u32)(ltest & 0xffffffff); 230 test = (u32)(ltest & 0xffffffff);
231 dbg("test = %d\n", test); 231 dbg("test = %d\n", test);
232 232
diff --git a/drivers/pci/hotplug/pciehp.h b/drivers/pci/hotplug/pciehp.h
index 62d6fe6c3714..e764918641ae 100644
--- a/drivers/pci/hotplug/pciehp.h
+++ b/drivers/pci/hotplug/pciehp.h
@@ -47,14 +47,14 @@ extern bool pciehp_debug;
47#define dbg(format, arg...) \ 47#define dbg(format, arg...) \
48do { \ 48do { \
49 if (pciehp_debug) \ 49 if (pciehp_debug) \
50 printk(KERN_DEBUG "%s: " format, MY_NAME , ## arg); \ 50 printk(KERN_DEBUG "%s: " format, MY_NAME, ## arg); \
51} while (0) 51} while (0)
52#define err(format, arg...) \ 52#define err(format, arg...) \
53 printk(KERN_ERR "%s: " format, MY_NAME , ## arg) 53 printk(KERN_ERR "%s: " format, MY_NAME, ## arg)
54#define info(format, arg...) \ 54#define info(format, arg...) \
55 printk(KERN_INFO "%s: " format, MY_NAME , ## arg) 55 printk(KERN_INFO "%s: " format, MY_NAME, ## arg)
56#define warn(format, arg...) \ 56#define warn(format, arg...) \
57 printk(KERN_WARNING "%s: " format, MY_NAME , ## arg) 57 printk(KERN_WARNING "%s: " format, MY_NAME, ## arg)
58 58
59#define ctrl_dbg(ctrl, format, arg...) \ 59#define ctrl_dbg(ctrl, format, arg...) \
60 do { \ 60 do { \
diff --git a/drivers/pci/hotplug/pciehp_core.c b/drivers/pci/hotplug/pciehp_core.c
index 612b21a14df5..ac531e674a05 100644
--- a/drivers/pci/hotplug/pciehp_core.c
+++ b/drivers/pci/hotplug/pciehp_core.c
@@ -62,14 +62,14 @@ MODULE_PARM_DESC(pciehp_force, "Force pciehp, even if OSHP is missing");
62 62
63#define PCIE_MODULE_NAME "pciehp" 63#define PCIE_MODULE_NAME "pciehp"
64 64
65static int set_attention_status (struct hotplug_slot *slot, u8 value); 65static int set_attention_status(struct hotplug_slot *slot, u8 value);
66static int enable_slot (struct hotplug_slot *slot); 66static int enable_slot(struct hotplug_slot *slot);
67static int disable_slot (struct hotplug_slot *slot); 67static int disable_slot(struct hotplug_slot *slot);
68static int get_power_status (struct hotplug_slot *slot, u8 *value); 68static int get_power_status(struct hotplug_slot *slot, u8 *value);
69static int get_attention_status (struct hotplug_slot *slot, u8 *value); 69static int get_attention_status(struct hotplug_slot *slot, u8 *value);
70static int get_latch_status (struct hotplug_slot *slot, u8 *value); 70static int get_latch_status(struct hotplug_slot *slot, u8 *value);
71static int get_adapter_status (struct hotplug_slot *slot, u8 *value); 71static int get_adapter_status(struct hotplug_slot *slot, u8 *value);
72static int reset_slot (struct hotplug_slot *slot, int probe); 72static int reset_slot(struct hotplug_slot *slot, int probe);
73 73
74/** 74/**
75 * release_slot - free up the memory used by a slot 75 * release_slot - free up the memory used by a slot
diff --git a/drivers/pci/hotplug/pcihp_skeleton.c b/drivers/pci/hotplug/pcihp_skeleton.c
index 9d4a95e66bda..172ed89200cd 100644
--- a/drivers/pci/hotplug/pcihp_skeleton.c
+++ b/drivers/pci/hotplug/pcihp_skeleton.c
@@ -52,11 +52,11 @@ static LIST_HEAD(slot_list);
52 do { \ 52 do { \
53 if (debug) \ 53 if (debug) \
54 printk(KERN_DEBUG "%s: " format "\n", \ 54 printk(KERN_DEBUG "%s: " format "\n", \
55 MY_NAME , ## arg); \ 55 MY_NAME, ## arg); \
56 } while (0) 56 } while (0)
57#define err(format, arg...) printk(KERN_ERR "%s: " format "\n", MY_NAME , ## arg) 57#define err(format, arg...) printk(KERN_ERR "%s: " format "\n", MY_NAME, ## arg)
58#define info(format, arg...) printk(KERN_INFO "%s: " format "\n", MY_NAME , ## arg) 58#define info(format, arg...) printk(KERN_INFO "%s: " format "\n", MY_NAME, ## arg)
59#define warn(format, arg...) printk(KERN_WARNING "%s: " format "\n", MY_NAME , ## arg) 59#define warn(format, arg...) printk(KERN_WARNING "%s: " format "\n", MY_NAME, ## arg)
60 60
61/* local variables */ 61/* local variables */
62static bool debug; 62static bool debug;
@@ -72,14 +72,14 @@ MODULE_LICENSE("GPL");
72module_param(debug, bool, 0644); 72module_param(debug, bool, 0644);
73MODULE_PARM_DESC(debug, "Debugging mode enabled or not"); 73MODULE_PARM_DESC(debug, "Debugging mode enabled or not");
74 74
75static int enable_slot (struct hotplug_slot *slot); 75static int enable_slot(struct hotplug_slot *slot);
76static int disable_slot (struct hotplug_slot *slot); 76static int disable_slot(struct hotplug_slot *slot);
77static int set_attention_status (struct hotplug_slot *slot, u8 value); 77static int set_attention_status(struct hotplug_slot *slot, u8 value);
78static int hardware_test (struct hotplug_slot *slot, u32 value); 78static int hardware_test(struct hotplug_slot *slot, u32 value);
79static int get_power_status (struct hotplug_slot *slot, u8 *value); 79static int get_power_status(struct hotplug_slot *slot, u8 *value);
80static int get_attention_status (struct hotplug_slot *slot, u8 *value); 80static int get_attention_status(struct hotplug_slot *slot, u8 *value);
81static int get_latch_status (struct hotplug_slot *slot, u8 *value); 81static int get_latch_status(struct hotplug_slot *slot, u8 *value);
82static int get_adapter_status (struct hotplug_slot *slot, u8 *value); 82static int get_adapter_status(struct hotplug_slot *slot, u8 *value);
83 83
84static struct hotplug_slot_ops skel_hotplug_slot_ops = { 84static struct hotplug_slot_ops skel_hotplug_slot_ops = {
85 .enable_slot = enable_slot, 85 .enable_slot = enable_slot,
diff --git a/drivers/pci/hotplug/rpaphp.h b/drivers/pci/hotplug/rpaphp.h
index b2593e876a09..7db024e68fe6 100644
--- a/drivers/pci/hotplug/rpaphp.h
+++ b/drivers/pci/hotplug/rpaphp.h
@@ -51,11 +51,11 @@ extern bool rpaphp_debug;
51 do { \ 51 do { \
52 if (rpaphp_debug) \ 52 if (rpaphp_debug) \
53 printk(KERN_DEBUG "%s: " format, \ 53 printk(KERN_DEBUG "%s: " format, \
54 MY_NAME , ## arg); \ 54 MY_NAME, ## arg); \
55 } while (0) 55 } while (0)
56#define err(format, arg...) printk(KERN_ERR "%s: " format, MY_NAME , ## arg) 56#define err(format, arg...) printk(KERN_ERR "%s: " format, MY_NAME, ## arg)
57#define info(format, arg...) printk(KERN_INFO "%s: " format, MY_NAME , ## arg) 57#define info(format, arg...) printk(KERN_INFO "%s: " format, MY_NAME, ## arg)
58#define warn(format, arg...) printk(KERN_WARNING "%s: " format, MY_NAME , ## arg) 58#define warn(format, arg...) printk(KERN_WARNING "%s: " format, MY_NAME, ## arg)
59 59
60/* slot states */ 60/* slot states */
61 61
diff --git a/drivers/pci/hotplug/rpaphp_core.c b/drivers/pci/hotplug/rpaphp_core.c
index 5a11232cf766..611f6056221a 100644
--- a/drivers/pci/hotplug/rpaphp_core.c
+++ b/drivers/pci/hotplug/rpaphp_core.c
@@ -94,7 +94,7 @@ static int get_power_status(struct hotplug_slot *hotplug_slot, u8 *value)
94 int retval, level; 94 int retval, level;
95 struct slot *slot = (struct slot *)hotplug_slot->private; 95 struct slot *slot = (struct slot *)hotplug_slot->private;
96 96
97 retval = rtas_get_power_level (slot->power_domain, &level); 97 retval = rtas_get_power_level(slot->power_domain, &level);
98 if (!retval) 98 if (!retval)
99 *value = level; 99 *value = level;
100 return retval; 100 return retval;
diff --git a/drivers/pci/hotplug/rpaphp_pci.c b/drivers/pci/hotplug/rpaphp_pci.c
index 9243f3e7a1c9..7836d6913e67 100644
--- a/drivers/pci/hotplug/rpaphp_pci.c
+++ b/drivers/pci/hotplug/rpaphp_pci.c
@@ -126,7 +126,7 @@ int rpaphp_enable_slot(struct slot *slot)
126 if (rpaphp_debug) { 126 if (rpaphp_debug) {
127 struct pci_dev *dev; 127 struct pci_dev *dev;
128 dbg("%s: pci_devs of slot[%s]\n", __func__, slot->dn->full_name); 128 dbg("%s: pci_devs of slot[%s]\n", __func__, slot->dn->full_name);
129 list_for_each_entry (dev, &bus->devices, bus_list) 129 list_for_each_entry(dev, &bus->devices, bus_list)
130 dbg("\t%s\n", pci_name(dev)); 130 dbg("\t%s\n", pci_name(dev));
131 } 131 }
132 } 132 }
diff --git a/drivers/pci/hotplug/rpaphp_slot.c b/drivers/pci/hotplug/rpaphp_slot.c
index a6082cc263f7..6937c725b00b 100644
--- a/drivers/pci/hotplug/rpaphp_slot.c
+++ b/drivers/pci/hotplug/rpaphp_slot.c
@@ -48,7 +48,7 @@ void dealloc_slot_struct(struct slot *slot)
48} 48}
49 49
50struct slot *alloc_slot_struct(struct device_node *dn, 50struct slot *alloc_slot_struct(struct device_node *dn,
51 int drc_index, char *drc_name, int power_domain) 51 int drc_index, char *drc_name, int power_domain)
52{ 52{
53 struct slot *slot; 53 struct slot *slot;
54 54
diff --git a/drivers/pci/hotplug/sgi_hotplug.c b/drivers/pci/hotplug/sgi_hotplug.c
index c32fb786d48e..339bce0403dd 100644
--- a/drivers/pci/hotplug/sgi_hotplug.c
+++ b/drivers/pci/hotplug/sgi_hotplug.c
@@ -99,7 +99,7 @@ static ssize_t path_show(struct pci_slot *pci_slot, char *buf)
99 if (!slot) 99 if (!slot)
100 return retval; 100 return retval;
101 101
102 retval = sprintf (buf, "%s\n", slot->physical_path); 102 retval = sprintf(buf, "%s\n", slot->physical_path);
103 return retval; 103 return retval;
104} 104}
105 105
@@ -313,7 +313,7 @@ static int sn_slot_disable(struct hotplug_slot *bss_hotplug_slot,
313 } 313 }
314 314
315 if ((action == PCI_REQ_SLOT_DISABLE) && rc) { 315 if ((action == PCI_REQ_SLOT_DISABLE) && rc) {
316 dev_dbg(&slot->pci_bus->self->dev,"remove failed rc = %d\n", rc); 316 dev_dbg(&slot->pci_bus->self->dev, "remove failed rc = %d\n", rc);
317 } 317 }
318 318
319 return rc; 319 return rc;
@@ -488,7 +488,7 @@ static int disable_slot(struct hotplug_slot *bss_hotplug_slot)
488 488
489 /* free the ACPI resources for the slot */ 489 /* free the ACPI resources for the slot */
490 if (SN_ACPI_BASE_SUPPORT() && 490 if (SN_ACPI_BASE_SUPPORT() &&
491 PCI_CONTROLLER(slot->pci_bus)->companion) { 491 PCI_CONTROLLER(slot->pci_bus)->companion) {
492 unsigned long long adr; 492 unsigned long long adr;
493 struct acpi_device *device; 493 struct acpi_device *device;
494 acpi_handle phandle; 494 acpi_handle phandle;
diff --git a/drivers/pci/hotplug/shpchp.h b/drivers/pci/hotplug/shpchp.h
index 5897d516427b..4da8fc601467 100644
--- a/drivers/pci/hotplug/shpchp.h
+++ b/drivers/pci/hotplug/shpchp.h
@@ -50,14 +50,14 @@ extern bool shpchp_debug;
50#define dbg(format, arg...) \ 50#define dbg(format, arg...) \
51do { \ 51do { \
52 if (shpchp_debug) \ 52 if (shpchp_debug) \
53 printk(KERN_DEBUG "%s: " format, MY_NAME , ## arg); \ 53 printk(KERN_DEBUG "%s: " format, MY_NAME, ## arg); \
54} while (0) 54} while (0)
55#define err(format, arg...) \ 55#define err(format, arg...) \
56 printk(KERN_ERR "%s: " format, MY_NAME , ## arg) 56 printk(KERN_ERR "%s: " format, MY_NAME, ## arg)
57#define info(format, arg...) \ 57#define info(format, arg...) \
58 printk(KERN_INFO "%s: " format, MY_NAME , ## arg) 58 printk(KERN_INFO "%s: " format, MY_NAME, ## arg)
59#define warn(format, arg...) \ 59#define warn(format, arg...) \
60 printk(KERN_WARNING "%s: " format, MY_NAME , ## arg) 60 printk(KERN_WARNING "%s: " format, MY_NAME, ## arg)
61 61
62#define ctrl_dbg(ctrl, format, arg...) \ 62#define ctrl_dbg(ctrl, format, arg...) \
63 do { \ 63 do { \
@@ -84,7 +84,7 @@ struct slot {
84 u8 presence_save; 84 u8 presence_save;
85 u8 pwr_save; 85 u8 pwr_save;
86 struct controller *ctrl; 86 struct controller *ctrl;
87 struct hpc_ops *hpc_ops; 87 const struct hpc_ops *hpc_ops;
88 struct hotplug_slot *hotplug_slot; 88 struct hotplug_slot *hotplug_slot;
89 struct list_head slot_list; 89 struct list_head slot_list;
90 struct delayed_work work; /* work for button event */ 90 struct delayed_work work; /* work for button event */
@@ -106,7 +106,7 @@ struct controller {
106 int slot_num_inc; /* 1 or -1 */ 106 int slot_num_inc; /* 1 or -1 */
107 struct pci_dev *pci_dev; 107 struct pci_dev *pci_dev;
108 struct list_head slot_list; 108 struct list_head slot_list;
109 struct hpc_ops *hpc_ops; 109 const struct hpc_ops *hpc_ops;
110 wait_queue_head_t queue; /* sleep & wake process */ 110 wait_queue_head_t queue; /* sleep & wake process */
111 u8 slot_device_offset; 111 u8 slot_device_offset;
112 u32 pcix_misc2_reg; /* for amd pogo errata */ 112 u32 pcix_misc2_reg; /* for amd pogo errata */
@@ -295,7 +295,7 @@ static inline void amd_pogo_errata_restore_misc_reg(struct slot *p_slot)
295 pci_write_config_dword(p_slot->ctrl->pci_dev, PCIX_MEM_BASE_LIMIT_OFFSET, rse_set); 295 pci_write_config_dword(p_slot->ctrl->pci_dev, PCIX_MEM_BASE_LIMIT_OFFSET, rse_set);
296 } 296 }
297 /* restore MiscII register */ 297 /* restore MiscII register */
298 pci_read_config_dword(p_slot->ctrl->pci_dev, PCIX_MISCII_OFFSET, &pcix_misc2_temp ); 298 pci_read_config_dword(p_slot->ctrl->pci_dev, PCIX_MISCII_OFFSET, &pcix_misc2_temp);
299 299
300 if (p_slot->ctrl->pcix_misc2_reg & SERRFATALENABLE_MASK) 300 if (p_slot->ctrl->pcix_misc2_reg & SERRFATALENABLE_MASK)
301 pcix_misc2_temp |= SERRFATALENABLE_MASK; 301 pcix_misc2_temp |= SERRFATALENABLE_MASK;
diff --git a/drivers/pci/hotplug/shpchp_core.c b/drivers/pci/hotplug/shpchp_core.c
index 7c854b6847d1..3454dc7385f1 100644
--- a/drivers/pci/hotplug/shpchp_core.c
+++ b/drivers/pci/hotplug/shpchp_core.c
@@ -57,13 +57,13 @@ MODULE_PARM_DESC(shpchp_poll_time, "Polling mechanism frequency, in seconds");
57 57
58#define SHPC_MODULE_NAME "shpchp" 58#define SHPC_MODULE_NAME "shpchp"
59 59
60static int set_attention_status (struct hotplug_slot *slot, u8 value); 60static int set_attention_status(struct hotplug_slot *slot, u8 value);
61static int enable_slot (struct hotplug_slot *slot); 61static int enable_slot(struct hotplug_slot *slot);
62static int disable_slot (struct hotplug_slot *slot); 62static int disable_slot(struct hotplug_slot *slot);
63static int get_power_status (struct hotplug_slot *slot, u8 *value); 63static int get_power_status(struct hotplug_slot *slot, u8 *value);
64static int get_attention_status (struct hotplug_slot *slot, u8 *value); 64static int get_attention_status(struct hotplug_slot *slot, u8 *value);
65static int get_latch_status (struct hotplug_slot *slot, u8 *value); 65static int get_latch_status(struct hotplug_slot *slot, u8 *value);
66static int get_adapter_status (struct hotplug_slot *slot, u8 *value); 66static int get_adapter_status(struct hotplug_slot *slot, u8 *value);
67 67
68static struct hotplug_slot_ops shpchp_hotplug_slot_ops = { 68static struct hotplug_slot_ops shpchp_hotplug_slot_ops = {
69 .set_attention_status = set_attention_status, 69 .set_attention_status = set_attention_status,
@@ -191,7 +191,7 @@ void cleanup_slots(struct controller *ctrl)
191/* 191/*
192 * set_attention_status - Turns the Amber LED for a slot on, off or blink 192 * set_attention_status - Turns the Amber LED for a slot on, off or blink
193 */ 193 */
194static int set_attention_status (struct hotplug_slot *hotplug_slot, u8 status) 194static int set_attention_status(struct hotplug_slot *hotplug_slot, u8 status)
195{ 195{
196 struct slot *slot = get_slot(hotplug_slot); 196 struct slot *slot = get_slot(hotplug_slot);
197 197
@@ -204,7 +204,7 @@ static int set_attention_status (struct hotplug_slot *hotplug_slot, u8 status)
204 return 0; 204 return 0;
205} 205}
206 206
207static int enable_slot (struct hotplug_slot *hotplug_slot) 207static int enable_slot(struct hotplug_slot *hotplug_slot)
208{ 208{
209 struct slot *slot = get_slot(hotplug_slot); 209 struct slot *slot = get_slot(hotplug_slot);
210 210
@@ -214,7 +214,7 @@ static int enable_slot (struct hotplug_slot *hotplug_slot)
214 return shpchp_sysfs_enable_slot(slot); 214 return shpchp_sysfs_enable_slot(slot);
215} 215}
216 216
217static int disable_slot (struct hotplug_slot *hotplug_slot) 217static int disable_slot(struct hotplug_slot *hotplug_slot)
218{ 218{
219 struct slot *slot = get_slot(hotplug_slot); 219 struct slot *slot = get_slot(hotplug_slot);
220 220
@@ -224,7 +224,7 @@ static int disable_slot (struct hotplug_slot *hotplug_slot)
224 return shpchp_sysfs_disable_slot(slot); 224 return shpchp_sysfs_disable_slot(slot);
225} 225}
226 226
227static int get_power_status (struct hotplug_slot *hotplug_slot, u8 *value) 227static int get_power_status(struct hotplug_slot *hotplug_slot, u8 *value)
228{ 228{
229 struct slot *slot = get_slot(hotplug_slot); 229 struct slot *slot = get_slot(hotplug_slot);
230 int retval; 230 int retval;
@@ -239,7 +239,7 @@ static int get_power_status (struct hotplug_slot *hotplug_slot, u8 *value)
239 return 0; 239 return 0;
240} 240}
241 241
242static int get_attention_status (struct hotplug_slot *hotplug_slot, u8 *value) 242static int get_attention_status(struct hotplug_slot *hotplug_slot, u8 *value)
243{ 243{
244 struct slot *slot = get_slot(hotplug_slot); 244 struct slot *slot = get_slot(hotplug_slot);
245 int retval; 245 int retval;
@@ -254,7 +254,7 @@ static int get_attention_status (struct hotplug_slot *hotplug_slot, u8 *value)
254 return 0; 254 return 0;
255} 255}
256 256
257static int get_latch_status (struct hotplug_slot *hotplug_slot, u8 *value) 257static int get_latch_status(struct hotplug_slot *hotplug_slot, u8 *value)
258{ 258{
259 struct slot *slot = get_slot(hotplug_slot); 259 struct slot *slot = get_slot(hotplug_slot);
260 int retval; 260 int retval;
@@ -269,7 +269,7 @@ static int get_latch_status (struct hotplug_slot *hotplug_slot, u8 *value)
269 return 0; 269 return 0;
270} 270}
271 271
272static int get_adapter_status (struct hotplug_slot *hotplug_slot, u8 *value) 272static int get_adapter_status(struct hotplug_slot *hotplug_slot, u8 *value)
273{ 273{
274 struct slot *slot = get_slot(hotplug_slot); 274 struct slot *slot = get_slot(hotplug_slot);
275 int retval; 275 int retval;
diff --git a/drivers/pci/hotplug/shpchp_hpc.c b/drivers/pci/hotplug/shpchp_hpc.c
index 7d223e9080ef..de0ea474fb73 100644
--- a/drivers/pci/hotplug/shpchp_hpc.c
+++ b/drivers/pci/hotplug/shpchp_hpc.c
@@ -542,7 +542,7 @@ static int hpc_set_attention_status(struct slot *slot, u8 value)
542 u8 slot_cmd = 0; 542 u8 slot_cmd = 0;
543 543
544 switch (value) { 544 switch (value) {
545 case 0 : 545 case 0:
546 slot_cmd = SET_ATTN_OFF; /* OFF */ 546 slot_cmd = SET_ATTN_OFF; /* OFF */
547 break; 547 break;
548 case 1: 548 case 1:
@@ -910,7 +910,7 @@ static int shpc_get_max_bus_speed(struct controller *ctrl)
910 return retval; 910 return retval;
911} 911}
912 912
913static struct hpc_ops shpchp_hpc_ops = { 913static const struct hpc_ops shpchp_hpc_ops = {
914 .power_on_slot = hpc_power_on_slot, 914 .power_on_slot = hpc_power_on_slot,
915 .slot_enable = hpc_slot_enable, 915 .slot_enable = hpc_slot_enable,
916 .slot_disable = hpc_slot_disable, 916 .slot_disable = hpc_slot_disable,
diff --git a/drivers/pci/hotplug/shpchp_sysfs.c b/drivers/pci/hotplug/shpchp_sysfs.c
index 52875b360463..7efb56a28c9f 100644
--- a/drivers/pci/hotplug/shpchp_sysfs.c
+++ b/drivers/pci/hotplug/shpchp_sysfs.c
@@ -35,7 +35,7 @@
35 35
36/* A few routines that create sysfs entries for the hot plug controller */ 36/* A few routines that create sysfs entries for the hot plug controller */
37 37
38static ssize_t show_ctrl (struct device *dev, struct device_attribute *attr, char *buf) 38static ssize_t show_ctrl(struct device *dev, struct device_attribute *attr, char *buf)
39{ 39{
40 struct pci_dev *pdev; 40 struct pci_dev *pdev;
41 char *out = buf; 41 char *out = buf;
@@ -43,7 +43,7 @@ static ssize_t show_ctrl (struct device *dev, struct device_attribute *attr, cha
43 struct resource *res; 43 struct resource *res;
44 struct pci_bus *bus; 44 struct pci_bus *bus;
45 45
46 pdev = container_of (dev, struct pci_dev, dev); 46 pdev = to_pci_dev(dev);
47 bus = pdev->subordinate; 47 bus = pdev->subordinate;
48 48
49 out += sprintf(buf, "Free resources: memory\n"); 49 out += sprintf(buf, "Free resources: memory\n");
@@ -83,11 +83,11 @@ static ssize_t show_ctrl (struct device *dev, struct device_attribute *attr, cha
83 83
84 return out - buf; 84 return out - buf;
85} 85}
86static DEVICE_ATTR (ctrl, S_IRUGO, show_ctrl, NULL); 86static DEVICE_ATTR(ctrl, S_IRUGO, show_ctrl, NULL);
87 87
88int shpchp_create_ctrl_files (struct controller *ctrl) 88int shpchp_create_ctrl_files(struct controller *ctrl)
89{ 89{
90 return device_create_file (&ctrl->pci_dev->dev, &dev_attr_ctrl); 90 return device_create_file(&ctrl->pci_dev->dev, &dev_attr_ctrl);
91} 91}
92 92
93void shpchp_remove_ctrl_files(struct controller *ctrl) 93void shpchp_remove_ctrl_files(struct controller *ctrl)
diff --git a/drivers/pci/pci-label.c b/drivers/pci/pci-label.c
index 024b5c179348..0ae74d96ed85 100644
--- a/drivers/pci/pci-label.c
+++ b/drivers/pci/pci-label.c
@@ -77,7 +77,7 @@ static umode_t smbios_instance_string_exist(struct kobject *kobj,
77 struct device *dev; 77 struct device *dev;
78 struct pci_dev *pdev; 78 struct pci_dev *pdev;
79 79
80 dev = container_of(kobj, struct device, kobj); 80 dev = kobj_to_dev(kobj);
81 pdev = to_pci_dev(dev); 81 pdev = to_pci_dev(dev);
82 82
83 return find_smbios_instance_string(pdev, NULL, SMBIOS_ATTR_NONE) ? 83 return find_smbios_instance_string(pdev, NULL, SMBIOS_ATTR_NONE) ?
@@ -221,7 +221,7 @@ static umode_t acpi_index_string_exist(struct kobject *kobj,
221{ 221{
222 struct device *dev; 222 struct device *dev;
223 223
224 dev = container_of(kobj, struct device, kobj); 224 dev = kobj_to_dev(kobj);
225 225
226 if (device_has_dsm(dev)) 226 if (device_has_dsm(dev))
227 return S_IRUGO; 227 return S_IRUGO;
diff --git a/drivers/pci/pci-sysfs.c b/drivers/pci/pci-sysfs.c
index 9cd27b703dd6..4ba61db43a6b 100644
--- a/drivers/pci/pci-sysfs.c
+++ b/drivers/pci/pci-sysfs.c
@@ -627,8 +627,7 @@ static ssize_t pci_read_config(struct file *filp, struct kobject *kobj,
627 struct bin_attribute *bin_attr, char *buf, 627 struct bin_attribute *bin_attr, char *buf,
628 loff_t off, size_t count) 628 loff_t off, size_t count)
629{ 629{
630 struct pci_dev *dev = to_pci_dev(container_of(kobj, struct device, 630 struct pci_dev *dev = to_pci_dev(kobj_to_dev(kobj));
631 kobj));
632 unsigned int size = 64; 631 unsigned int size = 64;
633 loff_t init_off = off; 632 loff_t init_off = off;
634 u8 *data = (u8 *) buf; 633 u8 *data = (u8 *) buf;
@@ -704,8 +703,7 @@ static ssize_t pci_write_config(struct file *filp, struct kobject *kobj,
704 struct bin_attribute *bin_attr, char *buf, 703 struct bin_attribute *bin_attr, char *buf,
705 loff_t off, size_t count) 704 loff_t off, size_t count)
706{ 705{
707 struct pci_dev *dev = to_pci_dev(container_of(kobj, struct device, 706 struct pci_dev *dev = to_pci_dev(kobj_to_dev(kobj));
708 kobj));
709 unsigned int size = count; 707 unsigned int size = count;
710 loff_t init_off = off; 708 loff_t init_off = off;
711 u8 *data = (u8 *) buf; 709 u8 *data = (u8 *) buf;
@@ -766,8 +764,7 @@ static ssize_t read_vpd_attr(struct file *filp, struct kobject *kobj,
766 struct bin_attribute *bin_attr, char *buf, 764 struct bin_attribute *bin_attr, char *buf,
767 loff_t off, size_t count) 765 loff_t off, size_t count)
768{ 766{
769 struct pci_dev *dev = 767 struct pci_dev *dev = to_pci_dev(kobj_to_dev(kobj));
770 to_pci_dev(container_of(kobj, struct device, kobj));
771 768
772 if (off > bin_attr->size) 769 if (off > bin_attr->size)
773 count = 0; 770 count = 0;
@@ -781,8 +778,7 @@ static ssize_t write_vpd_attr(struct file *filp, struct kobject *kobj,
781 struct bin_attribute *bin_attr, char *buf, 778 struct bin_attribute *bin_attr, char *buf,
782 loff_t off, size_t count) 779 loff_t off, size_t count)
783{ 780{
784 struct pci_dev *dev = 781 struct pci_dev *dev = to_pci_dev(kobj_to_dev(kobj));
785 to_pci_dev(container_of(kobj, struct device, kobj));
786 782
787 if (off > bin_attr->size) 783 if (off > bin_attr->size)
788 count = 0; 784 count = 0;
@@ -809,8 +805,7 @@ static ssize_t pci_read_legacy_io(struct file *filp, struct kobject *kobj,
809 struct bin_attribute *bin_attr, char *buf, 805 struct bin_attribute *bin_attr, char *buf,
810 loff_t off, size_t count) 806 loff_t off, size_t count)
811{ 807{
812 struct pci_bus *bus = to_pci_bus(container_of(kobj, struct device, 808 struct pci_bus *bus = to_pci_bus(kobj_to_dev(kobj));
813 kobj));
814 809
815 /* Only support 1, 2 or 4 byte accesses */ 810 /* Only support 1, 2 or 4 byte accesses */
816 if (count != 1 && count != 2 && count != 4) 811 if (count != 1 && count != 2 && count != 4)
@@ -835,8 +830,7 @@ static ssize_t pci_write_legacy_io(struct file *filp, struct kobject *kobj,
835 struct bin_attribute *bin_attr, char *buf, 830 struct bin_attribute *bin_attr, char *buf,
836 loff_t off, size_t count) 831 loff_t off, size_t count)
837{ 832{
838 struct pci_bus *bus = to_pci_bus(container_of(kobj, struct device, 833 struct pci_bus *bus = to_pci_bus(kobj_to_dev(kobj));
839 kobj));
840 834
841 /* Only support 1, 2 or 4 byte accesses */ 835 /* Only support 1, 2 or 4 byte accesses */
842 if (count != 1 && count != 2 && count != 4) 836 if (count != 1 && count != 2 && count != 4)
@@ -860,8 +854,7 @@ static int pci_mmap_legacy_mem(struct file *filp, struct kobject *kobj,
860 struct bin_attribute *attr, 854 struct bin_attribute *attr,
861 struct vm_area_struct *vma) 855 struct vm_area_struct *vma)
862{ 856{
863 struct pci_bus *bus = to_pci_bus(container_of(kobj, struct device, 857 struct pci_bus *bus = to_pci_bus(kobj_to_dev(kobj));
864 kobj));
865 858
866 return pci_mmap_legacy_page_range(bus, vma, pci_mmap_mem); 859 return pci_mmap_legacy_page_range(bus, vma, pci_mmap_mem);
867} 860}
@@ -881,8 +874,7 @@ static int pci_mmap_legacy_io(struct file *filp, struct kobject *kobj,
881 struct bin_attribute *attr, 874 struct bin_attribute *attr,
882 struct vm_area_struct *vma) 875 struct vm_area_struct *vma)
883{ 876{
884 struct pci_bus *bus = to_pci_bus(container_of(kobj, struct device, 877 struct pci_bus *bus = to_pci_bus(kobj_to_dev(kobj));
885 kobj));
886 878
887 return pci_mmap_legacy_page_range(bus, vma, pci_mmap_io); 879 return pci_mmap_legacy_page_range(bus, vma, pci_mmap_io);
888} 880}
@@ -997,8 +989,7 @@ int pci_mmap_fits(struct pci_dev *pdev, int resno, struct vm_area_struct *vma,
997static int pci_mmap_resource(struct kobject *kobj, struct bin_attribute *attr, 989static int pci_mmap_resource(struct kobject *kobj, struct bin_attribute *attr,
998 struct vm_area_struct *vma, int write_combine) 990 struct vm_area_struct *vma, int write_combine)
999{ 991{
1000 struct pci_dev *pdev = to_pci_dev(container_of(kobj, 992 struct pci_dev *pdev = to_pci_dev(kobj_to_dev(kobj));
1001 struct device, kobj));
1002 struct resource *res = attr->private; 993 struct resource *res = attr->private;
1003 enum pci_mmap_state mmap_type; 994 enum pci_mmap_state mmap_type;
1004 resource_size_t start, end; 995 resource_size_t start, end;
@@ -1051,8 +1042,7 @@ static ssize_t pci_resource_io(struct file *filp, struct kobject *kobj,
1051 struct bin_attribute *attr, char *buf, 1042 struct bin_attribute *attr, char *buf,
1052 loff_t off, size_t count, bool write) 1043 loff_t off, size_t count, bool write)
1053{ 1044{
1054 struct pci_dev *pdev = to_pci_dev(container_of(kobj, 1045 struct pci_dev *pdev = to_pci_dev(kobj_to_dev(kobj));
1055 struct device, kobj));
1056 struct resource *res = attr->private; 1046 struct resource *res = attr->private;
1057 unsigned long port = off; 1047 unsigned long port = off;
1058 int i; 1048 int i;
@@ -1222,7 +1212,7 @@ static ssize_t pci_write_rom(struct file *filp, struct kobject *kobj,
1222 struct bin_attribute *bin_attr, char *buf, 1212 struct bin_attribute *bin_attr, char *buf,
1223 loff_t off, size_t count) 1213 loff_t off, size_t count)
1224{ 1214{
1225 struct pci_dev *pdev = to_pci_dev(container_of(kobj, struct device, kobj)); 1215 struct pci_dev *pdev = to_pci_dev(kobj_to_dev(kobj));
1226 1216
1227 if ((off == 0) && (*buf == '0') && (count == 2)) 1217 if ((off == 0) && (*buf == '0') && (count == 2))
1228 pdev->rom_attr_enabled = 0; 1218 pdev->rom_attr_enabled = 0;
@@ -1248,7 +1238,7 @@ static ssize_t pci_read_rom(struct file *filp, struct kobject *kobj,
1248 struct bin_attribute *bin_attr, char *buf, 1238 struct bin_attribute *bin_attr, char *buf,
1249 loff_t off, size_t count) 1239 loff_t off, size_t count)
1250{ 1240{
1251 struct pci_dev *pdev = to_pci_dev(container_of(kobj, struct device, kobj)); 1241 struct pci_dev *pdev = to_pci_dev(kobj_to_dev(kobj));
1252 void __iomem *rom; 1242 void __iomem *rom;
1253 size_t size; 1243 size_t size;
1254 1244
@@ -1508,7 +1498,7 @@ static struct attribute *pci_dev_dev_attrs[] = {
1508static umode_t pci_dev_attrs_are_visible(struct kobject *kobj, 1498static umode_t pci_dev_attrs_are_visible(struct kobject *kobj,
1509 struct attribute *a, int n) 1499 struct attribute *a, int n)
1510{ 1500{
1511 struct device *dev = container_of(kobj, struct device, kobj); 1501 struct device *dev = kobj_to_dev(kobj);
1512 struct pci_dev *pdev = to_pci_dev(dev); 1502 struct pci_dev *pdev = to_pci_dev(dev);
1513 1503
1514 if (a == &vga_attr.attr) 1504 if (a == &vga_attr.attr)
@@ -1527,7 +1517,7 @@ static struct attribute *pci_dev_hp_attrs[] = {
1527static umode_t pci_dev_hp_attrs_are_visible(struct kobject *kobj, 1517static umode_t pci_dev_hp_attrs_are_visible(struct kobject *kobj,
1528 struct attribute *a, int n) 1518 struct attribute *a, int n)
1529{ 1519{
1530 struct device *dev = container_of(kobj, struct device, kobj); 1520 struct device *dev = kobj_to_dev(kobj);
1531 struct pci_dev *pdev = to_pci_dev(dev); 1521 struct pci_dev *pdev = to_pci_dev(dev);
1532 1522
1533 if (pdev->is_virtfn) 1523 if (pdev->is_virtfn)
@@ -1551,7 +1541,7 @@ static struct attribute *sriov_dev_attrs[] = {
1551static umode_t sriov_attrs_are_visible(struct kobject *kobj, 1541static umode_t sriov_attrs_are_visible(struct kobject *kobj,
1552 struct attribute *a, int n) 1542 struct attribute *a, int n)
1553{ 1543{
1554 struct device *dev = container_of(kobj, struct device, kobj); 1544 struct device *dev = kobj_to_dev(kobj);
1555 1545
1556 if (!dev_is_pf(dev)) 1546 if (!dev_is_pf(dev))
1557 return 0; 1547 return 0;
diff --git a/drivers/pci/pci.c b/drivers/pci/pci.c
index 314db8c1047a..49e3715477d1 100644
--- a/drivers/pci/pci.c
+++ b/drivers/pci/pci.c
@@ -1417,7 +1417,7 @@ struct pci_devres {
1417 1417
1418static void pcim_release(struct device *gendev, void *res) 1418static void pcim_release(struct device *gendev, void *res)
1419{ 1419{
1420 struct pci_dev *dev = container_of(gendev, struct pci_dev, dev); 1420 struct pci_dev *dev = to_pci_dev(gendev);
1421 struct pci_devres *this = res; 1421 struct pci_devres *this = res;
1422 int i; 1422 int i;
1423 1423
@@ -1534,7 +1534,7 @@ void __weak pcibios_release_device(struct pci_dev *dev) {}
1534 * is the default implementation. Architecture implementations can 1534 * is the default implementation. Architecture implementations can
1535 * override this. 1535 * override this.
1536 */ 1536 */
1537void __weak pcibios_disable_device (struct pci_dev *dev) {} 1537void __weak pcibios_disable_device(struct pci_dev *dev) {}
1538 1538
1539/** 1539/**
1540 * pcibios_penalize_isa_irq - penalize an ISA IRQ 1540 * pcibios_penalize_isa_irq - penalize an ISA IRQ
diff --git a/drivers/pci/setup-bus.c b/drivers/pci/setup-bus.c
index 1723ac1b30e1..7796d0a5befa 100644
--- a/drivers/pci/setup-bus.c
+++ b/drivers/pci/setup-bus.c
@@ -442,7 +442,7 @@ static void __assign_resources_sorted(struct list_head *head,
442 break; 442 break;
443 } 443 }
444 } 444 }
445 } 445 }
446 446
447 } 447 }
448 448