diff mbox series

[v2,07/10] EDAC/ghes: Cleanup struct ghes_edac_dimm_fill, rename it to ghes_dimm_fill

Message ID 20200422115814.22205-8-rrichter@marvell.com (mailing list archive)
State New, archived
Headers show
Series EDAC/mc/ghes: Fixes, cleanup and reworks | expand

Commit Message

Robert Richter April 22, 2020, 11:58 a.m. UTC
The struct is used to store temporary data for the dmidecode callback.
Clean this up a bit:

 1) Rename member count to index since this is what it is used for.

 2) Move code close to ghes_edac_dmidecode() where it is used.

 3) While at it, use edac_get_dimm_by_index().

Signed-off-by: Robert Richter <rrichter@marvell.com>
---
 drivers/edac/ghes_edac.c | 24 ++++++++++++------------
 1 file changed, 12 insertions(+), 12 deletions(-)

Comments

Borislav Petkov April 27, 2020, 2 p.m. UTC | #1
On Wed, Apr 22, 2020 at 01:58:11PM +0200, Robert Richter wrote:
> The struct is used to store temporary data for the dmidecode callback.
> Clean this up a bit:
> 
>  1) Rename member count to index since this is what it is used for.
> 
>  2) Move code close to ghes_edac_dmidecode() where it is used.
> 
>  3) While at it, use edac_get_dimm_by_index().
> 
> Signed-off-by: Robert Richter <rrichter@marvell.com>
> ---
>  drivers/edac/ghes_edac.c | 24 ++++++++++++------------
>  1 file changed, 12 insertions(+), 12 deletions(-)

Ok except the commit title is wrong. And yes, pls keep it "dimm_fill" -
short and sweet and without yet another "ghes" in the name. :)

Thx.
Robert Richter May 19, 2020, 9:35 a.m. UTC | #2
On 27.04.20 16:00:43, Borislav Petkov wrote:
> On Wed, Apr 22, 2020 at 01:58:11PM +0200, Robert Richter wrote:
> > The struct is used to store temporary data for the dmidecode callback.
> > Clean this up a bit:
> > 
> >  1) Rename member count to index since this is what it is used for.
> > 
> >  2) Move code close to ghes_edac_dmidecode() where it is used.
> > 
> >  3) While at it, use edac_get_dimm_by_index().
> > 
> > Signed-off-by: Robert Richter <rrichter@marvell.com>
> > ---
> >  drivers/edac/ghes_edac.c | 24 ++++++++++++------------
> >  1 file changed, 12 insertions(+), 12 deletions(-)
> 
> Ok except the commit title is wrong. And yes, pls keep it "dimm_fill" -
> short and sweet and without yet another "ghes" in the name. :)

Fixed the title.

Thanks,

-Robert
diff mbox series

Patch

diff --git a/drivers/edac/ghes_edac.c b/drivers/edac/ghes_edac.c
index 038e560fd332..4eadc5b344c8 100644
--- a/drivers/edac/ghes_edac.c
+++ b/drivers/edac/ghes_edac.c
@@ -88,12 +88,6 @@  struct memdev_dmi_entry {
 	u16 conf_mem_clk_speed;
 } __attribute__((__packed__));
 
-struct dimm_fill {
-	struct list_head dimms;
-	struct mem_ctl_info *mci;
-	unsigned int count;
-};
-
 static int ghes_dimm_pool_create(int num_dimm)
 {
 	struct ghes_dimm *ghes_dimm;
@@ -182,6 +176,12 @@  static void ghes_dimm_setup_label(struct dimm_info *dimm, u16 handle)
 			"unknown memory (handle: 0x%.4x)", handle);
 }
 
+struct dimm_fill {
+	struct list_head dimms;
+	struct mem_ctl_info *mci;
+	int index;
+};
+
 static void ghes_edac_dmidecode(const struct dmi_header *dh, void *arg)
 {
 	struct dimm_fill *dimm_fill = arg;
@@ -190,11 +190,11 @@  static void ghes_edac_dmidecode(const struct dmi_header *dh, void *arg)
 
 	if (dh->type == DMI_ENTRY_MEM_DEVICE) {
 		struct memdev_dmi_entry *entry = (struct memdev_dmi_entry *)dh;
-		struct dimm_info *dimm = edac_get_dimm(mci, dimm_fill->count, 0, 0);
+		struct dimm_info *dimm = edac_get_dimm_by_index(mci, dimm_fill->index);
 
 		if (entry->size == 0xffff) {
 			pr_info("Can't get DIMM%i size\n",
-				dimm_fill->count);
+				dimm_fill->index);
 			dimm->nr_pages = MiB_TO_PAGES(32);/* Unknown */
 		} else if (entry->size == 0x7fff) {
 			dimm->nr_pages = MiB_TO_PAGES(entry->extended_size);
@@ -267,7 +267,7 @@  static void ghes_edac_dmidecode(const struct dmi_header *dh, void *arg)
 
 		if (dimm->nr_pages) {
 			edac_dbg(1, "DIMM%i: %s size = %d MB%s\n",
-				dimm_fill->count, edac_mem_types[dimm->mtype],
+				dimm_fill->index, edac_mem_types[dimm->mtype],
 				PAGES_TO_MiB(dimm->nr_pages),
 				(dimm->edac_mode != EDAC_NONE) ? "(ECC)" : "");
 			edac_dbg(2, "\ttype %d, detail 0x%02x, width %d(total %d)\n",
@@ -280,7 +280,7 @@  static void ghes_edac_dmidecode(const struct dmi_header *dh, void *arg)
 		if (ghes_dimm)
 			list_add_tail(&ghes_dimm->entry, &dimm_fill->dimms);
 
-		dimm_fill->count++;
+		dimm_fill->index++;
 	}
 }
 
@@ -614,11 +614,11 @@  int ghes_edac_register(struct ghes *ghes, struct device *dev)
 	INIT_LIST_HEAD(&dimm_fill.dimms);
 
 	if (!fake) {
-		dimm_fill.count = 0;
+		dimm_fill.index = 0;
 		dimm_fill.mci = mci;
 		dmi_walk(ghes_edac_dmidecode, &dimm_fill);
 	} else {
-		struct dimm_info *dimm = edac_get_dimm(mci, 0, 0, 0);
+		struct dimm_info *dimm = edac_get_dimm_by_index(mci, 0);
 
 		dimm->nr_pages = 1;
 		dimm->grain = 128;