Skip to contentSkip to conversation

checkpatch: DT bindings should be a separate patch

PATCH Superseded Rob Herring 3 participants 3 messages Aug 9, 2018 – Aug 10, 2018 Checkpatch

v1 of 3 Superseded Latest is v3 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 checkpatch: DT bindings should be a separate patch

Devicetree bindings should be their own patch as documented in Documentation/devicetree/bindings/submitting-patches.txt section I.1. This is because bindings are logically independent from a driver implementation, they have a different maintainer (even though they often are applied via the same tree), and it makes for a cleaner history in the DT only tree created with git-filter-branch.

Cc Andy Whitcroft <[email protected]>
Cc Joe Perches <[email protected]>
---
 scripts/checkpatch.pl | 22 ++++++++++++++++++++++
 1 file changed, 22 insertions(+)
scripts/checkpatch.pl +22 -0
index a9c05506e325..20547c109ccd 100755
@@ -2236,6 +2236,7 @@ sub process {
 	our $clean = 1;
 	my $signoff = 0;
 	my $is_patch = 0;
+	my $is_binding_patch = -1;
 	my $in_header_lines = $file ? 0 : 1;
 	my $in_commit_log = 0;		#Scanning lines before patch
 	my $has_commit_log = 0;		#Encountered lines before patch
@@ -2485,6 +2486,27 @@ sub process {
 				$check = $check_orig;
 			}
 			$checklicenseline = 1;
+
+			if ($realfile !~ /MAINTAINERS/) {
+				my $mixed = 0;
+				if ($realfile =~ /(Documentation\/devicetree|include\/dt-bindings).*/) {
+					if ($is_binding_patch == 0) {
+						$mixed = 1;
+					}
+					$is_binding_patch = 1;
+				} else {
+					if ($is_binding_patch == 1) {
+						$mixed = 1;
+					}
+					$is_binding_patch = 0;
+				}
+
+				if ($mixed == 1) {
+					WARN("DT_SPLIT_BINDING_PATCH",
+					     "DT binding docs and includes should be a separate patch\n");
+				}
+			}
+
 			next;
 		}
 
Signature · 1 line
2.17.1
#1 lore raw
Quoted 31 lines · On Thu, 9 Aug 2018 14:50:32 -0600 Rob Herring <[email protected]> wrote:

Devicetree bindings should be their own patch as documented in Documentation/devicetree/bindings/submitting-patches.txt section I.1. This is because bindings are logically independent from a driver implementation, they have a different maintainer (even though they often are applied via the same tree), and it makes for a cleaner history in the DT only tree created with git-filter-branch.

...

scripts/checkpatch.pl +9 -0
@@ -2236,6 +2236,7 @@ sub process {
 	our $clean = 1;
 	my $signoff = 0;
 	my $is_patch = 0;
+	my $is_binding_patch = -1;
 	my $in_header_lines = $file ? 0 : 1;
 	my $in_commit_log = 0;		#Scanning lines before patch
 	my $has_commit_log = 0;		#Encountered lines before patch
@@ -2485,6 +2486,27 @@ sub process {
 				$check = $check_orig;
 			}
 			$checklicenseline = 1;
+
+			if ($realfile !~ /MAINTAINERS/) {
+				my $mixed = 0;
+				if ($realfile =~ /(Documentation\/devicetree|include\/dt-bindings).*/) {
+					if ($is_binding_patch == 0) {
+						$mixed = 1;
+					}
+					$is_binding_patch = 1;

scripts/checkpatch.pl sub process { · line 2506

Quoted 10 lines
scripts/checkpatch.pl +10 -0
+				} else {
+					if ($is_binding_patch == 1) {
+						$mixed = 1;
+					}
+					$is_binding_patch = 0;
+				}
+
+				if ($mixed == 1) {
+					WARN("DT_SPLIT_BINDING_PATCH",
+					     "DT binding docs and includes should be a separate patch\n");

A pointer to Documentation/devicetree/bindings/submitting-patches.txt might be helpful?

Quoted 5 lines
scripts/checkpatch.pl +3 -0
+				}
+			}
+
 			next;
 		}
maintainer
#2 lore raw
In reply to Rob Herring
Quoted 6 lines · Rob Herring

Devicetree bindings should be their own patch as documented in Documentation/devicetree/bindings/submitting-patches.txt section I.1. This is because bindings are logically independent from a driver implementation, they have a different maintainer (even though they often are applied via the same tree), and it makes for a cleaner history in the DT only tree created with git-filter-branch.

[]

scripts/checkpatch.pl

Quoted 1 line
scripts/checkpatch.pl +0 -0

[]

Quoted 9 lines
scripts/checkpatch.pl +1 -0
@@ -2236,6 +2236,7 @@ sub process {
 	our $clean = 1;
 	my $signoff = 0;
 	my $is_patch = 0;
+	my $is_binding_patch = -1;
 	my $in_header_lines = $file ? 0 : 1;
 	my $in_commit_log = 0;		#Scanning lines before patch
 	my $has_commit_log = 0;		#Encountered lines before patch

scripts/checkpatch.pl sub process { · line 2490

Quoted 5 lines
scripts/checkpatch.pl +2 -0
@@ -2485,6 +2486,27 @@ sub process {
 				$check = $check_orig;
 			}
 			$checklicenseline = 1;
+
+			if ($realfile !~ /MAINTAINERS/) {

Should probably be /^MAINTAINERS/

scripts/checkpatch.pl sub process { · line 2492

Quoted 2 lines
scripts/checkpatch.pl +2 -0
+				my $mixed = 0;
+				if ($realfile =~ /(Documentation\/devicetree|include\/dt-bindings).*/) {

This should have a ^ for the start of the filename and generally, this is easier to read using m@...@ like:

				if ($realfile =~ m@^(?:Documentation/devicetree/|include/dt-bindings/)@) {

scripts/checkpatch.pl sub process { · line 2502

Quoted 10 lines
scripts/checkpatch.pl +10 -0
+					if ($is_binding_patch == 0) {
+						$mixed = 1;
+					}
+					$is_binding_patch = 1;
+				} else {
+					if ($is_binding_patch == 1) {
+						$mixed = 1;
+					}
+					$is_binding_patch = 0;
+				}

Perhaps there is simpler logic using an xor.

scripts/checkpatch.pl sub process { · line 2507

Quoted 4 lines
scripts/checkpatch.pl +4 -0
+				if ($mixed == 1) {
+					WARN("DT_SPLIT_BINDING_PATCH",
+					     "DT binding docs and includes should be a separate patch\n");
+				}

Perhaps add 'see: Documentation/devicetree/bindings/submitting-patches.txt'

Quoted 1 line
scripts/checkpatch.pl +1 -0
+			}