Hi,
Since v1 [1]:
- Add check for vendors with '-', as suggested by Joe Perches
Regards,
Florian
[1] http://thread.gmane.org/gmane.linux.drivers.devicetree/63770
Florian Vaussard (2):
checkpatch: check vendor compatible with dashes
checkpatch: fix spurious vendor compatible warnings
scripts/checkpatch.pl | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
--
1.8.5.3
The current vendor compatible check will not match vendors with
dashes, like:
compatible="asahi-kasei"
Reported-by: Joe Perches <[email protected]>
Signed-off-by: Florian Vaussard <[email protected]>
---
scripts/checkpatch.pl | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
index 464dcef..e304e77 100755
--- a/scripts/checkpatch.pl
+++ b/scripts/checkpatch.pl
@@ -2058,7 +2058,7 @@ sub process {
my $vendor = $compat;
my $vendor_path = $dt_path . "vendor-prefixes.txt";
next if (! -f $vendor_path);
- $vendor =~ s/^([a-zA-Z0-9]+)\,.*/$1/;
+ $vendor =~ s/^([a-zA-Z0-9\-]+)\,.*/$1/;
`grep -Eq "$vendor" $vendor_path`;
if ( $? >> 8 ) {
WARN("UNDOCUMENTED_DT_STRING",
--
1.8.5.3
With a compatible string like
compatible = "foo";
checkpatch will currently try to find "foo" in vendor-prefixes.txt,
which is wrong since the vendor prefix is empty in this specific case.
Skip the vendor test if the compatible is not like
compatible = "vendor,something";
Signed-off-by: Florian Vaussard <[email protected]>
---
scripts/checkpatch.pl | 1 +
1 file changed, 1 insertion(+)
diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
index e304e77..7437505 100755
--- a/scripts/checkpatch.pl
+++ b/scripts/checkpatch.pl
@@ -2058,6 +2058,7 @@ sub process {
my $vendor = $compat;
my $vendor_path = $dt_path . "vendor-prefixes.txt";
next if (! -f $vendor_path);
+ next if not $vendor =~ /^[a-zA-Z0-9\-]+\,.*/;
$vendor =~ s/^([a-zA-Z0-9\-]+)\,.*/$1/;
`grep -Eq "$vendor" $vendor_path`;
if ( $? >> 8 ) {
--
1.8.5.3
Hi.
A couple of suggestions and a couple of questions.
I made the patch below against your patches to.
o Look for ".compatible = "foo" strings in .c and .h files too
o Improve the vendor name match in vendor-prefix.txt by only
matching the exact vendor name at the beginning of lines.
I then produced a file of all the compatible uses in dts
and used checkpatch on it. It's a long list and a longer
checkpatch warning list.
$ git ls-files | grep -E "\.dtsi?$" | \
xargs grep -hE "^\s*compatible\s*="| \
sed -r -e 's/^\s*//' -e 's/\s*=\s*/ = /'| sort | uniq > tmp.dts
$ .scripts/checkpatch.pl -f tmp.dts
A couple of questions:
How does the $compat2 variable actually work?
What is it supposed to do?
my $compat2 = $compat;
$compat2 =~ s/\,[a-z]*\-/\,<\.\*>\-/;
For instance:
WARNING: DT compatible string "marvell,tauros2-cache" appears un-documented -- check ./Documentation/devicetree/bindings/
The prefix "tauros2-" doesn't match '=~ s/[a-z]*-/
Should it? Should the '[a-z]*' be '[a-zA-Z0-9-]+'
like the other test?
Also the grep used when $compat2 is different than $compat
has <.*>
There aren't any descriptions I see in binding/ that have
any <foo> like uses with the angle brackets.
Are the angle brackets "<" and ">" necessary?
I think the code block should look more like:
my $compat2 = $compat;
$compat2 =~ s/\,[a-zA-Z0-9]*\-/\,\.\*\-/g;
my $grepfor = "\Q$compat\E";
$grepfor .= "|\Q$compat2\E" if ($compat2 ne $compat);
`grep -Erq "$grepfor" $dt_path`;
so that there's only 1 grep pattern when
$compat2 is the same as $compat and the
strings are escape quoted.
There are a _lot_ of missing entries:
o 164 vendor names
o 2408 device names (maybe due to bad compat2 greps?)
What, if anything, should be done about them?
---
scripts/checkpatch.pl | 22 +++++++++++-----------
1 file changed, 11 insertions(+), 11 deletions(-)
diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
index 4b5e7b3..7a9eed9 100755
--- a/scripts/checkpatch.pl
+++ b/scripts/checkpatch.pl
@@ -2051,29 +2051,29 @@ sub process {
}
# check for DT compatible documentation
- if (defined $root && $realfile =~ /\.dts/ &&
- $rawline =~ /^\+\s*compatible\s*=/) {
+ if (defined $root &&
+ (($realfile =~ /\.dtsi?$/ && $line =~ /^\+\s*compatible\s*=\s*\"/) ||
+ ($realfile =~ /\.[ch]$/ && $line =~ /^\+.*\.compatible\s*=\s*\"/))) {
+
my @compats = $rawline =~ /\"([a-zA-Z0-9\-\,\.\+_]+)\"/g;
+ my $dt_path = $root . "/Documentation/devicetree/bindings/";
+ my $vp_file = $root . "/Documentation/devicetree/bindings/vendor-prefixes.txt";
+
foreach my $compat (@compats) {
my $compat2 = $compat;
- my $dt_path = $root . "/Documentation/devicetree/bindings/";
$compat2 =~ s/\,[a-z]*\-/\,<\.\*>\-/;
`grep -Erq "$compat|$compat2" $dt_path`;
if ( $? >> 8 ) {
WARN("UNDOCUMENTED_DT_STRING",
"DT compatible string \"$compat\" appears un-documented -- check $dt_path\n" . $herecurr);
}
-
- my $vendor = $compat;
- my $vendor_path = $dt_path . "vendor-prefixes.txt";
- next if (! -f $vendor_path);
- next if not $vendor =~ /^[a-zA-Z0-9\-]+\,.*/;
- $vendor =~ s/^([a-zA-Z0-9\-]+)\,.*/$1/;
- `grep -Eq "$vendor" $vendor_path`;
+ next if $compat !~ /^([a-zA-Z0-9\-]+)\,/;
+ my $vendor = $1;
+ `grep -Eq "^$vendor\\b" $vp_file`;
if ( $? >> 8 ) {
WARN("UNDOCUMENTED_DT_STRING",
- "DT compatible string vendor \"$vendor\" appears un-documented -- check $vendor_path\n" . $herecurr);
+ "DT compatible string vendor \"$vendor\" appears un-documented -- check $vp_file\n" . $herecurr);
}
}
}
---