checkpatch: add DT compatible string documentation check
PATCH 1/1 checkpatch: add DT compatible string documentation check
From: Rob Herring <rob.herring-bsGFqQB8/[email protected]>
This adds a simple check that any compatible strings in DeviceTree dts files are present in Documentation/devicetree/bindings. This should be a temporary check until we have more sophisticated binding schema checking.
--- scripts/checkpatch.pl | 15 +++++++++++++++ 1 file changed, 15 insertions(+)
scripts/checkpatch.pl +15 -0
@@ -2034,6 +2034,21 @@ sub process { "Use of $flag is deprecated, please use \`$replacement->{$flag} instead.\n" . $herecurr) if ($replacement->{$flag}); } +# check for compatible documentation + if ($realfile =~ /\.dts/ && $rawline =~ /\+\s*compatible\s*=/) { + my @compats = $rawline =~ /\"([a-zA-Z0-9\-\,]+)\"/g; + + foreach my $compat (@compats) { + my $compat2 = $compat; + $compat2 =~ s/\,[a-z]*\-/\,<\.\*>\-/; + `egrep -rq "$compat|$compat2" "Documentation/devicetree/bindings/"`; + if ( $? >> 8 ) { + WARN("UNDOCUMENTED_DT_BINDING", + "DT compatible string \"$compat\" appears un-documented -- check Documentation/devicetree/bindings/\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 · 6 lines
1.8.3.2 -- To unsubscribe from this list: send the line "unsubscribe devicetree" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
Joe Perches
maintainerQuoted 1 line · Rob Herring
From: Rob Herring <rob.herring-bsGFqQB8/[email protected]>
Hi Rob.
Quoted 3 lines
This adds a simple check that any compatible strings in DeviceTree dts files are present in
Documentation/devicetree/bindings. This should be a temporary check until we have more sophisticated binding schema checking.
[]
scripts/checkpatch.pl
Quoted 1 line
scripts/checkpatch.pl +0
-0
[]
scripts/checkpatch.pl sub process { · line 2039
Quoted 7 lines
scripts/checkpatch.pl +3
-0@@ -2034,6 +2034,21 @@ sub process { "Use of $flag is deprecated, please use \`$replacement->{$flag} instead.\n" . $herecurr) if ($replacement->{$flag}); } +# check for compatible documentation + if ($realfile =~ /\.dts/ && $rawline =~ /\+\s*compatible\s*=/) { + my @compats = $rawline =~ /\"([a-zA-Z0-9\-\,]+)\"/g;
I believe there needs to be a \+\. in the brackets for lines like:
arch/c6x/boot/dts/tms320c6678.dtsi: compatible = "ti,c64x+timer64"; andarch/powerpc/boot/dts/mpc8313erdb.dts: compatible = "fsl,sec2.2", "fsl,sec2.1",
scripts/checkpatch.pl sub process { · line 2044
Quoted 5 lines
scripts/checkpatch.pl +5
-0+ + foreach my $compat (@compats) { + my $compat2 = $compat; + $compat2 =~ s/\,[a-z]*\-/\,<\.\*>\-/; + `egrep -rq "$compat|$compat2" "Documentation/devicetree/bindings/"`;
Perhaps the egrep should be grep -E
scripts/checkpatch.pl sub process { · line 2054
Quoted 10 lines
scripts/checkpatch.pl +7
-0+ if ( $? >> 8 ) { + WARN("UNDOCUMENTED_DT_BINDING", + "DT compatible string \"$compat\" appears un-documented -- check Documentation/devicetree/bindings/\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)$/);
--
To unsubscribe from this list: send the line "unsubscribe devicetree" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
Quoted 15 lines · Joe Perches
Quoted 1 line · Rob Herring
From: Rob Herring <rob.herring-bsGFqQB8/[email protected]>
Hi Rob.
Quoted 3 lines
This adds a simple check that any compatible strings in DeviceTree dts files are present in
Documentation/devicetree/bindings. This should be a temporary check until we have more sophisticated binding schema checking.[]
scripts/checkpatch.pl
Quoted 1 line
scripts/checkpatch.pl +0
-0[]
Quoted 4 lines
scripts/checkpatch.pl +0
-0@@ -2034,6 +2034,21 @@ sub process { "Use of $flag is deprecated, please use \`$replacement->{$flag} instead.\n" . $herecurr) if ($replacement->{$flag}); }
Quoted 8 lines
scripts/checkpatch.pl sub process { · line 2039
Quoted 3 lines
scripts/checkpatch.pl +3
-0+# check for compatible documentation + if ($realfile =~ /\.dts/ && $rawline =~ /\+\s*compatible\s*=/) { + my @compats = $rawline =~ /\"([a-zA-Z0-9\-\,]+)\"/g;I believe there needs to be a \+\. in the brackets for lines like:
arch/c6x/boot/dts/tms320c6678.dtsi: compatible = "ti,c64x+timer64";
I think we don't really want '+' (or '_') in compatible strings. That would really a check against the documentation versus whether the dts matches the documentation. So I probably should add a separate check on use of documented, but deprecated compatible strings. Ideally, that check would be on the binding doc, but since they are unstructured currently, we'd have to do it on dts files.
Quoted 2 lines
and
arch/powerpc/boot/dts/mpc8313erdb.dts: compatible = "fsl,sec2.2", "fsl,sec2.1",
Yes, indeed.
Rob
--
To unsubscribe from this list: send the line "unsubscribe devicetree" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
Joe Perches
maintainerQuoted 1 line · Rob Herring
I think we don't really want '+' (or '_') in compatible strings.
What about lines like:arch/powerpc/boot/dts/kmeter1.dts: compatible = "ucc_geth";
--
To unsubscribe from this list: send the line "unsubscribe devicetree" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
Quoted 5 lines · Joe Perches
Quoted 1 line · Rob Herring
I think we don't really want '+' (or '_') in compatible strings.
What about lines like:
arch/powerpc/boot/dts/kmeter1.dts: compatible = "ucc_geth";
I didn't say we don't have them, but for new bindings we want to flag things like this. It is fine if new dts files use those existing bindings, but no one should be creating new bindings with the deprecated style. The problem is that I can't really automate this check on the binding documentation until we move to schema based bindings (which won't be soon). So I would like to warn if dts files use deprecated styles. I don't expect this to be a frequent occurrence.
Rob
--
To unsubscribe from this list: send the line "unsubscribe devicetree" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html