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 1/7] acpiphp: convert to a kmalloc'ed slot name
Date: Tue, 5 Aug 2008 23:10:57 -0600 [thread overview]
Message-ID: <20080806051057.GB31319@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/acpiphp.h | 2 +-
drivers/pci/hotplug/acpiphp_core.c | 17 ++++++++++-------
2 files changed, 11 insertions(+), 8 deletions(-)
diff --git a/drivers/pci/hotplug/acpiphp.h b/drivers/pci/hotplug/acpiphp.h
index 5a58b07..2ac519d 100644
--- a/drivers/pci/hotplug/acpiphp.h
+++ b/drivers/pci/hotplug/acpiphp.h
@@ -63,7 +63,7 @@ struct slot {
struct hotplug_slot *hotplug_slot;
struct acpiphp_slot *acpi_slot;
struct hotplug_slot_info info;
- char name[SLOT_NAME_SIZE];
+ char *name;
};
/*
diff --git a/drivers/pci/hotplug/acpiphp_core.c b/drivers/pci/hotplug/acpiphp_core.c
index 0e496e8..ec164f4 100644
--- a/drivers/pci/hotplug/acpiphp_core.c
+++ b/drivers/pci/hotplug/acpiphp_core.c
@@ -301,6 +301,7 @@ static void release_slot(struct hotplug_slot *hotplug_slot)
dbg("%s - physical_slot = %s\n", __func__, hotplug_slot->name);
+ kfree(slot->name);
kfree(slot->hotplug_slot);
kfree(slot);
}
@@ -315,9 +316,13 @@ int acpiphp_register_hotplug_slot(struct acpiphp_slot *acpiphp_slot)
if (!slot)
goto error;
+ slot->name = kzalloc(SLOT_NAME_SIZE, GFP_KERNEL);
+ if (!slot->name)
+ goto error_slot;
+
slot->hotplug_slot = kzalloc(sizeof(*slot->hotplug_slot), GFP_KERNEL);
if (!slot->hotplug_slot)
- goto error_slot;
+ goto error_name;
slot->hotplug_slot->info = &slot->info;
@@ -336,23 +341,21 @@ int acpiphp_register_hotplug_slot(struct acpiphp_slot *acpiphp_slot)
slot->hotplug_slot->info->cur_bus_speed = PCI_SPEED_UNKNOWN;
acpiphp_slot->slot = slot;
- snprintf(slot->name, sizeof(slot->name), "%u", slot->acpi_slot->sun);
+ snprintf(slot->name, SLOT_NAME_SIZE, "%u", slot->acpi_slot->sun);
retval = pci_hp_register(slot->hotplug_slot,
acpiphp_slot->bridge->pci_bus,
acpiphp_slot->device);
- if (retval == -EBUSY)
- goto error_hpslot;
- if (retval) {
- err("pci_hp_register failed with error %d\n", retval);
+ if (retval)
goto error_hpslot;
- }
info("Slot [%s] registered\n", slot->hotplug_slot->name);
return 0;
error_hpslot:
kfree(slot->hotplug_slot);
+error_name:
+ kfree(slot->name);
error_slot:
kfree(slot);
error:
--
1.6.0.rc0.g95f8
next prev 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 ` Alex Chiang [this message]
2008-08-06 5:11 ` [PATCH 2/7] fakephp: convert to a kmalloc'ed slot name 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 ` [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=20080806051057.GB31319@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®