EDAC: Add routine to check if MC devices list is empty
authorYazen Ghannam <Yazen.Ghannam@amd.com>
Fri, 27 Jan 2017 17:24:21 +0000 (11:24 -0600)
committerBorislav Petkov <bp@suse.de>
Sat, 28 Jan 2017 13:36:47 +0000 (14:36 +0100)
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>
drivers/edac/edac_mc.c
drivers/edac/edac_mc.h

index 750891ea07de1573aba2d05a31bf8775b7d5ddf7..e5573c56b15e092df0eb0edf5d0d27490910f287 100644 (file)
@@ -453,6 +453,20 @@ void edac_mc_free(struct mem_ctl_info *mci)
 }
 EXPORT_SYMBOL_GPL(edac_mc_free);
 
+bool edac_has_mcs(void)
+{
+       bool ret;
+
+       mutex_lock(&mem_ctls_mutex);
+
+       ret = list_empty(&mc_devices);
+
+       mutex_unlock(&mem_ctls_mutex);
+
+       return !ret;
+}
+EXPORT_SYMBOL_GPL(edac_has_mcs);
+
 /* Caller must hold mem_ctls_mutex */
 static struct mem_ctl_info *__find_mci_by_dev(struct device *dev)
 {
index 50fc1dc9c0d837b2d661c1d6af1e3f2ff563adff..5357800e418d344b32d21d200c523803cbbcecbb 100644 (file)
@@ -148,6 +148,15 @@ extern int edac_mc_add_mc_with_groups(struct mem_ctl_info *mci,
  */
 extern void edac_mc_free(struct mem_ctl_info *mci);
 
+/**
+ * edac_has_mcs() - Check if any MCs have been allocated.
+ *
+ * Returns:
+ *     True if MC instances have been registered successfully.
+ *     False otherwise.
+ */
+extern bool edac_has_mcs(void);
+
 /**
  * edac_mc_find() - Search for a mem_ctl_info structure whose index is @idx.
  *