Re: [PATCH] checkpatch: Add exceptions for dsb keyword usage

From: Joe Perches
Date: Thu Jul 05 2018 - 17:14:37 EST


On Thu, 2018-07-05 at 11:19 -0700, Prakruthi Deepak Heragu wrote:
> mb() API can relpace the dsb() API in the kernel code. So, dsb() usage
> is discouraged. However, there are exceptions when dsb is used in a
> variable or a function name. Exceptions are when 'dsb' is prefixed with
> class [-_>*\.] and/or suffixed with class [-_\.;].
[]
> diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
[]
> @@ -5372,6 +5372,12 @@ sub process {
> "Avoid line continuations in quoted strings\n" . $herecurr);
> }
>
> +# dsb is too ARMish, and should usually be mb.
> + if ($line =~ /[^-_>*\.]\bdsb\b[^-_\.;]/) {
> + WARN("ARM_BARRIER",
> + "Use of dsb is discouranged: prefer mb.\n" .
> + $herecurr);
> + }

This patch is whitespace damaged with a spelling error.

Also, if this is reasonable test, and I don't know
that it is, it should be cc'd to the linux-arm list
linux-arm-kernel@xxxxxxxxxxxxxxxxxxx

Also, I suggest 2 tests, one for .S files and
another for .[ch] files, and this be made specific
to arch/arm... files

Something like:

if ($realfile =~ @^arch/arm@ &&
($realfile =~ /\.S$/ && $line =~ /\bdsb\b/) ||
($realfile =~ /\.[ch]$/ && $line =~ /\bdsb\s*\(/)) {
WARN("ARM_DSB",
"Prefer mb over dsb as an ARM memory barrier\n" . $herecurr);
}

ARM people, is this reasonable?