Re: [PATCH v9 2/2] EDAC: add EDAC driver for DMC520

From: Scott Branden
Date: Thu Jan 16 2020 - 19:31:36 EST


Hi Shiping,

Here is another small change to cleanup.

On 2020-01-15 6:32 a.m., Shiping Ji wrote:
New driver supports error detection and correction on the devices with ARM
DMC-520 memory controller.

Signed-off-by: Shiping Ji <shiping.linux@xxxxxxxxx>
Signed-off-by: Lei Wang <leiwang_git@xxxxxxxxxxx>
Reviewed-by: James Morse <james.morse@xxxxxxx>

---
Changes in v9:
- Removed interrupt-config and replaced with an interrupt map where names and masks are predefined
- Only one ISR function is defined, mask is retrieved from the interrupt map
- "dram_ecc_errc" and "dram_ecc_errd" are implemented

---
+static void dmc520_get_dram_ecc_error_info(struct dmc520_edac *edac,
+ bool is_ce,
+ struct ecc_error_info *info)
+{
+ u32 reg_offset_low, reg_offset_high;
+ u32 reg_val_low, reg_val_high;
+ bool valid;
+
+ reg_offset_low = is_ce ? REG_OFFSET_DRAM_ECC_ERRC_INT_INFO_31_00 :
+ REG_OFFSET_DRAM_ECC_ERRD_INT_INFO_31_00;
+ reg_offset_high = is_ce ? REG_OFFSET_DRAM_ECC_ERRC_INT_INFO_63_32 :
+ REG_OFFSET_DRAM_ECC_ERRD_INT_INFO_63_32;
+
+ reg_val_low = dmc520_read_reg(edac, reg_offset_low);
+ reg_val_high = dmc520_read_reg(edac, reg_offset_high);
+
+ valid = (FIELD_GET(REG_FIELD_ERR_INFO_LOW_VALID, reg_val_low) != 0) &&
+ (FIELD_GET(REG_FIELD_ERR_INFO_HIGH_VALID, reg_val_high) != 0);
+
+ if (valid) {
+ info->col =
+ FIELD_GET(REG_FIELD_ERR_INFO_LOW_COL, reg_val_low);
+ info->row =
+ FIELD_GET(REG_FIELD_ERR_INFO_LOW_ROW, reg_val_low);
+ info->rank =
+ FIELD_GET(REG_FIELD_ERR_INFO_LOW_RANK, reg_val_low);
+ info->bank =
+ FIELD_GET(REG_FIELD_ERR_INFO_HIGH_BANK, reg_val_high);
+ } else {
+ memset(info, 0, sizeof(struct ecc_error_info));
This should be sizeof(*info), not sizeof(struct ecc_error_info)
for better programming to allow info to change type in the future
without the code changing.
+ }
+}
+