[PATCH 4/9] powerpc/eeh: Introduce eeh_pe_free()

Gavin Shan shangw at linux.vnet.ibm.com
Tue Feb 25 16:37:45 EST 2014


The patch introduces eeh_pe_free() to replace original kfree(pe)
so that we could have more checks there and calls to platform
interface supplied by eeh_ops in future.

Signed-off-by: Gavin Shan <shangw at linux.vnet.ibm.com>
---
 arch/powerpc/kernel/eeh_pe.c |   25 +++++++++++++++++++++++--
 1 file changed, 23 insertions(+), 2 deletions(-)

diff --git a/arch/powerpc/kernel/eeh_pe.c b/arch/powerpc/kernel/eeh_pe.c
index f0c353f..2add834 100644
--- a/arch/powerpc/kernel/eeh_pe.c
+++ b/arch/powerpc/kernel/eeh_pe.c
@@ -60,6 +60,27 @@ static struct eeh_pe *eeh_pe_alloc(struct pci_controller *phb, int type)
 }
 
 /**
+ * eeh_pe_free - Free PE
+ * @pe: EEH PE
+ *
+ * Free PE instance dynamically
+ */
+static void eeh_pe_free(struct eeh_pe *pe)
+{
+	if (!pe)
+		return;
+
+	if (!list_empty(&pe->child_list) ||
+	    !list_empty(&pe->edevs)) {
+		pr_warn("%s: PHB#%x-PE#%x has child PE or EEH dev\n",
+			__func__, pe->phb->global_number, pe->addr);
+		return;
+	}
+
+	kfree(pe);
+}
+
+/**
  * eeh_phb_pe_create - Create PHB PE
  * @phb: PCI controller
  *
@@ -374,7 +395,7 @@ int eeh_add_to_parent_pe(struct eeh_dev *edev)
 			pr_err("%s: No PHB PE is found (PHB Domain=%d)\n",
 				__func__, edev->phb->global_number);
 			edev->pe = NULL;
-			kfree(pe);
+			eeh_pe_free(pe);
 			return -EEXIST;
 		}
 	}
@@ -433,7 +454,7 @@ int eeh_rmv_from_parent_pe(struct eeh_dev *edev)
 			if (list_empty(&pe->edevs) &&
 			    list_empty(&pe->child_list)) {
 				list_del(&pe->child);
-				kfree(pe);
+				eeh_pe_free(pe);
 			} else {
 				break;
 			}
-- 
1.7.10.4



More information about the Linuxppc-dev mailing list