aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authorHarry Ciao <qingtao.cao@windriver.com>2009-06-17 19:27:59 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2009-06-18 16:03:56 -0400
commit1dc9b70d7d48abd8a5c6f83021f38992f3b5a77f (patch)
treef4e3544c20b432d727a1c96f80eafb716a0f5966 /drivers
parent2a9036afffb3a174e980f90eb507c5aea6b540f6 (diff)
edac: add edac_device_alloc_index()
Add edac_device_alloc_index(), because for MAPLE platform there may exist several EDAC driver modules that could make use of edac_device_ctl_info structure at the same time. The index allocation for these structures should be taken care of by EDAC core. [akpm@linux-foundation.org: cleanups] Signed-off-by: Harry Ciao <qingtao.cao@windriver.com> Cc: Doug Thompson <norsk5@yahoo.com> Cc: Michael Ellerman <michael@ellerman.id.au> Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org> Cc: Kumar Gala <galak@gate.crashing.org> Cc: Paul Mackerras <paulus@samba.org> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/edac/amd8111_edac.c3
-rw-r--r--drivers/edac/edac_core.h1
-rw-r--r--drivers/edac/edac_device.c14
3 files changed, 16 insertions, 2 deletions
diff --git a/drivers/edac/amd8111_edac.c b/drivers/edac/amd8111_edac.c
index 2cb58ef743e0..35b78d04bbfa 100644
--- a/drivers/edac/amd8111_edac.c
+++ b/drivers/edac/amd8111_edac.c
@@ -37,7 +37,6 @@
37#define AMD8111_EDAC_MOD_STR "amd8111_edac" 37#define AMD8111_EDAC_MOD_STR "amd8111_edac"
38 38
39#define PCI_DEVICE_ID_AMD_8111_PCI 0x7460 39#define PCI_DEVICE_ID_AMD_8111_PCI 0x7460
40static int edac_dev_idx;
41 40
42enum amd8111_edac_devs { 41enum amd8111_edac_devs {
43 LPC_BRIDGE = 0, 42 LPC_BRIDGE = 0,
@@ -377,7 +376,7 @@ static int amd8111_dev_probe(struct pci_dev *dev,
377 * edac_device_ctl_info, but make use of existing 376 * edac_device_ctl_info, but make use of existing
378 * one instead. 377 * one instead.
379 */ 378 */
380 dev_info->edac_idx = edac_dev_idx++; 379 dev_info->edac_idx = edac_device_alloc_index();
381 dev_info->edac_dev = 380 dev_info->edac_dev =
382 edac_device_alloc_ctl_info(0, dev_info->ctl_name, 1, 381 edac_device_alloc_ctl_info(0, dev_info->ctl_name, 1,
383 NULL, 0, 0, 382 NULL, 0, 0,
diff --git a/drivers/edac/edac_core.h b/drivers/edac/edac_core.h
index 48d3b1409834..3493c6bdb820 100644
--- a/drivers/edac/edac_core.h
+++ b/drivers/edac/edac_core.h
@@ -841,6 +841,7 @@ extern void edac_device_handle_ue(struct edac_device_ctl_info *edac_dev,
841 int inst_nr, int block_nr, const char *msg); 841 int inst_nr, int block_nr, const char *msg);
842extern void edac_device_handle_ce(struct edac_device_ctl_info *edac_dev, 842extern void edac_device_handle_ce(struct edac_device_ctl_info *edac_dev,
843 int inst_nr, int block_nr, const char *msg); 843 int inst_nr, int block_nr, const char *msg);
844extern int edac_device_alloc_index(void);
844 845
845/* 846/*
846 * edac_pci APIs 847 * edac_pci APIs
diff --git a/drivers/edac/edac_device.c b/drivers/edac/edac_device.c
index a7d2c717d033..b02a6a69a8f0 100644
--- a/drivers/edac/edac_device.c
+++ b/drivers/edac/edac_device.c
@@ -490,6 +490,20 @@ void edac_device_reset_delay_period(struct edac_device_ctl_info *edac_dev,
490 mutex_unlock(&device_ctls_mutex); 490 mutex_unlock(&device_ctls_mutex);
491} 491}
492 492
493/*
494 * edac_device_alloc_index: Allocate a unique device index number
495 *
496 * Return:
497 * allocated index number
498 */
499int edac_device_alloc_index(void)
500{
501 static atomic_t device_indexes = ATOMIC_INIT(0);
502
503 return atomic_inc_return(&device_indexes) - 1;
504}
505EXPORT_SYMBOL_GPL(edac_device_alloc_index);
506
493/** 507/**
494 * edac_device_add_device: Insert the 'edac_dev' structure into the 508 * edac_device_add_device: Insert the 'edac_dev' structure into the
495 * edac_device global list and create sysfs entries associated with 509 * edac_device global list and create sysfs entries associated with