Commit ef64cfb0 authored by Rolf Eike Beer's avatar Rolf Eike Beer Committed by Deepak Saxena

[PATCH] Compaq PCI Hotplug: more coding style fixes

Fix a lot of coding style issues in Compaq PCI hotplug:
-spaces before opening brace of functions
-much too much C++ style comments
-wrap long lines
-remove some comments where the code does not really need to be explained

Eike
parent ab24376f
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
* Compaq Hot Plug Controller Driver * Compaq Hot Plug Controller Driver
* *
* Copyright (C) 1995,2001 Compaq Computer Corporation * Copyright (C) 1995,2001 Compaq Computer Corporation
* Copyright (C) 2001 Greg Kroah-Hartman (greg@kroah.com) * Copyright (C) 2001 Greg Kroah-Hartman <greg@kroah.com>
* Copyright (C) 2001 IBM Corp. * Copyright (C) 2001 IBM Corp.
* *
* All rights reserved. * All rights reserved.
...@@ -104,30 +104,18 @@ static struct hotplug_slot_ops cpqphp_hotplug_slot_ops = { ...@@ -104,30 +104,18 @@ static struct hotplug_slot_ops cpqphp_hotplug_slot_ops = {
}; };
static inline int is_slot64bit (struct slot *slot) static inline int is_slot64bit(struct slot *slot)
{ {
if (!slot || !slot->p_sm_slot) return (readb(slot->p_sm_slot + SMBIOS_SLOT_WIDTH) == 0x06) ? 1 : 0;
return 0;
if (readb(slot->p_sm_slot + SMBIOS_SLOT_WIDTH) == 0x06)
return 1;
return 0;
} }
static inline int is_slot66mhz (struct slot *slot) static inline int is_slot66mhz(struct slot *slot)
{ {
if (!slot || !slot->p_sm_slot) return (readb(slot->p_sm_slot + SMBIOS_SLOT_TYPE) == 0x0E) ? 1 : 0;
return 0;
if (readb(slot->p_sm_slot + SMBIOS_SLOT_TYPE) == 0x0E)
return 1;
return 0;
} }
/** /**
* detect_SMBIOS_pointer - find the system Management BIOS Table in the specified region of memory. * detect_SMBIOS_pointer - find the System Management BIOS Table in mem region.
* *
* @begin: begin pointer for region to be scanned. * @begin: begin pointer for region to be scanned.
* @end: end pointer for region to be scanned. * @end: end pointer for region to be scanned.
...@@ -211,7 +199,8 @@ static int pci_print_IRQ_route (void) ...@@ -211,7 +199,8 @@ static int pci_print_IRQ_route (void)
return -ENOMEM; return -ENOMEM;
} }
len = (routing_table->size - sizeof(struct irq_routing_table)) / sizeof(struct irq_info); len = (routing_table->size - sizeof(struct irq_routing_table)) /
sizeof(struct irq_info);
// Make sure I got at least one entry // Make sure I got at least one entry
if (len == 0) { if (len == 0) {
kfree(routing_table); kfree(routing_table);
...@@ -232,8 +221,8 @@ static int pci_print_IRQ_route (void) ...@@ -232,8 +221,8 @@ static int pci_print_IRQ_route (void)
} }
/* /**
* get_subsequent_smbios_entry * get_subsequent_smbios_entry: get the next entry from bios table.
* *
* Gets the first entry if previous == NULL * Gets the first entry if previous == NULL
* Otherwise, returns the next entry * Otherwise, returns the next entry
...@@ -243,7 +232,8 @@ static int pci_print_IRQ_route (void) ...@@ -243,7 +232,8 @@ static int pci_print_IRQ_route (void)
* *
* returns a pointer to an SMBIOS structure or NULL if none found * returns a pointer to an SMBIOS structure or NULL if none found
*/ */
static void * get_subsequent_smbios_entry(void *smbios_start, void *smbios_table, void *curr) static void *get_subsequent_smbios_entry(void *smbios_start,
void *smbios_table, void *curr)
{ {
u8 bail = 0; u8 bail = 0;
u8 previous_byte = 1; u8 previous_byte = 1;
...@@ -260,8 +250,9 @@ static void * get_subsequent_smbios_entry(void *smbios_start, void *smbios_table ...@@ -260,8 +250,9 @@ static void * get_subsequent_smbios_entry(void *smbios_start, void *smbios_table
p_temp += readb(curr + SMBIOS_GENERIC_LENGTH); p_temp += readb(curr + SMBIOS_GENERIC_LENGTH);
while ((p_temp < p_max) && !bail) { while ((p_temp < p_max) && !bail) {
// Look for the double NULL terminator /* Look for the double NULL terminator
// The first condition is the previous byte and the second is the curr * The first condition is the previous byte
* and the second is the curr */
if (!previous_byte && !(readb(p_temp))) { if (!previous_byte && !(readb(p_temp))) {
bail = 1; bail = 1;
} }
...@@ -291,7 +282,8 @@ static void * get_subsequent_smbios_entry(void *smbios_start, void *smbios_table ...@@ -291,7 +282,8 @@ static void * get_subsequent_smbios_entry(void *smbios_start, void *smbios_table
* *
* returns a pointer to an SMBIOS structure or %NULL if none found * returns a pointer to an SMBIOS structure or %NULL if none found
*/ */
static void *get_SMBIOS_entry (void *smbios_start, void *smbios_table, u8 type, void * previous) static void *get_SMBIOS_entry(void *smbios_start, void *smbios_table, u8 type,
void * previous)
{ {
if (!smbios_table) if (!smbios_table)
return NULL; return NULL;
...@@ -299,12 +291,14 @@ static void *get_SMBIOS_entry (void *smbios_start, void *smbios_table, u8 type, ...@@ -299,12 +291,14 @@ static void *get_SMBIOS_entry (void *smbios_start, void *smbios_table, u8 type,
if (!previous) { if (!previous) {
previous = smbios_start; previous = smbios_start;
} else { } else {
previous = get_subsequent_smbios_entry(smbios_start, smbios_table, previous); previous = get_subsequent_smbios_entry(smbios_start,
smbios_table, previous);
} }
while (previous) { while (previous) {
if (readb(previous + SMBIOS_GENERIC_TYPE) != type) { if (readb(previous + SMBIOS_GENERIC_TYPE) != type) {
previous = get_subsequent_smbios_entry(smbios_start, smbios_table, previous); previous = get_subsequent_smbios_entry(smbios_start,
smbios_table, previous);
} else { } else {
break; break;
} }
...@@ -328,7 +322,8 @@ static void release_slot(struct hotplug_slot *hotplug_slot) ...@@ -328,7 +322,8 @@ static void release_slot(struct hotplug_slot *hotplug_slot)
kfree(slot); kfree(slot);
} }
static int ctrl_slot_setup (struct controller * ctrl, void *smbios_start, void *smbios_table) static int ctrl_slot_setup (struct controller * ctrl, void *smbios_start,
void *smbios_table)
{ {
struct slot *new_slot; struct slot *new_slot;
u8 number_of_slots; u8 number_of_slots;
...@@ -337,7 +332,7 @@ static int ctrl_slot_setup (struct controller * ctrl, void *smbios_start, void * ...@@ -337,7 +332,7 @@ static int ctrl_slot_setup (struct controller * ctrl, void *smbios_start, void *
u8 ctrl_slot; u8 ctrl_slot;
u32 tempdword; u32 tempdword;
void *slot_entry= NULL; void *slot_entry= NULL;
int result; int result = -ENOMEM;
dbg("%s\n", __FUNCTION__); dbg("%s\n", __FUNCTION__);
...@@ -381,10 +376,12 @@ static int ctrl_slot_setup (struct controller * ctrl, void *smbios_start, void * ...@@ -381,10 +376,12 @@ static int ctrl_slot_setup (struct controller * ctrl, void *smbios_start, void *
new_slot->number = slot_number; new_slot->number = slot_number;
dbg("slot->number = %d\n",new_slot->number); dbg("slot->number = %d\n",new_slot->number);
slot_entry = get_SMBIOS_entry(smbios_start, smbios_table, 9, slot_entry); slot_entry = get_SMBIOS_entry(smbios_start, smbios_table, 9,
slot_entry);
while (slot_entry && (readw(slot_entry + SMBIOS_SLOT_NUMBER) != new_slot->number)) { while (slot_entry && (readw(slot_entry + SMBIOS_SLOT_NUMBER) != new_slot->number)) {
slot_entry = get_SMBIOS_entry(smbios_start, smbios_table, 9, slot_entry); slot_entry = get_SMBIOS_entry(smbios_start,
smbios_table, 9, slot_entry);
} }
new_slot->p_sm_slot = slot_entry; new_slot->p_sm_slot = slot_entry;
...@@ -417,7 +414,7 @@ static int ctrl_slot_setup (struct controller * ctrl, void *smbios_start, void * ...@@ -417,7 +414,7 @@ static int ctrl_slot_setup (struct controller * ctrl, void *smbios_start, void *
/* register this slot with the hotplug pci core */ /* register this slot with the hotplug pci core */
new_slot->hotplug_slot->release = &release_slot; new_slot->hotplug_slot->release = &release_slot;
new_slot->hotplug_slot->private = new_slot; new_slot->hotplug_slot->private = new_slot;
make_slot_name (new_slot->hotplug_slot->name, SLOT_NAME_SIZE, new_slot); make_slot_name(new_slot->hotplug_slot->name, SLOT_NAME_SIZE, new_slot);
new_slot->hotplug_slot->ops = &cpqphp_hotplug_slot_ops; new_slot->hotplug_slot->ops = &cpqphp_hotplug_slot_ops;
new_slot->hotplug_slot->info->power_status = get_slot_enabled(ctrl, new_slot); new_slot->hotplug_slot->info->power_status = get_slot_enabled(ctrl, new_slot);
...@@ -425,8 +422,11 @@ static int ctrl_slot_setup (struct controller * ctrl, void *smbios_start, void * ...@@ -425,8 +422,11 @@ static int ctrl_slot_setup (struct controller * ctrl, void *smbios_start, void *
new_slot->hotplug_slot->info->latch_status = cpq_get_latch_status(ctrl, new_slot); new_slot->hotplug_slot->info->latch_status = cpq_get_latch_status(ctrl, new_slot);
new_slot->hotplug_slot->info->adapter_status = get_presence_status(ctrl, new_slot); new_slot->hotplug_slot->info->adapter_status = get_presence_status(ctrl, new_slot);
dbg ("registering bus %d, dev %d, number %d, ctrl->slot_device_offset %d, slot %d\n", dbg ("registering bus %d, dev %d, number %d, "
new_slot->bus, new_slot->device, new_slot->number, ctrl->slot_device_offset, slot_number); "ctrl->slot_device_offset %d, slot %d\n",
new_slot->bus, new_slot->device,
new_slot->number, ctrl->slot_device_offset,
slot_number);
result = pci_hp_register (new_slot->hotplug_slot); result = pci_hp_register (new_slot->hotplug_slot);
if (result) { if (result) {
err ("pci_hp_register failed with error %d\n", result); err ("pci_hp_register failed with error %d\n", result);
...@@ -485,7 +485,8 @@ static int ctrl_slot_cleanup (struct controller * ctrl) ...@@ -485,7 +485,8 @@ static int ctrl_slot_cleanup (struct controller * ctrl)
// //
// Output: SUCCESS or FAILURE // Output: SUCCESS or FAILURE
//============================================================================= //=============================================================================
static int get_slot_mapping (struct pci_bus *bus, u8 bus_num, u8 dev_num, u8 *slot) static int
get_slot_mapping(struct pci_bus *bus, u8 bus_num, u8 dev_num, u8 *slot)
{ {
struct irq_routing_table *PCIIRQRoutingInfoLength; struct irq_routing_table *PCIIRQRoutingInfoLength;
u32 work; u32 work;
...@@ -520,17 +521,22 @@ static int get_slot_mapping (struct pci_bus *bus, u8 bus_num, u8 dev_num, u8 *sl ...@@ -520,17 +521,22 @@ static int get_slot_mapping (struct pci_bus *bus, u8 bus_num, u8 dev_num, u8 *sl
kfree(PCIIRQRoutingInfoLength); kfree(PCIIRQRoutingInfoLength);
return 0; return 0;
} else { } else {
// Didn't get a match on the target PCI device. Check if the /* Did not get a match on the target PCI device. Check
// current IRQ table entry is a PCI-to-PCI bridge device. If so, * if the current IRQ table entry is a PCI-to-PCI bridge
// and it's secondary bus matches the bus number for the target * device. If so, and it's secondary bus matches the
// device, I need to save the bridge's slot number. If I can't * bus number for the target device, I need to save the
// find an entry for the target device, I will have to assume it's * bridge's slot number. If I can not find an entry for
// on the other side of the bridge, and assign it the bridge's slot. * the target device, I will have to assume it's on the
* other side of the bridge, and assign it the bridge's
* slot. */
bus->number = tbus; bus->number = tbus;
pci_bus_read_config_dword (bus, PCI_DEVFN(tdevice, 0), PCI_REVISION_ID, &work); pci_bus_read_config_dword(bus, PCI_DEVFN(tdevice, 0),
PCI_REVISION_ID, &work);
if ((work >> 8) == PCI_TO_PCI_BRIDGE_CLASS) { if ((work >> 8) == PCI_TO_PCI_BRIDGE_CLASS) {
pci_bus_read_config_dword (bus, PCI_DEVFN(tdevice, 0), PCI_PRIMARY_BUS, &work); pci_bus_read_config_dword(bus,
PCI_DEVFN(tdevice, 0),
PCI_PRIMARY_BUS, &work);
// See if bridge's secondary bus matches target bus. // See if bridge's secondary bus matches target bus.
if (((work >> 8) & 0x000000FF) == (long) bus_num) { if (((work >> 8) & 0x000000FF) == (long) bus_num) {
bridgeSlot = tslot; bridgeSlot = tslot;
...@@ -559,7 +565,9 @@ static int get_slot_mapping (struct pci_bus *bus, u8 bus_num, u8 dev_num, u8 *sl ...@@ -559,7 +565,9 @@ static int get_slot_mapping (struct pci_bus *bus, u8 bus_num, u8 dev_num, u8 *sl
* cpqhp_set_attention_status - Turns the Amber LED for a slot on or off * cpqhp_set_attention_status - Turns the Amber LED for a slot on or off
* *
*/ */
static int cpqhp_set_attention_status (struct controller *ctrl, struct pci_func *func, u32 status) static int
cpqhp_set_attention_status(struct controller *ctrl, struct pci_func *func,
u32 status)
{ {
u8 hp_slot; u8 hp_slot;
...@@ -652,9 +660,8 @@ static int process_SI(struct hotplug_slot *hotplug_slot) ...@@ -652,9 +660,8 @@ static int process_SI(struct hotplug_slot *hotplug_slot)
dbg("bus, dev, fn = %d, %d, %d\n", bus, device, function); dbg("bus, dev, fn = %d, %d, %d\n", bus, device, function);
slot_func = cpqhp_slot_find(bus, device, function); slot_func = cpqhp_slot_find(bus, device, function);
if (!slot_func) { if (!slot_func)
return -ENODEV; return -ENODEV;
}
slot_func->bus = bus; slot_func->bus = bus;
slot_func->device = device; slot_func->device = device;
...@@ -685,11 +692,10 @@ static int process_SS(struct hotplug_slot *hotplug_slot) ...@@ -685,11 +692,10 @@ static int process_SS(struct hotplug_slot *hotplug_slot)
dbg("bus, dev, fn = %d, %d, %d\n", bus, device, function); dbg("bus, dev, fn = %d, %d, %d\n", bus, device, function);
slot_func = cpqhp_slot_find(bus, device, function); slot_func = cpqhp_slot_find(bus, device, function);
if (!slot_func) { if (!slot_func)
return -ENODEV; return -ENODEV;
}
dbg("In power_down_board, slot_func = %p, ctrl = %p\n", slot_func, ctrl); dbg("In %s, slot_func = %p, ctrl = %p\n", __FUNCTION__, slot_func, ctrl);
return cpqhp_process_SS(ctrl, slot_func); return cpqhp_process_SS(ctrl, slot_func);
} }
...@@ -845,11 +851,11 @@ static int cpqhpc_probe(struct pci_dev *pdev, const struct pci_device_id *ent) ...@@ -845,11 +851,11 @@ static int cpqhpc_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
case PCI_VENDOR_ID_COMPAQ: case PCI_VENDOR_ID_COMPAQ:
if (rev >= 0x13) { /* CIOBX */ if (rev >= 0x13) { /* CIOBX */
ctrl->push_flag = 1; ctrl->push_flag = 1;
ctrl->slot_switch_type = 1; // Switch is present ctrl->slot_switch_type = 1;
ctrl->push_button = 1; // Pushbutton is present ctrl->push_button = 1;
ctrl->pci_config_space = 1; // Index/data access to working registers 0 = not supported, 1 = supported ctrl->pci_config_space = 1;
ctrl->defeature_PHP = 1; // PHP is supported ctrl->defeature_PHP = 1;
ctrl->pcix_support = 1; // PCI-X supported ctrl->pcix_support = 1;
ctrl->pcix_speed_capability = 1; ctrl->pcix_speed_capability = 1;
pci_read_config_byte(pdev, 0x41, &bus_cap); pci_read_config_byte(pdev, 0x41, &bus_cap);
if (bus_cap & 0x80) { if (bus_cap & 0x80) {
...@@ -879,55 +885,55 @@ static int cpqhpc_probe(struct pci_dev *pdev, const struct pci_device_id *ent) ...@@ -879,55 +885,55 @@ static int cpqhpc_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
switch (subsystem_deviceid) { switch (subsystem_deviceid) {
case PCI_SUB_HPC_ID: case PCI_SUB_HPC_ID:
/* Original 6500/7000 implementation */ /* Original 6500/7000 implementation */
ctrl->slot_switch_type = 1; // Switch is present ctrl->slot_switch_type = 1;
ctrl->speed_capability = PCI_SPEED_33MHz; ctrl->speed_capability = PCI_SPEED_33MHz;
ctrl->push_button = 0; // No pushbutton ctrl->push_button = 0;
ctrl->pci_config_space = 1; // Index/data access to working registers 0 = not supported, 1 = supported ctrl->pci_config_space = 1;
ctrl->defeature_PHP = 1; // PHP is supported ctrl->defeature_PHP = 1;
ctrl->pcix_support = 0; // PCI-X not supported ctrl->pcix_support = 0;
ctrl->pcix_speed_capability = 0; // N/A since PCI-X not supported ctrl->pcix_speed_capability = 0;
break; break;
case PCI_SUB_HPC_ID2: case PCI_SUB_HPC_ID2:
/* First Pushbutton implementation */ /* First Pushbutton implementation */
ctrl->push_flag = 1; ctrl->push_flag = 1;
ctrl->slot_switch_type = 1; // Switch is present ctrl->slot_switch_type = 1;
ctrl->speed_capability = PCI_SPEED_33MHz; ctrl->speed_capability = PCI_SPEED_33MHz;
ctrl->push_button = 1; // Pushbutton is present ctrl->push_button = 1;
ctrl->pci_config_space = 1; // Index/data access to working registers 0 = not supported, 1 = supported ctrl->pci_config_space = 1;
ctrl->defeature_PHP = 1; // PHP is supported ctrl->defeature_PHP = 1;
ctrl->pcix_support = 0; // PCI-X not supported ctrl->pcix_support = 0;
ctrl->pcix_speed_capability = 0; // N/A since PCI-X not supported ctrl->pcix_speed_capability = 0;
break; break;
case PCI_SUB_HPC_ID_INTC: case PCI_SUB_HPC_ID_INTC:
/* Third party (6500/7000) */ /* Third party (6500/7000) */
ctrl->slot_switch_type = 1; // Switch is present ctrl->slot_switch_type = 1;
ctrl->speed_capability = PCI_SPEED_33MHz; ctrl->speed_capability = PCI_SPEED_33MHz;
ctrl->push_button = 0; // No pushbutton ctrl->push_button = 0;
ctrl->pci_config_space = 1; // Index/data access to working registers 0 = not supported, 1 = supported ctrl->pci_config_space = 1;
ctrl->defeature_PHP = 1; // PHP is supported ctrl->defeature_PHP = 1;
ctrl->pcix_support = 0; // PCI-X not supported ctrl->pcix_support = 0;
ctrl->pcix_speed_capability = 0; // N/A since PCI-X not supported ctrl->pcix_speed_capability = 0;
break; break;
case PCI_SUB_HPC_ID3: case PCI_SUB_HPC_ID3:
/* First 66 Mhz implementation */ /* First 66 Mhz implementation */
ctrl->push_flag = 1; ctrl->push_flag = 1;
ctrl->slot_switch_type = 1; // Switch is present ctrl->slot_switch_type = 1;
ctrl->speed_capability = PCI_SPEED_66MHz; ctrl->speed_capability = PCI_SPEED_66MHz;
ctrl->push_button = 1; // Pushbutton is present ctrl->push_button = 1;
ctrl->pci_config_space = 1; // Index/data access to working registers 0 = not supported, 1 = supported ctrl->pci_config_space = 1;
ctrl->defeature_PHP = 1; // PHP is supported ctrl->defeature_PHP = 1;
ctrl->pcix_support = 0; // PCI-X not supported ctrl->pcix_support = 0;
ctrl->pcix_speed_capability = 0; // N/A since PCI-X not supported ctrl->pcix_speed_capability = 0;
break; break;
case PCI_SUB_HPC_ID4: case PCI_SUB_HPC_ID4:
/* First PCI-X implementation, 100MHz */ /* First PCI-X implementation, 100MHz */
ctrl->push_flag = 1; ctrl->push_flag = 1;
ctrl->slot_switch_type = 1; // Switch is present ctrl->slot_switch_type = 1;
ctrl->speed_capability = PCI_SPEED_100MHz_PCIX; ctrl->speed_capability = PCI_SPEED_100MHz_PCIX;
ctrl->push_button = 1; // Pushbutton is present ctrl->push_button = 1;
ctrl->pci_config_space = 1; // Index/data access to working registers 0 = not supported, 1 = supported ctrl->pci_config_space = 1;
ctrl->defeature_PHP = 1; // PHP is supported ctrl->defeature_PHP = 1;
ctrl->pcix_support = 1; // PCI-X supported ctrl->pcix_support = 1;
ctrl->pcix_speed_capability = 0; ctrl->pcix_speed_capability = 0;
break; break;
default: default:
...@@ -1016,28 +1022,36 @@ static int cpqhpc_probe(struct pci_dev *pdev, const struct pci_device_id *ent) ...@@ -1016,28 +1022,36 @@ static int cpqhpc_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
} }
// Tell the user that we found one. // Tell the user that we found one.
info("Initializing the PCI hot plug controller residing on PCI bus %d\n", pdev->bus->number); info("Initializing the PCI hot plug controller residing on PCI bus %d\n",
pdev->bus->number);
dbg ("Hotplug controller capabilities:\n");
dbg (" speed_capability %d\n", ctrl->speed_capability); dbg("Hotplug controller capabilities:\n");
dbg (" slot_switch_type %s\n", ctrl->slot_switch_type == 0 ? "no switch" : "switch present"); dbg(" speed_capability %d\n", ctrl->speed_capability);
dbg (" defeature_PHP %s\n", ctrl->defeature_PHP == 0 ? "PHP not supported" : "PHP supported"); dbg(" slot_switch_type %s\n", ctrl->slot_switch_type ?
dbg (" alternate_base_address %s\n", ctrl->alternate_base_address == 0 ? "not supported" : "supported"); "switch present" : "no switch");
dbg (" pci_config_space %s\n", ctrl->pci_config_space == 0 ? "not supported" : "supported"); dbg(" defeature_PHP %s\n", ctrl->defeature_PHP ?
dbg (" pcix_speed_capability %s\n", ctrl->pcix_speed_capability == 0 ? "not supported" : "supported"); "PHP supported" : "PHP not supported");
dbg (" pcix_support %s\n", ctrl->pcix_support == 0 ? "not supported" : "supported"); dbg(" alternate_base_address %s\n", ctrl->alternate_base_address ?
"supported" : "not supported");
dbg(" pci_config_space %s\n", ctrl->pci_config_space ?
"supported" : "not supported");
dbg(" pcix_speed_capability %s\n", ctrl->pcix_speed_capability ?
"supported" : "not supported");
dbg(" pcix_support %s\n", ctrl->pcix_support ?
"supported" : "not supported");
ctrl->pci_dev = pdev; ctrl->pci_dev = pdev;
pci_set_drvdata(pdev, ctrl); pci_set_drvdata(pdev, ctrl);
/* make our own copy of the pci bus structure, as we like tweaking it a lot */ /* make our own copy of the pci bus structure,
ctrl->pci_bus = kmalloc (sizeof (*ctrl->pci_bus), GFP_KERNEL); * as we like tweaking it a lot */
ctrl->pci_bus = kmalloc(sizeof(*ctrl->pci_bus), GFP_KERNEL);
if (!ctrl->pci_bus) { if (!ctrl->pci_bus) {
err("out of memory\n"); err("out of memory\n");
rc = -ENOMEM; rc = -ENOMEM;
goto err_free_ctrl; goto err_free_ctrl;
} }
memcpy (ctrl->pci_bus, pdev->bus, sizeof (*ctrl->pci_bus)); memcpy(ctrl->pci_bus, pdev->bus, sizeof(*ctrl->pci_bus));
ctrl->bus = pdev->bus->number; ctrl->bus = pdev->bus->number;
ctrl->rev = rev; ctrl->rev = rev;
...@@ -1064,9 +1078,12 @@ static int cpqhpc_probe(struct pci_dev *pdev, const struct pci_device_id *ent) ...@@ -1064,9 +1078,12 @@ static int cpqhpc_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
goto err_free_bus; goto err_free_bus;
} }
ctrl->hpc_reg = ioremap(pci_resource_start(pdev, 0), pci_resource_len(pdev, 0)); ctrl->hpc_reg = ioremap(pci_resource_start(pdev, 0),
pci_resource_len(pdev, 0));
if (!ctrl->hpc_reg) { if (!ctrl->hpc_reg) {
err("cannot remap MMIO region %lx @ %lx\n", pci_resource_len(pdev, 0), pci_resource_start(pdev, 0)); err("cannot remap MMIO region %lx @ %lx\n",
pci_resource_len(pdev, 0),
pci_resource_start(pdev, 0));
rc = -ENODEV; rc = -ENODEV;
goto err_free_mem_region; goto err_free_mem_region;
} }
...@@ -1075,21 +1092,25 @@ static int cpqhpc_probe(struct pci_dev *pdev, const struct pci_device_id *ent) ...@@ -1075,21 +1092,25 @@ static int cpqhpc_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
ctrl->speed = get_controller_speed(ctrl); ctrl->speed = get_controller_speed(ctrl);
//************************************************** /********************************************************
// *
// Save configuration headers for this and * Save configuration headers for this and
// subordinate PCI buses * subordinate PCI buses
// *
//************************************************** ********************************************************/
// find the physical slot number of the first hot plug slot // find the physical slot number of the first hot plug slot
// Get slot won't work for devices behind bridges, but /* Get slot won't work for devices behind bridges, but
// in this case it will always be called for the "base" * in this case it will always be called for the "base"
// bus/dev/func of a slot. * bus/dev/func of a slot.
// CS: this is leveraging the PCIIRQ routing code from the kernel (pci-pc.c: get_irq_routing_table) * CS: this is leveraging the PCIIRQ routing code from the kernel
rc = get_slot_mapping(ctrl->pci_bus, pdev->bus->number, (readb(ctrl->hpc_reg + SLOT_MASK) >> 4), &(ctrl->first_slot)); * (pci-pc.c: get_irq_routing_table) */
dbg("get_slot_mapping: first_slot = %d, returned = %d\n", ctrl->first_slot, rc); rc = get_slot_mapping(ctrl->pci_bus, pdev->bus->number,
(readb(ctrl->hpc_reg + SLOT_MASK) >> 4),
&(ctrl->first_slot));
dbg("get_slot_mapping: first_slot = %d, returned = %d\n",
ctrl->first_slot, rc);
if (rc) { if (rc) {
err(msg_initialization_err, rc); err(msg_initialization_err, rc);
goto err_iounmap; goto err_iounmap;
...@@ -1098,7 +1119,8 @@ static int cpqhpc_probe(struct pci_dev *pdev, const struct pci_device_id *ent) ...@@ -1098,7 +1119,8 @@ static int cpqhpc_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
// Store PCI Config Space for all devices on this bus // Store PCI Config Space for all devices on this bus
rc = cpqhp_save_config(ctrl, ctrl->bus, readb(ctrl->hpc_reg + SLOT_MASK)); rc = cpqhp_save_config(ctrl, ctrl->bus, readb(ctrl->hpc_reg + SLOT_MASK));
if (rc) { if (rc) {
err("%s: unable to save PCI configuration data, error %d\n", __FUNCTION__, rc); err("%s: unable to save PCI configuration data, error %d\n",
__FUNCTION__, rc);
goto err_iounmap; goto err_iounmap;
} }
...@@ -1135,7 +1157,8 @@ static int cpqhpc_probe(struct pci_dev *pdev, const struct pci_device_id *ent) ...@@ -1135,7 +1157,8 @@ static int cpqhpc_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
rc = ctrl_slot_setup(ctrl, smbios_start, smbios_table); rc = ctrl_slot_setup(ctrl, smbios_start, smbios_table);
if (rc) { if (rc) {
err(msg_initialization_err, 6); err(msg_initialization_err, 6);
err("%s: unable to save PCI configuration data, error %d\n", __FUNCTION__, rc); err("%s: unable to save PCI configuration data, error %d\n",
__FUNCTION__, rc);
goto err_iounmap; goto err_iounmap;
} }
...@@ -1146,7 +1169,8 @@ static int cpqhpc_probe(struct pci_dev *pdev, const struct pci_device_id *ent) ...@@ -1146,7 +1169,8 @@ static int cpqhpc_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
dbg("HPC interrupt = %d \n", ctrl->interrupt); dbg("HPC interrupt = %d \n", ctrl->interrupt);
if (request_irq(ctrl->interrupt, cpqhp_ctrl_intr, if (request_irq(ctrl->interrupt, cpqhp_ctrl_intr,
SA_SHIRQ, MY_NAME, ctrl)) { SA_SHIRQ, MY_NAME, ctrl)) {
err("Can't get irq %d for the hotplug pci controller\n", ctrl->interrupt); err("Can't get irq %d for the hotplug pci controller\n",
ctrl->interrupt);
rc = -ENODEV; rc = -ENODEV;
goto err_iounmap; goto err_iounmap;
} }
...@@ -1202,8 +1226,8 @@ static int cpqhpc_probe(struct pci_dev *pdev, const struct pci_device_id *ent) ...@@ -1202,8 +1226,8 @@ static int cpqhpc_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
if (!power_mode) { if (!power_mode) {
if (!func->is_a_board) { if (!func->is_a_board) {
green_LED_off (ctrl, hp_slot); green_LED_off(ctrl, hp_slot);
slot_disable (ctrl, hp_slot); slot_disable(ctrl, hp_slot);
} }
} }
...@@ -1214,7 +1238,7 @@ static int cpqhpc_probe(struct pci_dev *pdev, const struct pci_device_id *ent) ...@@ -1214,7 +1238,7 @@ static int cpqhpc_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
if (!power_mode) { if (!power_mode) {
set_SOGO(ctrl); set_SOGO(ctrl);
// Wait for SOBS to be unset // Wait for SOBS to be unset
wait_for_ctrl_irq (ctrl); wait_for_ctrl_irq(ctrl);
} }
rc = init_SERR(ctrl); rc = init_SERR(ctrl);
...@@ -1227,7 +1251,7 @@ static int cpqhpc_probe(struct pci_dev *pdev, const struct pci_device_id *ent) ...@@ -1227,7 +1251,7 @@ static int cpqhpc_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
// Done with exclusive hardware access // Done with exclusive hardware access
up(&ctrl->crit_sect); up(&ctrl->crit_sect);
cpqhp_create_ctrl_files (ctrl); cpqhp_create_ctrl_files(ctrl);
return 0; return 0;
...@@ -1287,14 +1311,16 @@ static int one_time_init(void) ...@@ -1287,14 +1311,16 @@ static int one_time_init(void)
compaq_nvram_init(cpqhp_rom_start); compaq_nvram_init(cpqhp_rom_start);
/* Map smbios table entry point structure */ /* Map smbios table entry point structure */
smbios_table = detect_SMBIOS_pointer(cpqhp_rom_start, cpqhp_rom_start + ROM_PHY_LEN); smbios_table = detect_SMBIOS_pointer(cpqhp_rom_start,
cpqhp_rom_start + ROM_PHY_LEN);
if (!smbios_table) { if (!smbios_table) {
err ("Could not find the SMBIOS pointer in memory\n"); err ("Could not find the SMBIOS pointer in memory\n");
retval = -EIO; retval = -EIO;
goto error; goto error;
} }
smbios_start = ioremap(readl(smbios_table + ST_ADDRESS), readw(smbios_table + ST_LENGTH)); smbios_start = ioremap(readl(smbios_table + ST_ADDRESS),
readw(smbios_table + ST_LENGTH));
if (!smbios_start) { if (!smbios_start) {
err ("Could not ioremap memory region taken from SMBIOS values\n"); err ("Could not ioremap memory region taken from SMBIOS values\n");
retval = -EIO; retval = -EIO;
...@@ -1463,12 +1489,10 @@ static int __init cpqhpc_init(void) ...@@ -1463,12 +1489,10 @@ static int __init cpqhpc_init(void)
cpqhp_debug = debug; cpqhp_debug = debug;
info (DRIVER_DESC " version: " DRIVER_VERSION "\n");
result = pci_module_init(&cpqhpc_driver); result = pci_module_init(&cpqhpc_driver);
dbg("pci_module_init = %d\n", result); dbg("pci_module_init = %d\n", result);
if (result)
return result; return result;
info (DRIVER_DESC " version: " DRIVER_VERSION "\n");
return 0;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment