[PATCH] Yet more PCI fixes for 2.5.73

Greg KH (greg@kroah.com)
Thu, 26 Jun 2003 17:51:43 -0700


ChangeSet 1.1498, 2003/06/26 16:04:05-07:00, greg@kroah.com

[PATCH] PCI Hotplug: pcihp_skeleton: fix delete bug and add release() callback

drivers/pci/hotplug/pcihp_skeleton.c | 42 ++++++++++++++++++++++-------------
1 files changed, 27 insertions(+), 15 deletions(-)

diff -Nru a/drivers/pci/hotplug/pcihp_skeleton.c b/drivers/pci/hotplug/pcihp_skeleton.c
--- a/drivers/pci/hotplug/pcihp_skeleton.c Thu Jun 26 17:39:24 2003
+++ b/drivers/pci/hotplug/pcihp_skeleton.c Thu Jun 26 17:39:24 2003
@@ -1,8 +1,8 @@
/*
- * PCI Hot Plug Controller Skeleton Driver - 0.1
+ * PCI Hot Plug Controller Skeleton Driver - 0.2
*
- * Copyright (c) 2001 Greg Kroah-Hartman (greg@kroah.com)
- * Copyright (c) 2001 IBM Corp.
+ * Copyright (c) 2001,2003 Greg Kroah-Hartman (greg@kroah.com)
+ * Copyright (c) 2001,2003 IBM Corp.
*
* All rights reserved.
*
@@ -69,7 +69,7 @@
static int debug;
static int num_slots;

-#define DRIVER_VERSION "0.1"
+#define DRIVER_VERSION "0.2"
#define DRIVER_AUTHOR "Greg Kroah-Hartman <greg@kroah.com>"
#define DRIVER_DESC "Hot Plug PCI Controller Skeleton Driver"

@@ -288,6 +288,21 @@
return retval;
}

+static void release_slots(struct hotplug_slot *hotplug_slot)
+{
+ struct slot *slot = get_slot(hotplug_slot, __FUNCTION__);
+ int retval = 0;
+
+ if (slot == NULL)
+ return -ENODEV;
+
+ dbg(__FUNCTION__" - physical_slot = %s\n", hotplug_slot->name);
+ kfree(slot->hotplug_slot->info);
+ kfree(slot->hotplug_slot->name);
+ kfree(slot->hotplug_slot);
+ kfree(slot);
+}
+
#define SLOT_NAME_SIZE 10
static void make_slot_name (struct slot *slot)
{
@@ -347,6 +362,7 @@
slot->number = i;

hotplug_slot->private = slot;
+ hotplug_slot->release = &release_slot;
make_slot_name (slot);
hotplug_slot->ops = &skel_hotplug_slot_ops;

@@ -376,27 +392,23 @@

return retval;
}
-
-static void cleanup_slots (void)
+
+static void cleanup_slots(void)
{
struct list_head *tmp;
+ struct list_head *next;
struct slot *slot;

/*
- * Unregister all of our slots with the pci_hotplug subsystem,
- * and free up all memory that we had allocated.
+ * Unregister all of our slots with the pci_hotplug subsystem.
+ * Memory will be freed in release_slot() callback after slot's
+ * lifespan is finished.
*/
- list_for_each (tmp, &slot_list) {
+ list_for_each_safe (tmp, next, &slot_list) {
slot = list_entry (tmp, struct slot, slot_list);
list_del (&slot->slot_list);
pci_hp_deregister (slot->hotplug_slot);
- kfree (slot->hotplug_slot->info);
- kfree (slot->hotplug_slot->name);
- kfree (slot->hotplug_slot);
- kfree (slot);
}
-
- return;
}

static int __init pcihp_skel_init(void)

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/