checkpatch: add DT compatible string documentation checks
PATCH 1/1 checkpatch: add DT compatible string documentation checks
This adds a simple check that any compatible strings in DeviceTree dts files are present in Documentation/devicetree/bindings and in dts/Bindings/.
Vendor prefixes are also checked for existing in vendor-prefixes.txt.
This code is based on linux v4.0-rc6 checkpatch.pl dt-checking code by Rob Herring & Florian Vaussard:
Rob Herring (2):
checkpatch: add DT compatible string documentation checks
checkpatch: fix wildcard DT compatible string checking
Florian Vaussard (3):
checkpatch: fix spurious vendor compatible warnings
checkpatch: check compatible strings in .c and .h too
checkpatch: improve the compatible vendor match
--- scripts/checkpatch.pl | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+)
scripts/checkpatch.pl +35 -0
@@ -1466,6 +1466,41 @@ sub process { #print "is_end<$is_end> length<$length>\n"; } +# check for DT compatible documentation + if (defined $root && + (($realfile =~ /\.dtsi?$/ && $line =~ /^\+\s*compatible\s*=\s*\"/) || + ($realfile =~ /\.[ch]$/ && $line =~ /^\+.*\.compatible\s*=\s*\"/))) { + + my @compats = $rawline =~ /\"([a-zA-Z0-9\-\,\.\+_]+)\"/g; + + # linux device tree files + my $dt_path = $root . "/dts/Bindings/"; + my $vp_file = $dt_path . "vendor-prefixes.txt"; + + # barebox-specific bindings + $dt_path = $dt_path . " " . $root . "/Documentation/devicetree/bindings/"; + + foreach my $compat (@compats) { + my $compat2 = $compat; + $compat2 =~ s/\,[a-zA-Z0-9]*\-/\,<\.\*>\-/; + my $compat3 = $compat; + $compat3 =~ s/\,([a-z]*)[0-9]*\-/\,$1<\.\*>\-/; + `grep -Erq "$compat|$compat2|$compat3" $dt_path`; + if ( $? >> 8 ) { + WARN( + "DT compatible string \"$compat\" appears un-documented -- check $dt_path\n" . $herecurr); + } + + next if $compat !~ /^([a-zA-Z0-9\-]+)\,/; + my $vendor = $1; + `grep -Eq "^$vendor\\b" $vp_file`; + if ( $? >> 8 ) { + WARN( + "DT compatible string vendor \"$vendor\" appears un-documented -- check $vp_file\n" . $herecurr); + } + } + } + # check we are in a valid source file if not then ignore this hunk next if ($realfile !~ /\.(h|c|s|S|pl|sh)$/);
Signature · 7 lines
2.1.4 _______________________________________________ barebox mailing list [email protected] http://lists.infradead.org/mailman/listinfo/barebox
On Wed, 22 Apr 2015 23:39:18 +0300
Antony Pavlov <[email protected]> wrote:
ping
Quoted 74 lines
This adds a simple check that any compatible strings in DeviceTree dts files are present in
Documentation/devicetree/bindingsand in dts/Bindings/.Vendor prefixes are also checked for existing in vendor-prefixes.txt.
This code is based on linux v4.0-rc6 checkpatch.pl dt-checking code by Rob Herring & Florian Vaussard:
Rob Herring (2):
checkpatch: add DT compatible string documentation checks
checkpatch: fix wildcard DT compatible string checkingFlorian Vaussard (3):
checkpatch: fix spurious vendor compatible warnings
checkpatch: check compatible strings in .c and .h too
checkpatch: improve the compatible vendor matchSigned-off-by Antony Pavlov <[email protected]>Cc Rob Herring <[email protected]>Cc Florian Vaussard <[email protected]>--- scripts/checkpatch.pl | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+)scripts/checkpatch.pl +35
-0@@ -1466,6 +1466,41 @@ sub process { #print "is_end<$is_end> length<$length>\n"; } +# check for DT compatible documentation + if (defined $root && + (($realfile =~ /\.dtsi?$/ && $line =~ /^\+\s*compatible\s*=\s*\"/) || + ($realfile =~ /\.[ch]$/ && $line =~ /^\+.*\.compatible\s*=\s*\"/))) { + + my @compats = $rawline =~ /\"([a-zA-Z0-9\-\,\.\+_]+)\"/g; + + # linux device tree files + my $dt_path = $root . "/dts/Bindings/"; + my $vp_file = $dt_path . "vendor-prefixes.txt"; + + # barebox-specific bindings + $dt_path = $dt_path . " " . $root . "/Documentation/devicetree/bindings/"; + + foreach my $compat (@compats) { + my $compat2 = $compat; + $compat2 =~ s/\,[a-zA-Z0-9]*\-/\,<\.\*>\-/; + my $compat3 = $compat; + $compat3 =~ s/\,([a-z]*)[0-9]*\-/\,$1<\.\*>\-/; + `grep -Erq "$compat|$compat2|$compat3" $dt_path`; + if ( $? >> 8 ) { + WARN( + "DT compatible string \"$compat\" appears un-documented -- check $dt_path\n" . $herecurr); + } + + next if $compat !~ /^([a-zA-Z0-9\-]+)\,/; + my $vendor = $1; + `grep -Eq "^$vendor\\b" $vp_file`; + if ( $? >> 8 ) { + WARN( + "DT compatible string vendor \"$vendor\" appears un-documented -- check $vp_file\n" . $herecurr); + } + } + } + # check we are in a valid source file if not then ignore this hunk next if ($realfile !~ /\.(h|c|s|S|pl|sh)$/);Signature · 1 line
2.1.4
Signature · 8 lines
-- Best regards, Antony Pavlov _______________________________________________ barebox mailing list [email protected] http://lists.infradead.org/mailman/listinfo/barebox
Hi Antony,
Quoted 9 lines · Antony Pavlov
This adds a simple check that any compatible strings in DeviceTree dts files are present in
Documentation/devicetree/bindingsand in dts/Bindings/.Vendor prefixes are also checked for existing in vendor-prefixes.txt.
This code is based on linux v4.0-rc6 checkpatch.pl dt-checking code by Rob Herring & Florian Vaussard:
Quoted 8 lines
Rob Herring (2):
checkpatch: add DT compatible string documentation checks
checkpatch: fix wildcard DT compatible string checkingFlorian Vaussard (3):
checkpatch: fix spurious vendor compatible warnings
checkpatch: check compatible strings in .c and .h too
checkpatch: improve the compatible vendor match
Sorry for the delay. The reason I haven't written you back is that I was unsure if we want to have the compatible checks in barebox. I now think it's good to have them, so I merged this patch.
Sascha
Signature · 9 lines
Pengutronix e.K. | | Industrial Linux Solutions | http://www.pengutronix.de/ | Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0 | Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 | _______________________________________________ barebox mailing list [email protected] http://lists.infradead.org/mailman/listinfo/barebox