ChangeSet 1.1587.12.70, 2004/04/30 15:22:36-07:00, eike-hotplug@sf-tec.de [PATCH] SHPC PCI Hotplug: fix cleanup_slots to use a release function shpchp is the only driver which does not use a release function for the slot struct. This adds one and does some minor coding style fixes. Also no one cares about the return value of cleanup_slots (which is always 0 anyway) so we can make the function void. drivers/pci/hotplug/shpchp_core.c | 38 +++++++++++++++++++++++--------------- 1 files changed, 23 insertions(+), 15 deletions(-) diff -Nru a/drivers/pci/hotplug/shpchp_core.c b/drivers/pci/hotplug/shpchp_core.c --- a/drivers/pci/hotplug/shpchp_core.c Mon May 17 16:58:40 2004 +++ b/drivers/pci/hotplug/shpchp_core.c Mon May 17 16:58:40 2004 @@ -90,6 +90,22 @@ .get_cur_bus_speed = get_cur_bus_speed, }; +/** + * release_slot - free up the memory used by a slot + * @hotplug_slot: slot to free + */ +static void release_slot(struct hotplug_slot *hotplug_slot) +{ + struct slot *slot = (struct slot *)hotplug_slot->private; + + 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 int init_slots(struct controller *ctrl) { struct slot *new_slot; @@ -150,7 +166,8 @@ /* register this slot with the hotplug pci core */ 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->release = &release_slot; new_slot->hotplug_slot->ops = &shpchp_hotplug_slot_ops; new_slot->hpc_ops->get_power_status(new_slot, &(new_slot->hotplug_slot->info->power_status)); @@ -178,29 +195,20 @@ slot_number += ctrl->slot_num_inc; } - return(0); + return 0; } - -static int cleanup_slots (struct controller * ctrl) +static void cleanup_slots(const struct controller *ctrl) { - struct slot *old_slot, *next_slot; + struct slot *old_slot; old_slot = ctrl->slot; ctrl->slot = NULL; while (old_slot) { - next_slot = old_slot->next; - pci_hp_deregister (old_slot->hotplug_slot); - kfree(old_slot->hotplug_slot->info); - kfree(old_slot->hotplug_slot->name); - kfree(old_slot->hotplug_slot); - kfree(old_slot); - old_slot = next_slot; + pci_hp_deregister(old_slot->hotplug_slot); + old_slot = old_slot->next; } - - - return(0); } static int get_ctlr_slot_config(struct controller *ctrl)