From patchwork Mon Apr 13 06:05:15 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: qingtao.cao@windriver.com X-Patchwork-Id: 25895 Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from ozlabs.org (localhost [127.0.0.1]) by ozlabs.org (Postfix) with ESMTP id E0E6FDE21C for ; Mon, 13 Apr 2009 16:12:32 +1000 (EST) X-Original-To: linuxppc-dev@ozlabs.org Delivered-To: linuxppc-dev@ozlabs.org Received: from mail.wrs.com (mail.windriver.com [147.11.1.11]) by ozlabs.org (Postfix) with ESMTP id B4DAFDDFD5 for ; Mon, 13 Apr 2009 16:11:31 +1000 (EST) Received: from ALA-MAIL03.corp.ad.wrs.com (ala-mail03 [147.11.57.144]) by mail.wrs.com (8.13.6/8.13.6) with ESMTP id n3D6BBK0014212; Sun, 12 Apr 2009 23:11:11 -0700 (PDT) Received: from ala-mail06.corp.ad.wrs.com ([147.11.57.147]) by ALA-MAIL03.corp.ad.wrs.com with Microsoft SMTPSVC(6.0.3790.1830); Sun, 12 Apr 2009 23:11:10 -0700 Received: from localhost.localdomain ([128.224.159.147]) by ala-mail06.corp.ad.wrs.com with Microsoft SMTPSVC(6.0.3790.1830); Sun, 12 Apr 2009 23:11:10 -0700 From: Harry Ciao To: norsk5@yahoo.com, michael@ellerman.id.au, bluesmoke-devel@lists.sourceforge.net, linuxppc-dev@ozlabs.org Subject: [v2 PATCH 2/3] EDAC: Add edac_device_alloc_index() Date: Mon, 13 Apr 2009 14:05:15 +0800 Message-Id: <1239602716-18352-3-git-send-email-qingtao.cao@windriver.com> X-Mailer: git-send-email 1.5.6.2 In-Reply-To: <1239602716-18352-2-git-send-email-qingtao.cao@windriver.com> References: <1239602716-18352-1-git-send-email-qingtao.cao@windriver.com> <1239602716-18352-2-git-send-email-qingtao.cao@windriver.com> X-OriginalArrivalTime: 13 Apr 2009 06:11:11.0030 (UTC) FILETIME=[A45B3D60:01C9BBFE] Cc: linux-kernel@vger.kernel.org X-BeenThere: linuxppc-dev@ozlabs.org X-Mailman-Version: 2.1.11 Precedence: list List-Id: Linux on PowerPC Developers Mail List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: linuxppc-dev-bounces+patchwork-incoming=ozlabs.org@ozlabs.org Errors-To: linuxppc-dev-bounces+patchwork-incoming=ozlabs.org@ozlabs.org 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. Signed-off-by: Harry Ciao --- drivers/edac/amd8111_edac.c | 3 +-- drivers/edac/edac_core.h | 1 + drivers/edac/edac_device.c | 13 +++++++++++++ 3 files changed, 15 insertions(+), 2 deletions(-) --- a/drivers/edac/amd8111_edac.c +++ b/drivers/edac/amd8111_edac.c @@ -37,7 +37,6 @@ #define AMD8111_EDAC_MOD_STR "amd8111_edac" #define PCI_DEVICE_ID_AMD_8111_PCI 0x7460 -static int edac_dev_idx; enum amd8111_edac_devs { LPC_BRIDGE = 0, @@ -377,7 +376,7 @@ static int amd8111_dev_probe(struct pci_ * edac_device_ctl_info, but make use of existing * one instead. */ - dev_info->edac_idx = edac_dev_idx++; + dev_info->edac_idx = edac_device_alloc_index(); dev_info->edac_dev = edac_device_alloc_ctl_info(0, dev_info->ctl_name, 1, NULL, 0, 0, --- a/drivers/edac/edac_core.h +++ b/drivers/edac/edac_core.h @@ -819,6 +819,7 @@ extern void edac_device_handle_ue(struct int inst_nr, int block_nr, const char *msg); extern void edac_device_handle_ce(struct edac_device_ctl_info *edac_dev, int inst_nr, int block_nr, const char *msg); +extern int edac_device_alloc_index(void); /* * edac_pci APIs --- a/drivers/edac/edac_device.c +++ b/drivers/edac/edac_device.c @@ -37,6 +37,7 @@ */ static DEFINE_MUTEX(device_ctls_mutex); static LIST_HEAD(edac_device_list); +static atomic_t device_indexes = ATOMIC_INIT(0); #ifdef CONFIG_EDAC_DEBUG static void edac_device_dump_device(struct edac_device_ctl_info *edac_dev) @@ -490,6 +491,18 @@ void edac_device_reset_delay_period(stru mutex_unlock(&device_ctls_mutex); } +/* + * edac_device_alloc_index: Allocate a unique device index number + * + * Return: + * allocated index number + */ +int edac_device_alloc_index(void) +{ + return atomic_inc_return(&device_indexes) - 1; +} +EXPORT_SYMBOL_GPL(edac_device_alloc_index); + /** * edac_device_add_device: Insert the 'edac_dev' structure into the * edac_device global list and create sysfs entries associated with