All of lore.kernel.org
 help / color / mirror / Atom feed
From: Alex Chiang <achiang@hp.com>
To: Kenji Kaneshige <kaneshige.kenji@jp.fujitsu.com>,
	Matthew Wilcox <matthew@wil.cx>,
	Pierre Ossman <drzeus-list@drzeus.cx>,
	Jesse Barnes <jbarnes@virtuousgeek.org>,
	LKML <linux-kernel@vger.kernel.org>,
	linux-pci@vger.kernel.org
Subject: [PATCH 2/7] fakephp: convert to a kmalloc'ed slot name
Date: Tue, 5 Aug 2008 23:11:11 -0600	[thread overview]
Message-ID: <20080806051111.GC31319@ldl.fc.hp.com> (raw)
In-Reply-To: <20080806050745.GA31319@ldl.fc.hp.com>


Callers of pci_hp_register() need to be converted from a
char name[] to a char *name.

This change allows pci_create_slot() to dynamically rename the
sysfs name of the slot in the event of a name collision.

Signed-off-by: Alex Chiang <achiang@hp.com>
---
 drivers/pci/hotplug/fakephp.c |   15 ++++++++++++---
 1 files changed, 12 insertions(+), 3 deletions(-)

diff --git a/drivers/pci/hotplug/fakephp.c b/drivers/pci/hotplug/fakephp.c
index 40337a0..af8a1bf 100644
--- a/drivers/pci/hotplug/fakephp.c
+++ b/drivers/pci/hotplug/fakephp.c
@@ -60,13 +60,15 @@
 #define DRIVER_AUTHOR	"Greg Kroah-Hartman <greg@kroah.com>"
 #define DRIVER_DESC	"Fake PCI Hot Plug Controller Driver"
 
+#define SLOT_NAME_SIZE	8
+
 struct dummy_slot {
 	struct list_head node;
 	struct hotplug_slot *slot;
 	struct pci_dev *dev;
 	struct work_struct remove_work;
 	unsigned long removed;
-	char name[8];
+	char *name;
 };
 
 static int debug;
@@ -91,6 +93,7 @@ static void dummy_release(struct hotplug_slot *slot)
 
 	list_del(&dslot->node);
 	kfree(dslot->slot->info);
+	kfree(dslot->name);
 	kfree(dslot->slot);
 	pci_dev_put(dslot->dev);
 	kfree(dslot);
@@ -119,8 +122,12 @@ static int add_slot(struct pci_dev *dev)
 	if (!dslot)
 		goto error_info;
 
+	dslot->name = kzalloc(SLOT_NAME_SIZE, GFP_KERNEL);
+	if (!dslot->name)
+		goto error_dslot;
+
 	slot->name = dslot->name;
-	snprintf(slot->name, sizeof(dslot->name), "fake%d", count++);
+	snprintf(slot->name, SLOT_NAME_SIZE, "fake%d", count++);
 	dbg("slot->name = %s\n", slot->name);
 	slot->ops = &dummy_hotplug_slot_ops;
 	slot->release = &dummy_release;
@@ -129,7 +136,7 @@ static int add_slot(struct pci_dev *dev)
 	retval = pci_hp_register(slot, dev->bus, PCI_SLOT(dev->devfn));
 	if (retval) {
 		err("pci_hp_register failed with error %d\n", retval);
-		goto error_dslot;
+		goto error_name;
 	}
 
 	dslot->slot = slot;
@@ -137,6 +144,8 @@ static int add_slot(struct pci_dev *dev)
 	list_add (&dslot->node, &slot_list);
 	return retval;
 
+error_name:
+	kfree(dslot->name);
 error_dslot:
 	kfree(dslot);
 error_info:
-- 
1.6.0.rc0.g95f8


  parent reply	other threads:[~2008-08-06  5:11 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-08-06  5:07 [PATCH 0/7] Fixups for duplicate slot names Alex Chiang
2008-08-06  5:10 ` [PATCH 1/7] acpiphp: convert to a kmalloc'ed slot name Alex Chiang
2008-08-06  5:11 ` Alex Chiang [this message]
2008-08-06  5:11 ` [PATCH 3/7] pciehp: " Alex Chiang
2008-08-06  5:11 ` [PATCH 4/7] PCI hotplug: convert skeleton code " Alex Chiang
2008-08-06  5:11 ` [PATCH 5/7] shpchp: convert " Alex Chiang
2008-08-06  5:12 ` [PATCH 6/7] pci_slot: " Alex Chiang
2008-08-06  5:12 ` [PATCH 7/7] PCI Hotplug core: fixups for duplicate slot names Alex Chiang
2008-08-07  8:43 ` [PATCH 0/7] Fixups " Kenji Kaneshige
2008-08-07 17:25   ` Alex Chiang
2008-08-11  1:19     ` Kenji Kaneshige

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=20080806051111.GC31319@ldl.fc.hp.com \
    --to=achiang@hp.com \
    --cc=drzeus-list@drzeus.cx \
    --cc=jbarnes@virtuousgeek.org \
    --cc=kaneshige.kenji@jp.fujitsu.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pci@vger.kernel.org \
    --cc=matthew@wil.cx \
    /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.