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 6/7] pci_slot: convert to a kmalloc'ed slot name
Date: Tue, 5 Aug 2008 23:12:17 -0600 [thread overview]
Message-ID: <20080806051217.GG31319@ldl.fc.hp.com> (raw)
In-Reply-To: <20080806050745.GA31319@ldl.fc.hp.com>
Callers of pci_create_slot() 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/acpi/pci_slot.c | 14 ++++++++++++--
1 files changed, 12 insertions(+), 2 deletions(-)
diff --git a/drivers/acpi/pci_slot.c b/drivers/acpi/pci_slot.c
index d5b4ef8..b146b72 100644
--- a/drivers/acpi/pci_slot.c
+++ b/drivers/acpi/pci_slot.c
@@ -133,7 +133,7 @@ register_slot(acpi_handle handle, u32 lvl, void *context, void **rv)
{
int device;
unsigned long sun;
- char name[SLOT_NAME_SIZE];
+ char *name;
struct acpi_pci_slot *slot;
struct pci_slot *pci_slot;
struct callback_args *parent_context = context;
@@ -149,10 +149,18 @@ register_slot(acpi_handle handle, u32 lvl, void *context, void **rv)
return AE_OK;
}
- snprintf(name, sizeof(name), "%u", (u32)sun);
+ name = kzalloc(SLOT_NAME_SIZE, GFP_KERNEL);
+ if (!name) {
+ err("%s: cannot allocate memory for name\n", __func__);
+ kfree(slot);
+ return AE_OK;
+ }
+
+ snprintf(name, SLOT_NAME_SIZE, "%u", (u32)sun);
pci_slot = pci_create_slot(pci_bus, device, name);
if (IS_ERR(pci_slot)) {
err("pci_create_slot returned %ld\n", PTR_ERR(pci_slot));
+ kfree(name);
kfree(slot);
return AE_OK;
}
@@ -167,6 +175,8 @@ register_slot(acpi_handle handle, u32 lvl, void *context, void **rv)
dbg("pci_slot: %p, pci_bus: %x, device: %d, name: %s\n",
pci_slot, pci_bus->number, device, name);
+ kfree(name);
+
return AE_OK;
}
--
1.6.0.rc0.g95f8
next prev parent reply other threads:[~2008-08-06 5:13 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 ` [PATCH 2/7] fakephp: " Alex Chiang
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 ` Alex Chiang [this message]
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=20080806051217.GG31319@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.