Skip to content

Commit 1dc9b70

Browse files
qcao-zztorvalds
authored andcommitted
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. [[email protected]: cleanups] Signed-off-by: Harry Ciao <[email protected]> Cc: Doug Thompson <[email protected]> Cc: Michael Ellerman <[email protected]> Cc: Benjamin Herrenschmidt <[email protected]> Cc: Kumar Gala <[email protected]> Cc: Paul Mackerras <[email protected]> Signed-off-by: Andrew Morton <[email protected]> Signed-off-by: Linus Torvalds <[email protected]>
1 parent 2a9036a commit 1dc9b70

File tree

3 files changed

+16
-2
lines changed

3 files changed

+16
-2
lines changed

drivers/edac/amd8111_edac.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,6 @@
3737
#define AMD8111_EDAC_MOD_STR "amd8111_edac"
3838

3939
#define PCI_DEVICE_ID_AMD_8111_PCI 0x7460
40-
static int edac_dev_idx;
4140

4241
enum amd8111_edac_devs {
4342
LPC_BRIDGE = 0,
@@ -377,7 +376,7 @@ static int amd8111_dev_probe(struct pci_dev *dev,
377376
* edac_device_ctl_info, but make use of existing
378377
* one instead.
379378
*/
380-
dev_info->edac_idx = edac_dev_idx++;
379+
dev_info->edac_idx = edac_device_alloc_index();
381380
dev_info->edac_dev =
382381
edac_device_alloc_ctl_info(0, dev_info->ctl_name, 1,
383382
NULL, 0, 0,

drivers/edac/edac_core.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -841,6 +841,7 @@ extern void edac_device_handle_ue(struct edac_device_ctl_info *edac_dev,
841841
int inst_nr, int block_nr, const char *msg);
842842
extern void edac_device_handle_ce(struct edac_device_ctl_info *edac_dev,
843843
int inst_nr, int block_nr, const char *msg);
844+
extern int edac_device_alloc_index(void);
844845

845846
/*
846847
* edac_pci APIs

drivers/edac/edac_device.c

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -490,6 +490,20 @@ void edac_device_reset_delay_period(struct edac_device_ctl_info *edac_dev,
490490
mutex_unlock(&device_ctls_mutex);
491491
}
492492

493+
/*
494+
* edac_device_alloc_index: Allocate a unique device index number
495+
*
496+
* Return:
497+
* allocated index number
498+
*/
499+
int 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+
}
505+
EXPORT_SYMBOL_GPL(edac_device_alloc_index);
506+
493507
/**
494508
* edac_device_add_device: Insert the 'edac_dev' structure into the
495509
* edac_device global list and create sysfs entries associated with

0 commit comments

Comments
 (0)