[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-ID: <CAK8P3a3emZd=Tz5JhxevkX3OJMMEn_2Nb+_LQtGZJ9-GWNpd2g@mail.gmail.com>
Date: Thu, 23 Jul 2020 11:09:40 +0200
From: Arnd Bergmann <arnd@...db.de>
To: Krzysztof Kozlowski <krzk@...nel.org>
Cc: Olof Johansson <olof@...om.net>, arm-soc <arm@...nel.org>,
SoC Team <soc@...nel.org>, Markus Mayer <mmayer@...adcom.com>,
bcm-kernel-feedback-list <bcm-kernel-feedback-list@...adcom.com>,
Florian Fainelli <f.fainelli@...il.com>,
Santosh Shilimkar <ssantosh@...nel.org>,
Matthias Brugger <matthias.bgg@...il.com>,
Roger Quadros <rogerq@...com>,
Tony Lindgren <tony@...mide.com>,
Vladimir Zapolskiy <vz@...ia.com>,
Thierry Reding <thierry.reding@...il.com>,
Jonathan Hunter <jonathanh@...dia.com>,
"linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>,
Linux ARM <linux-arm-kernel@...ts.infradead.org>,
"moderated list:ARM/Mediatek SoC..."
<linux-mediatek@...ts.infradead.org>,
linux-omap <linux-omap@...r.kernel.org>,
"open list:TEGRA ARCHITECTURE SUPPORT" <linux-tegra@...r.kernel.org>,
Andrew Morton <akpm@...ux-foundation.org>,
Linus Torvalds <torvalds@...ux-foundation.org>,
Greg Kroah-Hartman <gregkh@...uxfoundation.org>
Subject: Re: [PATCH 19/23] memory: omap-gpmc: Enclose macro statements in do-while
On Thu, Jul 23, 2020 at 9:39 AM Krzysztof Kozlowski <krzk@...nel.org> wrote:
>
> do-while is a preferred way for complex macros because of safety
> reasons. This fixes checkpatch error:
>
> ERROR: Macros starting with if should be enclosed by a do - while
> loop to avoid possible if/else logic defects
>
> Signed-off-by: Krzysztof Kozlowski <krzk@...nel.org>
This is an improvement, but the macro still has other issues that
are just as bad as the one you address:
- Using the # operator to avoid the "" in the invocation seems confusing
- it implicitly uses the 'cs' and 't' variables of the calling function instead
of passing them as arguments.
- it calls 'return -1' in a function that otherwise uses errno-style
return codes, so this gets interpreted as EPERM "Operation not
permitted".
I would probably just open-code the entire thing and remove the
macro like:
ret = 0;
ret |= set_gpmc_timing_reg(cs, GPMC_CS_CONFIG2, 0, 3, 0, t->cs_on,
GPMC_CD_FCLK, "cs_on");
ret |= set_gpmc_timing_reg(cs, GPMC_CS_CONFIG2, 8, 12, 0,
t->cs_rd_off, GPMC_CD_FCLK, "cs_rd_off");
ret |= set_gpmc_timing_reg(cs, GPMC_CS_CONFIG2, 16, 20, 0,
t->cs_wr_off, GPMC_CD_FCLK, "cs_wr_off);
...
if (ret)
return -ENXIO;
Of maybe leave the macro, but remove the if/return part and use
the "ret |= GPMC_SET_ONE(...)" trick to avoid some of the problems.
Arnd
Powered by blists - more mailing lists