Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 17511
b: refs/heads/master
c: efbf62e
h: refs/heads/master
i:
  17509: 3f29d95
  17507: 0dc0cb5
  17503: d90b3fe
v: v3
  • Loading branch information
Jesper Juhl authored and Greg Kroah-Hartman committed Jan 9, 2006
1 parent 3e17893 commit a670be4
Show file tree
Hide file tree
Showing 2 changed files with 68 additions and 55 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 5d135dff536f30022674d463ce3119bb28e045df
refs/heads/master: efbf62e9f4d93c3716a4d6d3221d537c71e299a2
121 changes: 67 additions & 54 deletions trunk/drivers/pci/hotplug/cpqphp_core.c
Original file line number Diff line number Diff line change
Expand Up @@ -327,7 +327,9 @@ static int ctrl_slot_setup(struct controller *ctrl,
void __iomem *smbios_start,
void __iomem *smbios_table)
{
struct slot *new_slot;
struct slot *slot;
struct hotplug_slot *hotplug_slot;
struct hotplug_slot_info *hotplug_slot_info;
u8 number_of_slots;
u8 slot_device;
u8 slot_number;
Expand All @@ -345,109 +347,120 @@ static int ctrl_slot_setup(struct controller *ctrl,
slot_number = ctrl->first_slot;

while (number_of_slots) {
new_slot = kmalloc(sizeof(*new_slot), GFP_KERNEL);
if (!new_slot)
slot = kmalloc(sizeof(*slot), GFP_KERNEL);
if (!slot)
goto error;

memset(new_slot, 0, sizeof(struct slot));
new_slot->hotplug_slot = kmalloc(sizeof(*(new_slot->hotplug_slot)),
memset(slot, 0, sizeof(struct slot));
slot->hotplug_slot = kmalloc(sizeof(*(slot->hotplug_slot)),
GFP_KERNEL);
if (!new_slot->hotplug_slot)
if (!slot->hotplug_slot)
goto error_slot;
memset(new_slot->hotplug_slot, 0, sizeof(struct hotplug_slot));
hotplug_slot = slot->hotplug_slot;
memset(hotplug_slot, 0, sizeof(struct hotplug_slot));

new_slot->hotplug_slot->info =
kmalloc(sizeof(*(new_slot->hotplug_slot->info)),
hotplug_slot->info =
kmalloc(sizeof(*(hotplug_slot->info)),
GFP_KERNEL);
if (!new_slot->hotplug_slot->info)
if (!hotplug_slot->info)
goto error_hpslot;
memset(new_slot->hotplug_slot->info, 0,
hotplug_slot_info = hotplug_slot->info;
memset(hotplug_slot_info, 0,
sizeof(struct hotplug_slot_info));
new_slot->hotplug_slot->name = kmalloc(SLOT_NAME_SIZE, GFP_KERNEL);
if (!new_slot->hotplug_slot->name)
hotplug_slot->name = kmalloc(SLOT_NAME_SIZE, GFP_KERNEL);

if (!hotplug_slot->name)
goto error_info;

new_slot->ctrl = ctrl;
new_slot->bus = ctrl->bus;
new_slot->device = slot_device;
new_slot->number = slot_number;
dbg("slot->number = %d\n",new_slot->number);
slot->ctrl = ctrl;
slot->bus = ctrl->bus;
slot->device = slot_device;
slot->number = slot_number;
dbg("slot->number = %d\n", slot->number);

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) !=
slot->number)) {
slot_entry = get_SMBIOS_entry(smbios_start,
smbios_table, 9, slot_entry);
}

new_slot->p_sm_slot = slot_entry;
slot->p_sm_slot = slot_entry;

init_timer(&new_slot->task_event);
new_slot->task_event.expires = jiffies + 5 * HZ;
new_slot->task_event.function = cpqhp_pushbutton_thread;
init_timer(&slot->task_event);
slot->task_event.expires = jiffies + 5 * HZ;
slot->task_event.function = cpqhp_pushbutton_thread;

//FIXME: these capabilities aren't used but if they are
// they need to be correctly implemented
new_slot->capabilities |= PCISLOT_REPLACE_SUPPORTED;
new_slot->capabilities |= PCISLOT_INTERLOCK_SUPPORTED;
slot->capabilities |= PCISLOT_REPLACE_SUPPORTED;
slot->capabilities |= PCISLOT_INTERLOCK_SUPPORTED;

if (is_slot64bit(new_slot))
new_slot->capabilities |= PCISLOT_64_BIT_SUPPORTED;
if (is_slot66mhz(new_slot))
new_slot->capabilities |= PCISLOT_66_MHZ_SUPPORTED;
if (is_slot64bit(slot))
slot->capabilities |= PCISLOT_64_BIT_SUPPORTED;
if (is_slot66mhz(slot))
slot->capabilities |= PCISLOT_66_MHZ_SUPPORTED;
if (ctrl->speed == PCI_SPEED_66MHz)
new_slot->capabilities |= PCISLOT_66_MHZ_OPERATION;
slot->capabilities |= PCISLOT_66_MHZ_OPERATION;

ctrl_slot = slot_device - (readb(ctrl->hpc_reg + SLOT_MASK) >> 4);
ctrl_slot =
slot_device - (readb(ctrl->hpc_reg + SLOT_MASK) >> 4);

// Check presence
new_slot->capabilities |= ((((~tempdword) >> 23) | ((~tempdword) >> 15)) >> ctrl_slot) & 0x02;
slot->capabilities |=
((((~tempdword) >> 23) |
((~tempdword) >> 15)) >> ctrl_slot) & 0x02;
// Check the switch state
new_slot->capabilities |= ((~tempdword & 0xFF) >> ctrl_slot) & 0x01;
slot->capabilities |=
((~tempdword & 0xFF) >> ctrl_slot) & 0x01;
// Check the slot enable
new_slot->capabilities |= ((read_slot_enable(ctrl) << 2) >> ctrl_slot) & 0x04;
slot->capabilities |=
((read_slot_enable(ctrl) << 2) >> ctrl_slot) & 0x04;

/* register this slot with the hotplug pci core */
new_slot->hotplug_slot->release = &release_slot;
new_slot->hotplug_slot->private = new_slot;
make_slot_name(new_slot->hotplug_slot->name, SLOT_NAME_SIZE, new_slot);
new_slot->hotplug_slot->ops = &cpqphp_hotplug_slot_ops;
hotplug_slot->release = &release_slot;
hotplug_slot->private = slot;
make_slot_name(hotplug_slot->name, SLOT_NAME_SIZE, 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->attention_status = cpq_get_attention_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);
hotplug_slot_info->power_status = get_slot_enabled(ctrl, slot);
hotplug_slot_info->attention_status =
cpq_get_attention_status(ctrl, slot);
hotplug_slot_info->latch_status =
cpq_get_latch_status(ctrl, slot);
hotplug_slot_info->adapter_status =
get_presence_status(ctrl, slot);

dbg ("registering bus %d, dev %d, number %d, "
dbg("registering bus %d, dev %d, number %d, "
"ctrl->slot_device_offset %d, slot %d\n",
new_slot->bus, new_slot->device,
new_slot->number, ctrl->slot_device_offset,
slot->bus, slot->device,
slot->number, ctrl->slot_device_offset,
slot_number);
result = pci_hp_register (new_slot->hotplug_slot);
result = pci_hp_register(hotplug_slot);
if (result) {
err ("pci_hp_register failed with error %d\n", result);
err("pci_hp_register failed with error %d\n", result);
goto error_name;
}

new_slot->next = ctrl->slot;
ctrl->slot = new_slot;
slot->next = ctrl->slot;
ctrl->slot = slot;

number_of_slots--;
slot_device++;
slot_number++;
}

return 0;

error_name:
kfree(new_slot->hotplug_slot->name);
kfree(hotplug_slot->name);
error_info:
kfree(new_slot->hotplug_slot->info);
kfree(hotplug_slot_info);
error_hpslot:
kfree(new_slot->hotplug_slot);
kfree(hotplug_slot);
error_slot:
kfree(new_slot);
kfree(slot);
error:
return result;
}
Expand Down

0 comments on commit a670be4

Please sign in to comment.