diff options
| author | Hidetoshi Seto <seto.hidetoshi@jp.fujitsu.com> | 2010-08-20 03:24:44 -0400 |
|---|---|---|
| committer | Mauro Carvalho Chehab <mchehab@redhat.com> | 2010-10-24 09:20:38 -0400 |
| commit | 848b2f7ed6db4d3a83201187159665cc57725d9f (patch) | |
| tree | 336f5b94a2294f8613b43b0a7694fb17ac6fa136 | |
| parent | b197cba071ec8a171fbaaaf82d119315a6f6cb0b (diff) | |
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>
| -rw-r--r-- | drivers/edac/i7core_edac.c | 34 |
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) | |||
| 447 | return NULL; | 447 | return NULL; |
| 448 | } | 448 | } |
| 449 | 449 | ||
| 450 | static struct i7core_dev *alloc_i7core_dev(u8 socket, | ||
| 451 | const struct pci_id_table *table) | ||
| 452 | { | ||
| 453 | struct i7core_dev *i7core_dev; | ||
| 454 | |||
| 455 | i7core_dev = kzalloc(sizeof(*i7core_dev), GFP_KERNEL); | ||
| 456 | if (!i7core_dev) | ||
| 457 | return NULL; | ||
| 458 | |||
| 459 | i7core_dev->pdev = kzalloc(sizeof(*i7core_dev->pdev) * table->n_devs, | ||
| 460 | GFP_KERNEL); | ||
| 461 | if (!i7core_dev->pdev) { | ||
| 462 | kfree(i7core_dev); | ||
| 463 | return NULL; | ||
| 464 | } | ||
| 465 | |||
| 466 | i7core_dev->socket = socket; | ||
| 467 | i7core_dev->n_devs = table->n_devs; | ||
| 468 | list_add_tail(&i7core_dev->list, &i7core_edac_list); | ||
| 469 | |||
| 470 | return i7core_dev; | ||
| 471 | } | ||
| 472 | |||
| 450 | /**************************************************************************** | 473 | /**************************************************************************** |
| 451 | Memory check routines | 474 | Memory check routines |
| 452 | ****************************************************************************/ | 475 | ****************************************************************************/ |
| @@ -1355,18 +1378,9 @@ static int i7core_get_onedevice(struct pci_dev **prev, | |||
| 1355 | 1378 | ||
| 1356 | i7core_dev = get_i7core_dev(socket); | 1379 | i7core_dev = get_i7core_dev(socket); |
| 1357 | if (!i7core_dev) { | 1380 | if (!i7core_dev) { |
| 1358 | i7core_dev = kzalloc(sizeof(*i7core_dev), GFP_KERNEL); | 1381 | i7core_dev = alloc_i7core_dev(socket, table); |
| 1359 | if (!i7core_dev) | 1382 | if (!i7core_dev) |
| 1360 | return -ENOMEM; | 1383 | return -ENOMEM; |
| 1361 | i7core_dev->pdev = kzalloc(sizeof(*i7core_dev->pdev) | ||
| 1362 | * table->n_devs, GFP_KERNEL); | ||
| 1363 | if (!i7core_dev->pdev) { | ||
| 1364 | kfree(i7core_dev); | ||
| 1365 | return -ENOMEM; | ||
| 1366 | } | ||
| 1367 | i7core_dev->socket = socket; | ||
| 1368 | i7core_dev->n_devs = table->n_devs; | ||
| 1369 | list_add_tail(&i7core_dev->list, &i7core_edac_list); | ||
| 1370 | } | 1384 | } |
| 1371 | 1385 | ||
| 1372 | if (i7core_dev->pdev[devno]) { | 1386 | if (i7core_dev->pdev[devno]) { |
