summaryrefslogtreecommitdiff
path: root/drivers/edac
diff options
context:
space:
mode:
authorHidetoshi Seto <seto.hidetoshi@jp.fujitsu.com>2010-08-20 11:24:44 +0400
committerMauro Carvalho Chehab <mchehab@redhat.com>2010-10-24 17:20:38 +0400
commit848b2f7ed6db4d3a83201187159665cc57725d9f (patch)
tree336f5b94a2294f8613b43b0a7694fb17ac6fa136 /drivers/edac
parentb197cba071ec8a171fbaaaf82d119315a6f6cb0b (diff)
downloadlinux-848b2f7ed6db4d3a83201187159665cc57725d9f.tar.xz
i7core_edac: Introduce alloc_i7core_dev
It's nice to have a method for a single purpose. Signed-off-by: Hidetoshi Seto <seto.hidetoshi@jp.fujitsu.com> Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
Diffstat (limited to 'drivers/edac')
-rw-r--r--drivers/edac/i7core_edac.c34
1 files changed, 24 insertions, 10 deletions
diff --git a/drivers/edac/i7core_edac.c b/drivers/edac/i7core_edac.c
index 567ee18d9d3f..c4fa112271e5 100644
--- a/drivers/edac/i7core_edac.c
+++ b/drivers/edac/i7core_edac.c
@@ -447,6 +447,29 @@ static struct i7core_dev *get_i7core_dev(u8 socket)
return NULL;
}
+static struct i7core_dev *alloc_i7core_dev(u8 socket,
+ const struct pci_id_table *table)
+{
+ struct i7core_dev *i7core_dev;
+
+ i7core_dev = kzalloc(sizeof(*i7core_dev), GFP_KERNEL);
+ if (!i7core_dev)
+ return NULL;
+
+ i7core_dev->pdev = kzalloc(sizeof(*i7core_dev->pdev) * table->n_devs,
+ GFP_KERNEL);
+ if (!i7core_dev->pdev) {
+ kfree(i7core_dev);
+ return NULL;
+ }
+
+ i7core_dev->socket = socket;
+ i7core_dev->n_devs = table->n_devs;
+ list_add_tail(&i7core_dev->list, &i7core_edac_list);
+
+ return i7core_dev;
+}
+
/****************************************************************************
Memory check routines
****************************************************************************/
@@ -1355,18 +1378,9 @@ static int i7core_get_onedevice(struct pci_dev **prev,
i7core_dev = get_i7core_dev(socket);
if (!i7core_dev) {
- i7core_dev = kzalloc(sizeof(*i7core_dev), GFP_KERNEL);
+ i7core_dev = alloc_i7core_dev(socket, table);
if (!i7core_dev)
return -ENOMEM;
- i7core_dev->pdev = kzalloc(sizeof(*i7core_dev->pdev)
- * table->n_devs, GFP_KERNEL);
- if (!i7core_dev->pdev) {
- kfree(i7core_dev);
- return -ENOMEM;
- }
- i7core_dev->socket = socket;
- i7core_dev->n_devs = table->n_devs;
- list_add_tail(&i7core_dev->list, &i7core_edac_list);
}
if (i7core_dev->pdev[devno]) {