lkml.org 
[lkml]   [2019]   [Jun]   [24]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
SubjectRe: [PATCH v6 1/1] EDAC, mellanox: Add ECC support for BlueField DDR4
From
Date
On Mon, 2019-06-24 at 14:42 -0400, Shravan Kumar Ramani wrote:
> Add ECC support for Mellanox BlueField SoC DDR controller.
> This requires SMC to the running Arm Trusted Firmware to report
> what is the current memory configuration.
[]
> diff --git a/drivers/edac/bluefield_edac.c b/drivers/edac/bluefield_edac.c
[]
> @@ -0,0 +1,381 @@
[]
> +#define MLXBF_ECC_CNT__SERR_CNT_SHIFT 0
> +#define MLXBF_ECC_CNT__SERR_CNT_MASK 0xffff
> +#define MLXBF_ECC_CNT__DERR_CNT_SHIFT 16
> +#define MLXBF_ECC_CNT__DERR_CNT_MASK 0xffff

[multiple variants of #defines like the above]

[]

> + serr = (dram_syndrom >> MLXBF_SYNDROM__SERR_SHIFT) &
> + MLXBF_SYNDROM__SERR_MASK;
> + derr = (dram_syndrom >> MLXBF_SYNDROM__DERR_SHIFT) &
> + MLXBF_SYNDROM__DERR_MASK;
> + syndrom = (dram_syndrom >> MLXBF_SYNDROM__SYN_SHIFT) &
> + MLXBF_SYNDROM__SYN_MASK;

To improve readability and reduce possible copy/paste errors,
these would all benefit from a macro like

#define MLXBF_SM(val, type) \
(((val) >> (MLXBF_ ## type ## _SHIFT)) & (MLXBF_ ## type ## _MASK)))

So these uses could become:

serr = MLXBF_SM(dram_syndrom, SYNDROM__SERR);
derr = MLXBF_SM(dram_syndrom, SYNDROM__DERR);
syndrom =
MLXBF_SM(dram_syndrom, SYN);

etc...


\
 
 \ /
  Last update: 2019-06-24 21:57    [W:0.040 / U:5.596 seconds]
©2003-2018 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site