Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 46712
b: refs/heads/master
c: a0b1725
h: refs/heads/master
v: v3
  • Loading branch information
Kenji Kaneshige authored and Greg Kroah-Hartman committed Feb 7, 2007
1 parent 7f529b0 commit 70b2f61
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 64 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: 429538ad3eeffec4199d8adddd1e9e4c80b2c08b
refs/heads/master: a0b1725720d9a023a1dee129234f5972056038c6
10 changes: 2 additions & 8 deletions trunk/drivers/pci/hotplug/pciehp.h
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ extern int pciehp_force;
#define info(format, arg...) printk(KERN_INFO "%s: " format, MY_NAME , ## arg)
#define warn(format, arg...) printk(KERN_WARNING "%s: " format, MY_NAME , ## arg)


#define SLOT_NAME_SIZE 10
struct slot {
struct slot *next;
u8 bus;
Expand All @@ -63,6 +63,7 @@ struct slot {
struct hpc_ops *hpc_ops;
struct hotplug_slot *hotplug_slot;
struct list_head slot_list;
char name[SLOT_NAME_SIZE];
};

struct event_info {
Expand Down Expand Up @@ -233,13 +234,6 @@ static inline int wait_for_ctrl_irq(struct controller *ctrl)
return retval;
}

#define SLOT_NAME_SIZE 10

static inline void make_slot_name(char *buffer, int buffer_size, struct slot *slot)
{
snprintf(buffer, buffer_size, "%04d_%04d", slot->bus, slot->number);
}

enum php_ctlr_type {
PCI,
ISA,
Expand Down
90 changes: 35 additions & 55 deletions trunk/drivers/pci/hotplug/pciehp_core.c
Original file line number Diff line number Diff line change
Expand Up @@ -98,101 +98,81 @@ static void release_slot(struct hotplug_slot *hotplug_slot)
dbg("%s - physical_slot = %s\n", __FUNCTION__, hotplug_slot->name);

kfree(slot->hotplug_slot->info);
kfree(slot->hotplug_slot->name);
kfree(slot->hotplug_slot);
kfree(slot);
}

static void make_slot_name(struct slot *slot)
{
snprintf(slot->hotplug_slot->name, SLOT_NAME_SIZE, "%04d_%04d",
slot->bus, slot->number);
}

static int init_slots(struct controller *ctrl)
{
struct slot *slot;
struct hpc_ops *hpc_ops;
struct hotplug_slot *hotplug_slot;
struct hotplug_slot_info *hotplug_slot_info;
u8 number_of_slots;
u8 slot_device;
u32 slot_number;
int result = -ENOMEM;
struct hotplug_slot_info *info;
int retval = -ENOMEM;
int i;

number_of_slots = ctrl->num_slots;
slot_device = ctrl->slot_device_offset;
slot_number = ctrl->first_slot;

while (number_of_slots) {
for (i = 0; i < ctrl->num_slots; i++) {
slot = kzalloc(sizeof(*slot), GFP_KERNEL);
if (!slot)
goto error;

slot->hotplug_slot =
kzalloc(sizeof(*(slot->hotplug_slot)),
GFP_KERNEL);
if (!slot->hotplug_slot)
hotplug_slot = kzalloc(sizeof(*hotplug_slot), GFP_KERNEL);
if (!hotplug_slot)
goto error_slot;
hotplug_slot = slot->hotplug_slot;
slot->hotplug_slot = hotplug_slot;

hotplug_slot->info =
kzalloc(sizeof(*(hotplug_slot->info)),
GFP_KERNEL);
if (!hotplug_slot->info)
info = kzalloc(sizeof(*info), GFP_KERNEL);
if (!info)
goto error_hpslot;
hotplug_slot_info = hotplug_slot->info;
hotplug_slot->name = kmalloc(SLOT_NAME_SIZE, GFP_KERNEL);
if (!hotplug_slot->name)
goto error_info;
hotplug_slot->info = info;

slot->ctrl = ctrl;
slot->bus = ctrl->slot_bus;
slot->device = slot_device;
slot->hpc_ops = hpc_ops = ctrl->hpc_ops;
hotplug_slot->name = slot->name;

slot->hp_slot = i;
slot->ctrl = ctrl;
slot->bus = ctrl->pci_dev->subordinate->number;
slot->device = ctrl->slot_device_offset + i;
slot->hpc_ops = ctrl->hpc_ops;
slot->number = ctrl->first_slot;
slot->hp_slot = slot_device - ctrl->slot_device_offset;

/* register this slot with the hotplug pci core */
hotplug_slot->private = slot;
hotplug_slot->release = &release_slot;
make_slot_name(hotplug_slot->name, SLOT_NAME_SIZE, slot);
make_slot_name(slot);
hotplug_slot->ops = &pciehp_hotplug_slot_ops;

hpc_ops->get_power_status(slot,
&(hotplug_slot_info->power_status));
hpc_ops->get_attention_status(slot,
&(hotplug_slot_info->attention_status));
hpc_ops->get_latch_status(slot,
&(hotplug_slot_info->latch_status));
hpc_ops->get_adapter_status(slot,
&(hotplug_slot_info->adapter_status));
get_power_status(hotplug_slot, &info->power_status);
get_attention_status(hotplug_slot, &info->attention_status);
get_latch_status(hotplug_slot, &info->latch_status);
get_adapter_status(hotplug_slot, &info->adapter_status);

dbg("Registering bus=%x dev=%x hp_slot=%x sun=%x "
"slot_device_offset=%x\n",
slot->bus, slot->device, slot->hp_slot, slot->number,
ctrl->slot_device_offset);
result = pci_hp_register(hotplug_slot);
if (result) {
err ("pci_hp_register failed with error %d\n", result);
goto error_name;
"slot_device_offset=%x\n", slot->bus, slot->device,
slot->hp_slot, slot->number, ctrl->slot_device_offset);
retval = pci_hp_register(hotplug_slot);
if (retval) {
err ("pci_hp_register failed with error %d\n", retval);
goto error_info;
}

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

number_of_slots--;
slot_device++;
slot_number += ctrl->slot_num_inc;
}

return 0;

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


Expand Down

0 comments on commit 70b2f61

Please sign in to comment.