Re: [PATCH v2 4/7] ghes_edac: avoid multiple calls to dmi_walk()

Borislav Petkov
2017-08-16T17:32:02Z

On Wed, Aug 16, 2017 at 10:22:49AM -0400, Steven Rostedt wrote:
> Maybe keep that original mutex just in case.

Let's do the elegant thing:

---
diff --git a/drivers/edac/ghes_edac.c b/drivers/edac/ghes_edac.c
index d4089c2980ef..386e04a7bda0 100644
--- a/drivers/edac/ghes_edac.c
+++ b/drivers/edac/ghes_edac.c
@@ -28,6 +28,7 @@ struct ghes_edac_pvt {
char msg[80];
};

+static atomic_t ghes_init = ATOMIC_INIT(0);
static struct ghes_edac_pvt *ghes_pvt;

/*
@@ -426,7 +427,7 @@ int ghes_edac_register(struct ghes *ghes, struct device *dev)
/*
* We have only one logical memory controller to which all DIMMs belong.
*/
- if (ghes_pvt)
+ if (atomic_inc_return(&ghes_init) > 1)
return 0;

/* Get the number of DIMMs */

--
Regards/Gruss,
Boris.

Good mailing practices for 400: avoid top-posting and trim the reply.