All of lore.kernel.org
 help / color / mirror / Atom feed
From: Greg KH <greg@kroah.com>
To: linux-kernel@vger.kernel.org, pcihpd-discuss@lists.sourceforge.net
Subject: Re: [PATCH] Yet more PCI fixes for 2.5.73
Date: Thu, 26 Jun 2003 17:51:44 -0700	[thread overview]
Message-ID: <10566751043125@kroah.com> (raw)
In-Reply-To: <1056675104264@kroah.com>

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

[PATCH] PCI Hotplug: cpqphp: add release() callback and other minor cleanups.


 drivers/pci/hotplug/cpqphp_core.c |   38 ++++++++++++++++++++++----------------
 1 files changed, 22 insertions(+), 16 deletions(-)


diff -Nru a/drivers/pci/hotplug/cpqphp_core.c b/drivers/pci/hotplug/cpqphp_core.c
--- a/drivers/pci/hotplug/cpqphp_core.c	Thu Jun 26 17:39:08 2003
+++ b/drivers/pci/hotplug/cpqphp_core.c	Thu Jun 26 17:39:08 2003
@@ -312,6 +312,20 @@
 	return previous;
 }
 
+static void release_slot(struct hotplug_slot *hotplug_slot)
+{
+	struct slot *slot = get_slot (hotplug_slot, __FUNCTION__);
+	
+	if (slot == NULL)
+		return;
+	
+	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 ctrl_slot_setup (struct controller * ctrl, void *smbios_start, void *smbios_table)
 {
@@ -401,6 +415,7 @@
 		new_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;
@@ -415,10 +430,7 @@
 		result = pci_hp_register (new_slot->hotplug_slot);
 		if (result) {
 			err ("pci_hp_register failed with error %d\n", result);
-			kfree (new_slot->hotplug_slot->info);
-			kfree (new_slot->hotplug_slot->name);
-			kfree (new_slot->hotplug_slot);
-			kfree (new_slot);
+			release_slot(new_slot->hotplug_slot);
 			return result;
 		}
 		
@@ -430,10 +442,9 @@
 		slot_number++;
 	}
 
-	return(0);
+	return 0;
 }
 
-
 static int ctrl_slot_cleanup (struct controller * ctrl)
 {
 	struct slot *old_slot, *next_slot;
@@ -442,12 +453,9 @@
 	ctrl->slot = NULL;
 
 	while (old_slot) {
+		/* memory will be freed by the release_slot callback */
 		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;
 	}
 
@@ -498,7 +506,7 @@
 	       sizeof(struct irq_routing_table)) / sizeof(struct irq_info);
 	// Make sure I got at least one entry
 	if (len == 0) {
-		if (PCIIRQRoutingInfoLength != NULL) kfree(PCIIRQRoutingInfoLength );
+		kfree(PCIIRQRoutingInfoLength);
 		return -1;
 	}
 
@@ -509,9 +517,7 @@
 
 		if ((tbus == bus_num) && (tdevice == dev_num)) {
 			*slot = tslot;
-
-			if (PCIIRQRoutingInfoLength != NULL)
-				kfree(PCIIRQRoutingInfoLength);
+			kfree(PCIIRQRoutingInfoLength);
 			return 0;
 		} else {
 			// Didn't get a match on the target PCI device. Check if the
@@ -540,10 +546,10 @@
 	// slot number for the bridge.
 	if (bridgeSlot != 0xFF) {
 		*slot = bridgeSlot;
-		if (PCIIRQRoutingInfoLength != NULL) kfree(PCIIRQRoutingInfoLength );
+		kfree(PCIIRQRoutingInfoLength);
 		return 0;
 	}
-	if (PCIIRQRoutingInfoLength != NULL) kfree(PCIIRQRoutingInfoLength );
+	kfree(PCIIRQRoutingInfoLength);
 	// Couldn't find an entry in the routing table for this PCI device
 	return -1;
 }


  reply	other threads:[~2003-06-27  2:44 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2003-06-27  0:50 [BK PATCH] Yet more PCI fixes for 2.5.73 Greg KH
2003-06-27  0:51 ` [PATCH] " Greg KH
2003-06-27  0:51   ` Greg KH
2003-06-27  0:51     ` Greg KH
2003-06-27  0:51       ` Greg KH [this message]
2003-06-27  0:51         ` Greg KH
2003-06-27  0:51           ` Greg KH
2003-06-27  0:51             ` Greg KH

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=10566751043125@kroah.com \
    --to=greg@kroah.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=pcihpd-discuss@lists.sourceforge.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.