lkml.org 
[lkml]   [2008]   [Aug]   [6]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
Date
From
Subject[PATCH 2/7] fakephp: convert to a kmalloc'ed slot name

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


\
 
 \ /
  Last update: 2008-08-06 07:15    [W:0.109 / U:1.156 seconds]
©2003-2018 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site