Skip to contentSkip to conversation

checkpatch: DT bindings should be a separate patch

PATCH Superseded Rob Herring 2 participants 2 messages Aug 10, 2018 Checkpatch

v2 of 3 Superseded Latest is v3 →

lore
Share & tools
lore
#0 lore raw

PATCH v2 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]>

---
v2:
- Add doc pointer to warning
- Simplify logic

Joe, this makes $is_binding_patch an empty value when the regex doesn't match rather than 0 which would be more logical IMO. It seems to work fine, but I'm not sure if there's a better way to do it.

 scripts/checkpatch.pl | 14 ++++++++++++++
 1 file changed, 14 insertions(+)
scripts/checkpatch.pl +14 -0
index a9c05506e325..f9aba4bc41ce 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,19 @@ sub process {
 				$check = $check_orig;
 			}
 			$checklicenseline = 1;
+
+			if ($realfile !~ /^MAINTAINERS/) {
+				my $last_binding_patch = $is_binding_patch;
+
+				$is_binding_patch = ($realfile =~ m@^(?:Documentation/devicetree/|include/dt-bindings/)@);
+
+				if (($last_binding_patch != -1) &&
+				    ($last_binding_patch ^ $is_binding_patch)) {
+					WARN("DT_SPLIT_BINDING_PATCH",
+					     "DT binding docs and includes should be a separate patch. See: Documentation/devicetree/bindings/submitting-patches.txt");
+				}
+			}
+
 			next;
 		}
 
Signature · 1 line
2.17.1
maintainer
#1 lore raw
Quoted 10 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.

Cc Andy Whitcroft <[email protected]>
Cc Joe Perches <[email protected]>
Quoted 8 lines

---
v2:
- Add doc pointer to warning
- Simplify logic

Joe, this makes $is_binding_patch an empty value when the regex doesn't match rather than 0 which would be more logical IMO. It seems to work fine, but I'm not sure if there's a better way to do it.

Hi Rob. This looks fine with a couple nits.

Quoted 16 lines
 scripts/checkpatch.pl | 14 ++++++++++++++
 1 file changed, 14 insertions(+)
scripts/checkpatch.pl +1 -0
index a9c05506e325..f9aba4bc41ce 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

scripts/checkpatch.pl sub process { · line 2493

Quoted 8 lines
scripts/checkpatch.pl +5 -0
@@ -2485,6 +2486,19 @@ sub process {
 				$check = $check_orig;
 			}
 			$checklicenseline = 1;
+
+			if ($realfile !~ /^MAINTAINERS/) {
+				my $last_binding_patch = $is_binding_patch;
+
+				$is_binding_patch = ($realfile =~ m@^(?:Documentation/devicetree/|include/dt-bindings/)@);

If you want 0/1 you could use:

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

(perl syntax is a constant joy)

scripts/checkpatch.pl sub process { · line 2498

Quoted 5 lines
scripts/checkpatch.pl +5 -0
+
+				if (($last_binding_patch != -1) &&
+				    ($last_binding_patch ^ $is_binding_patch)) {
+					WARN("DT_SPLIT_BINDING_PATCH",
+					     "DT binding docs and includes should be a separate patch. See: Documentation/devicetree/bindings/submitting-patches.txt");

This is missing a '\n' newline at the end of the message.

Quoted 6 lines
scripts/checkpatch.pl +3 -0
+				}
+			}
+
 			next;
 		}