[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <c40261d18ff593767a026d0392d44f322b4a3b33.camel@perches.com>
Date: Mon, 24 Jun 2019 12:56:57 -0700
From: Joe Perches <joe@...ches.com>
To: Shravan Kumar Ramani <sramani@...lanox.com>,
Borislav Petkov <bp@...en8.de>,
Mauro Carvalho Chehab <mchehab@...nel.org>,
James Morse <james.morse@....com>
Cc: Liming Sun <lsun@...lanox.com>, linux-edac@...r.kernel.org,
linux-kernel@...r.kernel.org
Subject: Re: [PATCH v6 1/1] EDAC, mellanox: Add ECC support for BlueField
DDR4
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...
Powered by blists - more mailing lists