mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Alex Chiang <achiang@hp.com>
To: linux-pci@vger.kernel.org, linux-kernel@vger.kernel.org
Cc: jbarnes@virtuousgeek.org, kristen.c.accardi@intel.com,
	benh@kernel.crashing.org, Alex Chiang <achiang@hp.com>
Subject: [PATCH v2 10/13] PCI: rpaphp: stop managing hotplug_slot->name
Date: Tue, 09 Sep 2008 04:00:52 -0600	[thread overview]
Message-ID: <20080909100052.29542.19510.stgit@bob.kio> (raw)
In-Reply-To: <20080909091813.29542.85613.stgit@bob.kio>

We no longer need to manage our version of hotplug_slot->name
since the PCI and hotplug core manage it on our behalf.

This means that alloc_slot_struct() no longer needs to take
a 'name' param. On the other hand, we give rpaphp_register_slot()
a 'name' param now to simplify the hotplug registration process.
rpaphp_register_slot() can directly pass the drc_name to the
PCI hotplug core.

Cc: jbarnes@virtuousgeek.org
Cc: kristen.c.accardi@intel.com
Cc: benh@kernel.crashing.org
Signed-off-by: Alex Chiang <achiang@hp.com>
---

 drivers/pci/hotplug/rpaphp.h      |   10 +++++++---
 drivers/pci/hotplug/rpaphp_core.c |    6 +++---
 drivers/pci/hotplug/rpaphp_pci.c  |    4 ++--
 drivers/pci/hotplug/rpaphp_slot.c |   26 +++++++++-----------------
 4 files changed, 21 insertions(+), 25 deletions(-)

diff --git a/drivers/pci/hotplug/rpaphp.h b/drivers/pci/hotplug/rpaphp.h
index 7d5921b..12f8aa7 100644
--- a/drivers/pci/hotplug/rpaphp.h
+++ b/drivers/pci/hotplug/rpaphp.h
@@ -73,13 +73,17 @@ struct slot {
 	u32 index;
 	u32 type;
 	u32 power_domain;
-	char *name;
 	struct device_node *dn;
 	struct pci_bus *bus;
 	struct list_head *pci_devs;
 	struct hotplug_slot *hotplug_slot;
 };
 
+static inline const char *slot_name(struct slot *slot)
+{
+	return hotplug_slot_name(slot->hotplug_slot);
+}
+
 extern struct hotplug_slot_ops rpaphp_hotplug_slot_ops;
 extern struct list_head rpaphp_slot_head;
 
@@ -96,8 +100,8 @@ extern int rpaphp_get_drc_props(struct device_node *dn, int *drc_index,
 
 /* rpaphp_slot.c */
 extern void dealloc_slot_struct(struct slot *slot);
-extern struct slot *alloc_slot_struct(struct device_node *dn, int drc_index, char *drc_name, int power_domain);
-extern int rpaphp_register_slot(struct slot *slot);
+extern struct slot *alloc_slot_struct(struct device_node *dn, int drc_index, int power_domain);
+extern int rpaphp_register_slot(struct slot *slot, const char *name);
 extern int rpaphp_deregister_slot(struct slot *slot);
 	
 #endif				/* _PPC64PHP_H */
diff --git a/drivers/pci/hotplug/rpaphp_core.c b/drivers/pci/hotplug/rpaphp_core.c
index 1f84f40..c989005 100644
--- a/drivers/pci/hotplug/rpaphp_core.c
+++ b/drivers/pci/hotplug/rpaphp_core.c
@@ -324,7 +324,7 @@ int rpaphp_add_slot(struct device_node *dn)
 	type = (char *) &types[1];
 	for (i = 0; i < indexes[0]; i++) {
 
-		slot = alloc_slot_struct(dn, indexes[i + 1], name, power_domains[i + 1]);
+		slot = alloc_slot_struct(dn, indexes[i + 1], power_domains[i + 1]);
 		if (!slot)
 			return -ENOMEM;
 
@@ -335,7 +335,7 @@ int rpaphp_add_slot(struct device_node *dn)
 
 		retval = rpaphp_enable_slot(slot);
 		if (!retval)
-			retval = rpaphp_register_slot(slot);
+			retval = rpaphp_register_slot(slot, name);
 
 		if (retval)
 			dealloc_slot_struct(slot);
@@ -404,7 +404,7 @@ static int enable_slot(struct hotplug_slot *hotplug_slot)
 	} else if (state == EMPTY) {
 		slot->state = EMPTY;
 	} else {
-		err("%s: slot[%s] is in invalid state\n", __func__, slot->name);
+		err("%s: slot[%s] is in invalid state\n", __func__, slot_name(slot));
 		slot->state = NOT_VALID;
 		return -EINVAL;
 	}
diff --git a/drivers/pci/hotplug/rpaphp_pci.c b/drivers/pci/hotplug/rpaphp_pci.c
index 5acfd4f..46eed88 100644
--- a/drivers/pci/hotplug/rpaphp_pci.c
+++ b/drivers/pci/hotplug/rpaphp_pci.c
@@ -51,7 +51,7 @@ int rpaphp_get_sensor_state(struct slot *slot, int *state)
 						  &setlevel);
 			if (rc < 0) {
 				dbg("%s: power on slot[%s] failed rc=%d.\n",
-				    __func__, slot->name, rc);
+				    __func__, slot_name(slot), rc);
 			} else {
 				rc = rtas_get_sensor(DR_ENTITY_SENSE,
 						     slot->index, state);
@@ -111,7 +111,7 @@ int rpaphp_enable_slot(struct slot *slot)
 		/* non-empty slot has to have child */
 		if (!slot->dn->child) {
 			err("%s: slot[%s]'s device_node doesn't have child for adapter\n",
-			    __func__, slot->name);
+			    __func__, slot_name(slot));
 			return -EINVAL;
 		}
 
diff --git a/drivers/pci/hotplug/rpaphp_slot.c b/drivers/pci/hotplug/rpaphp_slot.c
index 736d3b4..2d167c3 100644
--- a/drivers/pci/hotplug/rpaphp_slot.c
+++ b/drivers/pci/hotplug/rpaphp_slot.c
@@ -43,13 +43,12 @@ static void rpaphp_release_slot(struct hotplug_slot *hotplug_slot)
 void dealloc_slot_struct(struct slot *slot)
 {
 	kfree(slot->hotplug_slot->info);
-	kfree(slot->hotplug_slot->name);
 	kfree(slot->hotplug_slot);
 	kfree(slot);
 }
 
 struct slot *alloc_slot_struct(struct device_node *dn,
-                       int drc_index, char *drc_name, int power_domain)
+			int drc_index, int power_domain)
 {
 	struct slot *slot;
 	
@@ -63,11 +62,6 @@ struct slot *alloc_slot_struct(struct device_node *dn,
 					   GFP_KERNEL);
 	if (!slot->hotplug_slot->info)
 		goto error_hpslot;
-	slot->hotplug_slot->name = kmalloc(strlen(drc_name) + 1, GFP_KERNEL);
-	if (!slot->hotplug_slot->name)
-		goto error_info;	
-	slot->name = slot->hotplug_slot->name;
-	strcpy(slot->name, drc_name);
 	slot->dn = dn;
 	slot->index = drc_index;
 	slot->power_domain = power_domain;
@@ -77,8 +71,6 @@ struct slot *alloc_slot_struct(struct device_node *dn,
 	
 	return (slot);
 
-error_info:
-	kfree(slot->hotplug_slot->info);
 error_hpslot:
 	kfree(slot->hotplug_slot);
 error_slot:
@@ -92,7 +84,7 @@ static int is_registered(struct slot *slot)
 	struct slot *tmp_slot;
 
 	list_for_each_entry(tmp_slot, &rpaphp_slot_head, rpaphp_slot_list) {
-		if (!strcmp(tmp_slot->name, slot->name))
+		if (!strcmp(slot_name(tmp_slot), slot_name(slot)))
 			return 1;
 	}	
 	return 0;
@@ -104,32 +96,32 @@ int rpaphp_deregister_slot(struct slot *slot)
 	struct hotplug_slot *php_slot = slot->hotplug_slot;
 
 	 dbg("%s - Entry: deregistering slot=%s\n",
-		__func__, slot->name);
+		__func__, slot_name(slot));
 
 	list_del(&slot->rpaphp_slot_list);
 	
 	retval = pci_hp_deregister(php_slot);
 	if (retval)
-		err("Problem unregistering a slot %s\n", slot->name);
+		err("Problem unregistering a slot %s\n", slot_name(slot));
 
 	dbg("%s - Exit: rc[%d]\n", __func__, retval);
 	return retval;
 }
 EXPORT_SYMBOL_GPL(rpaphp_deregister_slot);
 
-int rpaphp_register_slot(struct slot *slot)
+int rpaphp_register_slot(struct slot *slot, const char *name)
 {
 	struct hotplug_slot *php_slot = slot->hotplug_slot;
 	int retval;
 	int slotno;
 
 	dbg("%s registering slot:path[%s] index[%x], name[%s] pdomain[%x] type[%d]\n", 
-		__func__, slot->dn->full_name, slot->index, slot->name,
+		__func__, slot->dn->full_name, slot->index, slot_name(slot),
 		slot->power_domain, slot->type);
 
 	/* should not try to register the same slot twice */
 	if (is_registered(slot)) {
-		err("rpaphp_register_slot: slot[%s] is already registered\n", slot->name);
+		err("rpaphp_register_slot: slot[%s] is already registered\n", slot_name(slot));
 		return -EAGAIN;
 	}	
 
@@ -137,7 +129,7 @@ int rpaphp_register_slot(struct slot *slot)
 		slotno = PCI_SLOT(PCI_DN(slot->dn->child)->devfn);
 	else
 		slotno = -1;
-	retval = pci_hp_register(php_slot, slot->bus, slotno, slot->name);
+	retval = pci_hp_register(php_slot, slot->bus, slotno, name);
 	if (retval) {
 		err("pci_hp_register failed with error %d\n", retval);
 		return retval;
@@ -145,7 +137,7 @@ int rpaphp_register_slot(struct slot *slot)
 
 	/* add slot to our internal list */
 	list_add(&slot->rpaphp_slot_list, &rpaphp_slot_head);
-	info("Slot [%s] registered\n", slot->name);
+	info("Slot [%s] registered\n", name);
 	return 0;
 }
 


  parent reply	other threads:[~2008-09-09 10:03 UTC|newest]

Thread overview: 55+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-08-17  0:14 [PATCH 00/13] PCI: let the core manage slot names Alex Chiang
2008-08-17  0:15 ` [PATCH 01/13] PCI Hotplug core: add 'name' param pci_hp_register interface Alex Chiang
2008-08-17  0:16 ` [PATCH 02/13] PCI: prevent duplicate slot names Alex Chiang
2008-08-21 10:24   ` Kenji Kaneshige
2008-09-09  9:04     ` Alex Chiang
2008-09-11  2:43       ` Kenji Kaneshige
2008-09-09 10:00         ` [PATCH v2 00/13] PCI: let the core manage " Alex Chiang
2008-09-09 10:00           ` [PATCH v2 01/13] PCI Hotplug core: add 'name' param pci_hp_register interface Alex Chiang
2008-09-09 12:05             ` Matthew Wilcox
2008-09-09 17:18               ` Alex Chiang
2008-09-09 10:00           ` [PATCH v2 02/13] PCI: prevent duplicate slot names Alex Chiang
2008-09-09 13:07             ` Matthew Wilcox
2008-09-22 21:38               ` Alex Chiang
2008-09-22 22:42                 ` Matthew Wilcox
2008-09-10 14:58             ` Rolf Eike Beer
2008-09-22 21:40               ` Alex Chiang
2008-09-11  2:47             ` Kenji Kaneshige
2008-09-11 10:37               ` Alex Chiang
2008-09-23  0:05               ` Alex Chiang
2008-09-09 10:00           ` [PATCH v2 03/13] PCI, PCI Hotplug: introduce slot_name helpers Alex Chiang
2008-09-09 14:30             ` Matthew Wilcox
2008-09-09 10:00           ` [PATCH v2 04/13] PCI: acpiphp: remove 'name' parameter Alex Chiang
2008-09-09 14:38             ` Matthew Wilcox
2008-09-23  1:16               ` Alex Chiang
2008-09-09 10:00           ` [PATCH v2 05/13] PCI: cpci_hotplug: stop managing hotplug_slot->name Alex Chiang
2008-09-09 15:04             ` Matthew Wilcox
2008-09-09 21:11               ` Scott Murray
2008-09-09 10:00           ` [PATCH v2 06/13] PCI: cpqphp: " Alex Chiang
2008-09-09 15:08             ` Matthew Wilcox
2008-09-23  1:20               ` Alex Chiang
2008-09-09 10:00           ` [PATCH v2 07/13] PCI: fakephp: remove 'name' parameter Alex Chiang
2008-09-09 10:00           ` [PATCH v2 08/13] PCI: ibmphp: stop managing hotplug_slot->name Alex Chiang
2008-09-09 10:00           ` [PATCH v2 09/13] PCI: pciehp: remove 'name' parameter Alex Chiang
2008-09-09 10:00           ` Alex Chiang [this message]
2008-09-09 10:00           ` [PATCH v2 11/13] PCI: SGI Hotplug: stop managing bss_hotplug_slot->name Alex Chiang
2008-09-09 10:01           ` [PATCH v2 12/13] PCI: shcphp: remove 'name' parameter Alex Chiang
2008-09-09 10:01           ` [PATCH v2 13/13] PCI: Hotplug core: remove 'name' Alex Chiang
2008-08-17  0:16 ` [PATCH 03/13] PCI, PCI Hotplug: introduce slot_name helpers Alex Chiang
2008-08-17  0:16 ` [PATCH 04/13] PCI: acpiphp: remove 'name' parameter Alex Chiang
2008-08-17  8:59   ` Rolf Eike Beer
2008-08-19 18:39     ` Alex Chiang
2008-08-19 21:01       ` Rolf Eike Beer
2008-08-19 21:26         ` Alex Chiang
2008-08-19 21:40       ` Jesse Barnes
2008-08-19 23:50         ` Alex Chiang
2008-08-20  2:25           ` Kenji Kaneshige
2008-08-17  0:16 ` [PATCH 05/13] PCI: cpci_hotplug: stop managing hotplug_slot->name Alex Chiang
2008-08-17  0:16 ` [PATCH 06/13] PCI: cpqphp: " Alex Chiang
2008-08-17  0:17 ` [PATCH 07/13] PCI: fakephp: remove 'name' parameter Alex Chiang
2008-08-17  0:17 ` [PATCH 08/13] PCI: ibmphp: stop managing hotplug_slot->name Alex Chiang
2008-08-17  0:17 ` [PATCH 09/13] PCI: pciehp: remove 'name' parameter Alex Chiang
2008-08-17  0:17 ` [PATCH 10/13] PCI: rpaphp: stop managing hotplug_slot->name Alex Chiang
2008-08-17  0:17 ` [PATCH 11/13] PCI: SGI Hotplug: stop managing bss_hotplug_slot->name Alex Chiang
2008-08-17  0:17 ` [PATCH 12/13] PCI: shcphp: remove 'name' parameter Alex Chiang
2008-08-17  0:17 ` [PATCH 13/13] PCI: Hotplug core: remove 'name' Alex Chiang

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=20080909100052.29542.19510.stgit@bob.kio \
    --to=achiang@hp.com \
    --cc=benh@kernel.crashing.org \
    --cc=jbarnes@virtuousgeek.org \
    --cc=kristen.c.accardi@intel.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pci@vger.kernel.org \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

Powered by JetHome