Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

EDAC: Add routine to check if MC devices list is empty

We need to know if any MC devices have been allocated.

Signed-off-by: Yazen Ghannam <Yazen.Ghannam@amd.com>
Cc: linux-edac <linux-edac@vger.kernel.org>
Link: http://lkml.kernel.org/r/1485537863-2707-7-git-send-email-Yazen.Ghannam@amd.com
[ Prettify text. ]
Signed-off-by: Borislav Petkov <bp@suse.de>

authored by

Yazen Ghannam and committed by
Borislav Petkov
d7fc9d77 df64636f

+23
+14
drivers/edac/edac_mc.c
··· 453 453 } 454 454 EXPORT_SYMBOL_GPL(edac_mc_free); 455 455 456 + bool edac_has_mcs(void) 457 + { 458 + bool ret; 459 + 460 + mutex_lock(&mem_ctls_mutex); 461 + 462 + ret = list_empty(&mc_devices); 463 + 464 + mutex_unlock(&mem_ctls_mutex); 465 + 466 + return !ret; 467 + } 468 + EXPORT_SYMBOL_GPL(edac_has_mcs); 469 + 456 470 /* Caller must hold mem_ctls_mutex */ 457 471 static struct mem_ctl_info *__find_mci_by_dev(struct device *dev) 458 472 {
+9
drivers/edac/edac_mc.h
··· 149 149 extern void edac_mc_free(struct mem_ctl_info *mci); 150 150 151 151 /** 152 + * edac_has_mcs() - Check if any MCs have been allocated. 153 + * 154 + * Returns: 155 + * True if MC instances have been registered successfully. 156 + * False otherwise. 157 + */ 158 + extern bool edac_has_mcs(void); 159 + 160 + /** 152 161 * edac_mc_find() - Search for a mem_ctl_info structure whose index is @idx. 153 162 * 154 163 * @idx: index to be seek