mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH v2] checkpatch: report warning with files ending with blank lines
@ 2026-10-07 12:28 Christian Marangi
  2026-10-07 16:49 ` Joe Perches
  0 siblings, 1 reply; 10+ messages in thread
From: Christian Marangi @ 2026-10-07 12:28 UTC (permalink / raw)
  To: Andy Whitcroft, Joe Perches, linux-kernel; +Cc: Christian Marangi

On applying patch, git, depending on the default configuration, might
complain for any file having blank lines at end of file.

These blank lines can go unnotice by the patch submitter as they are not
reported by checkpatch.pl with the maintainer only noticing the error when
the patch is applied. This result in the submitter getting confused asking
further info to the maintainer making the review process longer.

To address this, add a simple logic to catch this error and report as
warning. Example:

WARNING: blank line at end of file
102: FILE: Documentation/devicetree/bindings/phy/airoha,an7581-usb-phy.yaml:62:
+    };
+

Signed-off-by: Christian Marangi <ansuelsmth@gmail.com>
---
Changes v2:
- Move EOF check as last check

 scripts/checkpatch.pl | 19 +++++++++++++++++++
 1 file changed, 19 insertions(+)

diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
index 8a7787d228a6..d12e0e62def5 100755
--- a/scripts/checkpatch.pl
+++ b/scripts/checkpatch.pl
@@ -3887,6 +3887,25 @@ sub process {
 			     "It's generally not useful to have the filename in the file\n" . $herecurr);
 		}
 
+# check for blank line at end of file
+		if ($rawline =~ /^\+[ \t]*$/ &&
+		    (!defined $rawlines[$linenr] ||
+		     $rawlines[$linenr] =~ /^diff --git / ||
+		     $rawlines[$linenr] =~ /^-- $/)) {
+			my $context = $rawline;
+
+			for (my $i = $linenr - 2; $i >= 0; $i--) {
+				last if ($rawlines[$i] !~ /^\+/);
+
+				$context = $rawlines[$i] . "\n" . $context;
+
+				last if ($rawlines[$i] !~ /^\+[ \t]*$/);
+			}
+
+			WARN("BLANK_AT_EOF",
+			     "blank line at end of file\n" . $here . "\n" . $context . "\n");
+		}
+
 # check we are in a valid source file if not then ignore this hunk
 		next if ($realfile !~ /\.(h|c|rs|s|S|sh|dtsi|dts)$/);
 
-- 
2.55.0


^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH v2] checkpatch: report warning with files ending with blank lines
  2026-10-07 12:28 [PATCH v2] checkpatch: report warning with files ending with blank lines Christian Marangi
@ 2026-10-07 16:49 ` Joe Perches
  2026-10-07 16:52   ` Christian Marangi
  0 siblings, 1 reply; 10+ messages in thread
From: Joe Perches @ 2026-10-07 16:49 UTC (permalink / raw)
  To: Christian Marangi, Andy Whitcroft, linux-kernel

On Wed, 2026-10-07 at 14:28 +0200, Christian Marangi wrote:
> ```
> On applying patch, git, depending on the default configuration, might
> complain for any file having blank lines at end of file.

I was not clear enough in my first reply.

I meant that the test should be done only once, not
for each line of the input.

After the end of the process() loop of

	foreach my $rawline (@rawlines) {
		[...]
	}

a single test of $rawlines[-1] could be done.

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH v2] checkpatch: report warning with files ending with blank lines
  2026-10-07 16:49 ` Joe Perches
@ 2026-10-07 16:52   ` Christian Marangi
  2026-10-07 17:50     ` Joe Perches
  2026-10-07 17:58     ` Joe Perches
  0 siblings, 2 replies; 10+ messages in thread
From: Christian Marangi @ 2026-10-07 16:52 UTC (permalink / raw)
  To: Joe Perches; +Cc: Andy Whitcroft, linux-kernel

On Wed, Oct 07, 2026 at 09:49:48AM -0700, Joe Perches wrote:
> On Wed, 2026-10-07 at 14:28 +0200, Christian Marangi wrote:
> > ```
> > On applying patch, git, depending on the default configuration, might
> > complain for any file having blank lines at end of file.
> 
> I was not clear enough in my first reply.
> 
> I meant that the test should be done only once, not
> for each line of the input.
> 
> After the end of the process() loop of
> 
> 	foreach my $rawline (@rawlines) {
> 		[...]
> 	}
> 
> a single test of $rawlines[-1] could be done.

Yes I also was with that idea but then I quickly figure it out that we are
not testing if the .patch have blank line at EOF. But if the single file of
the patch have blank line at EOF.

That can only be done in the process() while scanning each line as it does
progressively check new files in it.

(unless I'm missing something)

-- 
	Ansuel

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH v2] checkpatch: report warning with files ending with blank lines
  2026-10-07 16:52   ` Christian Marangi
@ 2026-10-07 17:50     ` Joe Perches
  2026-10-07 17:54       ` Christian Marangi
  2026-10-07 17:58     ` Joe Perches
  1 sibling, 1 reply; 10+ messages in thread
From: Joe Perches @ 2026-10-07 17:50 UTC (permalink / raw)
  To: Christian Marangi; +Cc: Andy Whitcroft, linux-kernel

On Wed, 2026-10-07 at 18:52 +0200, Christian Marangi wrote:
> On Wed, Oct 07, 2026 at 09:49:48AM -0700, Joe Perches wrote:
> On Wed, 2026-10-07 at 14:28 +0200, Christian Marangi wrote:
> > > On applying patch, git, depending on the default configuration, might
> > > complain for any file having blank lines at end of file.
> > I was not clear enough in my first reply.
> > 
> > I meant that the test should be done only once, not
> > for each line of the input.
> > 
> > After the end of the process() loop of
> > 
> 	foreach my $rawline (@rawlines) {
> 		[...]
> 	}
> > 
> > a single test of $rawlines[-1] could be done.
> 
> Yes I also was with that idea but then I quickly figure it out that we are
> not testing if the .patch have blank line at EOF. But if the single file of
> the patch have blank line at EOF.
> 
> That can only be done in the process() while scanning each line as it does
> progressively check new files in it.
> 
> (unless I'm missing something)

Dunno.  Maybe I'm missing something but maybe something like this:

diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
index f424dafce5bce..d2f99127a9a9a 100755
--- a/scripts/checkpatch.pl
+++ b/scripts/checkpatch.pl
@@ -7850,6 +7850,13 @@ sub process {
 		exit(0);
 	}
 
+	# check if the last line is a blank line
+	if (($is_patch && $rawlines[-1] =~ /^\+\s*$/) ||
+	    (!$is_patch && $rawlines[-1] =~ /^\s*$/)) {
+		WARN("LINE_SPACING",
+		     "Blank lines at EOF are not good\n");
+	}
+
 	# In mailback mode only produce a report in the negative, for
 	# things that appear to be patches.
 	if ($mailback && ($clean == 1 || !$is_patch)) {

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH v2] checkpatch: report warning with files ending with blank lines
  2026-10-07 17:50     ` Joe Perches
@ 2026-10-07 17:54       ` Christian Marangi
  2026-10-07 18:30         ` Joe Perches
  0 siblings, 1 reply; 10+ messages in thread
From: Christian Marangi @ 2026-10-07 17:54 UTC (permalink / raw)
  To: Joe Perches; +Cc: Andy Whitcroft, linux-kernel

On Wed, Oct 07, 2026 at 10:50:30AM -0700, Joe Perches wrote:
> On Wed, 2026-10-07 at 18:52 +0200, Christian Marangi wrote:
> > On Wed, Oct 07, 2026 at 09:49:48AM -0700, Joe Perches wrote:
> > On Wed, 2026-10-07 at 14:28 +0200, Christian Marangi wrote:
> > > > On applying patch, git, depending on the default configuration, might
> > > > complain for any file having blank lines at end of file.
> > > I was not clear enough in my first reply.
> > > 
> > > I meant that the test should be done only once, not
> > > for each line of the input.
> > > 
> > > After the end of the process() loop of
> > > 
> > 	foreach my $rawline (@rawlines) {
> > 		[...]
> > 	}
> > > 
> > > a single test of $rawlines[-1] could be done.
> > 
> > Yes I also was with that idea but then I quickly figure it out that we are
> > not testing if the .patch have blank line at EOF. But if the single file of
> > the patch have blank line at EOF.
> > 
> > That can only be done in the process() while scanning each line as it does
> > progressively check new files in it.
> > 
> > (unless I'm missing something)
> 
> Dunno.  Maybe I'm missing something but maybe something like this:
> 
> diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
> index f424dafce5bce..d2f99127a9a9a 100755
> --- a/scripts/checkpatch.pl
> +++ b/scripts/checkpatch.pl
> @@ -7850,6 +7850,13 @@ sub process {
>  		exit(0);
>  	}
>  
> +	# check if the last line is a blank line
> +	if (($is_patch && $rawlines[-1] =~ /^\+\s*$/) ||
> +	    (!$is_patch && $rawlines[-1] =~ /^\s*$/)) {
> +		WARN("LINE_SPACING",
> +		     "Blank lines at EOF are not good\n");
> +	}
> +
>  	# In mailback mode only produce a report in the negative, for
>  	# things that appear to be patches.
>  	if ($mailback && ($clean == 1 || !$is_patch)) {

Yes if you think about this, this will read the last line of the .patch,
not the last line of a new file that will be generated by the .patch.

diff --git a/MAINTAINERS b/MAINTAINERS
index 70a11f2ff61d..0b9946c532af 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -785,3 +785,9 @@ S:	Maintained
 F:	Documentation/devicetree/bindings/spi/airoha,en7581-snand.yaml
 F:	drivers/spi/spi-airoha-snfi.c
 
+AIROHA USB PHY DRIVER
+M:	Christian Marangi <ansuelsmth@gmail.com>
+L:	linux-arm-kernel@lists.infradead.org (moderated for non-subscribers)
+S:	Maintained
+F:	Documentation/devicetree/bindings/phy/airoha,an7581-usb-phy.yaml
+
-- 
2.55.0

It's to catch situation like this. Example for entire new file or adding
stuff at the end of a file, where a new line is introduced.

git am will complain about this.

-- 
	Ansuel

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH v2] checkpatch: report warning with files ending with blank lines
  2026-10-07 16:52   ` Christian Marangi
  2026-10-07 17:50     ` Joe Perches
@ 2026-10-07 17:58     ` Joe Perches
  1 sibling, 0 replies; 10+ messages in thread
From: Joe Perches @ 2026-10-07 17:58 UTC (permalink / raw)
  To: Christian Marangi; +Cc: Andy Whitcroft, linux-kernel

On Wed, 2026-10-07 at 18:52 +0200, Christian Marangi wrote:
> Yes I also was with that idea but then I quickly figure it out that we are
> not testing if the .patch have blank line at EOF. But if the single file of
> the patch have blank line at EOF.

A long time ago:

https://lore.kernel.org/lkml/b5e2a4d9eb49290d6dc3449c90cdf07797b1aba6.camel@perches.com/

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH v2] checkpatch: report warning with files ending with blank lines
  2026-10-07 17:54       ` Christian Marangi
@ 2026-10-07 18:30         ` Joe Perches
  2026-10-07 18:31           ` Christian Marangi
  0 siblings, 1 reply; 10+ messages in thread
From: Joe Perches @ 2026-10-07 18:30 UTC (permalink / raw)
  To: Christian Marangi; +Cc: Andy Whitcroft, linux-kernel

On Wed, 2026-10-07 at 19:54 +0200, Christian Marangi wrote:
> Yes if you think about this, this will read the last line of the .patch,
> not the last line of a new file that will be generated by the .patch.
> 
> diff --git a/MAINTAINERS b/MAINTAINERS
> index 70a11f2ff61d..0b9946c532af 100644
> --- a/MAINTAINERS
> +++ b/MAINTAINERS
> @@ -785,3 +785,9 @@ S:	Maintained
>  F:	Documentation/devicetree/bindings/spi/airoha,en7581-snand.yaml
>  F:	drivers/spi/spi-airoha-snfi.c
>  
> +AIROHA USB PHY DRIVER
> +M:	Christian Marangi <[ansuelsmth@gmail.com](mailto:ansuelsmth@gmail.com)>
> +L:	[linux-arm-kernel@lists.infradead.org](mailto:linux-arm-kernel@lists.infradead.org) (moderated for non-subscribers)
> +S:	Maintained
> +F:	Documentation/devicetree/bindings/phy/airoha,an7581-usb-phy.yaml
> +
> -- 
> 2.55.0
> 
> It's to catch situation like this. Example for entire new file or adding
> stuff at the end of a file, where a new line is introduced.
> 
> git am will complain about this.

It seems there's something odd about the patch content
as there aren't any context lines after the addition.

How was it generated ?

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH v2] checkpatch: report warning with files ending with blank lines
  2026-10-07 18:30         ` Joe Perches
@ 2026-10-07 18:31           ` Christian Marangi
  2026-10-07 18:48             ` Joe Perches
  0 siblings, 1 reply; 10+ messages in thread
From: Christian Marangi @ 2026-10-07 18:31 UTC (permalink / raw)
  To: Joe Perches; +Cc: Andy Whitcroft, linux-kernel

On Wed, Oct 07, 2026 at 11:30:20AM -0700, Joe Perches wrote:
> On Wed, 2026-10-07 at 19:54 +0200, Christian Marangi wrote:
> > Yes if you think about this, this will read the last line of the .patch,
> > not the last line of a new file that will be generated by the .patch.
> > 
> > diff --git a/MAINTAINERS b/MAINTAINERS
> > index 70a11f2ff61d..0b9946c532af 100644
> > --- a/MAINTAINERS
> > +++ b/MAINTAINERS
> > @@ -785,3 +785,9 @@ S:	Maintained
> >  F:	Documentation/devicetree/bindings/spi/airoha,en7581-snand.yaml
> >  F:	drivers/spi/spi-airoha-snfi.c
> >  
> > +AIROHA USB PHY DRIVER
> > +M:	Christian Marangi <[ansuelsmth@gmail.com](mailto:ansuelsmth@gmail.com)>
> > +L:	[linux-arm-kernel@lists.infradead.org](mailto:linux-arm-kernel@lists.infradead.org) (moderated for non-subscribers)
> > +S:	Maintained
> > +F:	Documentation/devicetree/bindings/phy/airoha,an7581-usb-phy.yaml
> > +
> > -- 
> > 2.55.0
> > 
> > It's to catch situation like this. Example for entire new file or adding
> > stuff at the end of a file, where a new line is introduced.
> > 
> > git am will complain about this.
> 
> It seems there's something odd about the patch content
> as there aren't any context lines after the addition.
> 
> How was it generated ?

It was just an example, it's not the full patch. Just the last patch.

-- 
	Ansuel

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH v2] checkpatch: report warning with files ending with blank lines
  2026-10-07 18:31           ` Christian Marangi
@ 2026-10-07 18:48             ` Joe Perches
  2026-10-07 18:50               ` Christian Marangi (Ansuel)
  0 siblings, 1 reply; 10+ messages in thread
From: Joe Perches @ 2026-10-07 18:48 UTC (permalink / raw)
  To: Christian Marangi; +Cc: Andy Whitcroft, linux-kernel

On Wed, 2026-10-07 at 20:31 +0200, Christian Marangi wrote:

> > > It's to catch situation like this. Example for entire new file or adding
> > > stuff at the end of a file, where a new line is introduced.
> > > 
> > > git am will complain about this.
> > 
> > It seems there's something odd about the patch content
> > as there aren't any context lines after the addition.
> > 
> > How was it generated ?
> 
> It was just an example, it's not the full patch. Just the last patch.

Send more correct examples.

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH v2] checkpatch: report warning with files ending with blank lines
  2026-10-07 18:48             ` Joe Perches
@ 2026-10-07 18:50               ` Christian Marangi (Ansuel)
  0 siblings, 0 replies; 10+ messages in thread
From: Christian Marangi (Ansuel) @ 2026-10-07 18:50 UTC (permalink / raw)
  To: Joe Perches; +Cc: Andy Whitcroft, linux-kernel

Il giorno mer 7 ott 2026 alle ore 20:48 Joe Perches <joe@perches.com>
ha scritto:
>
> On Wed, 2026-10-07 at 20:31 +0200, Christian Marangi wrote:
>
> > > > It's to catch situation like this. Example for entire new file or adding
> > > > stuff at the end of a file, where a new line is introduced.
> > > >
> > > > git am will complain about this.
> > >
> > > It seems there's something odd about the patch content
> > > as there aren't any context lines after the addition.
> > >
> > > How was it generated ?
> >
> > It was just an example, it's not the full patch. Just the last patch.
>
> Send more correct examples.

Here... the DT file adds a whitespace at the end of file. With this
patch checkpatch
correctly report the problem.

From 530fb038855d8e64023a3fd14ebd0396bbfc780a Mon Sep 17 00:00:00 2001
From: Christian Marangi <ansuelsmth@gmail.com>
Date: Fri, 7 Feb 2025 13:25:28 +0100
Subject: [PATCH v12 1/3] dt-bindings: phy: Add documentation for Airoha AN7581
 USB PHY

Add documentation for Airoha AN7581 USB PHY that describe the USB PHY
for the USB controller.

Airoha AN7581 SoC support a maximum of 2 USB port. The USB 2.0 mode is
always supported. The USB 3.0 mode is optional and depends on the Serdes
mode currently configured on the system for the relevant USB port.

To correctly calibrate, the USB 2.0 port require correct value in
"airoha,usb2-monitor-clk-sel" property. Both the 2 USB 2.0 port permit
selecting one of the 4 monitor clock for calibration (internal clock not
exposed to the system) but each port have only one of the 4 actually
connected in HW hence the correct value needs to be specified in DT
based on board and the physical port. Normally it's monitor clock 1 for
USB1 and monitor clock 2 for USB2.

To correctly setup the Serdes mode attached to the USB 3.0 mode, a phys
property is required with the phandle pointing to the correct Serdes port
provided by the SCU node. Providing the phys property is optional if USB
3.0 is not used.

Signed-off-by: Christian Marangi <ansuelsmth@gmail.com>
Reviewed-by: Krzysztof Kozlowski <krzysztof.kozlowski@oss.qualcomm.com>
---
 .../bindings/phy/airoha,an7581-usb-phy.yaml   | 62 +++++++++++++++++++
 MAINTAINERS                                   |  6 ++
 2 files changed, 68 insertions(+)
 create mode 100644
Documentation/devicetree/bindings/phy/airoha,an7581-usb-phy.yaml

diff --git a/Documentation/devicetree/bindings/phy/airoha,an7581-usb-phy.yaml
b/Documentation/devicetree/bindings/phy/airoha,an7581-usb-phy.yaml
new file mode 100644
index 000000000000..f42e3d49a61f
--- /dev/null
+++ b/Documentation/devicetree/bindings/phy/airoha,an7581-usb-phy.yaml
@@ -0,0 +1,62 @@
+# SPDX-License-Identifier: GPL-2.0-only OR BSD-2-Clause
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/phy/airoha,an7581-usb-phy.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: Airoha AN7581 SoC USB PHY
+
+maintainers:
+  - Christian Marangi <ansuelsmth@gmail.com>
+
+description: >
+  The Airoha AN7581 SoC USB PHY describes the USB PHY for the USB controller.
+
+  Airoha AN7581 SoC support a maximum of 2 USB port. The USB 2.0 mode is
+  always supported. The USB 3.0 mode is optional and depends on the Serdes
+  mode currently configured on the system for the relevant USB port.
+
+properties:
+  compatible:
+    const: airoha,an7581-usb-phy
+
+  reg:
+    maxItems: 1
+
+  airoha,usb2-monitor-clk-sel:
+    description: Describe what oscillator across the available 4
+      should be selected for USB 2.0 Slew Rate calibration.
+    $ref: /schemas/types.yaml#/definitions/uint32
+    enum: [0, 1, 2, 3]
+
+  phys:
+    items:
+      - description: phandle to Serdes PHY. Optional if USB 3.0 is not used.
+
+  '#phy-cells':
+    description: The cell contains the mode, PHY_TYPE_USB2 or PHY_TYPE_USB3,
+      as defined in dt-bindings/phy/phy.h.
+    const: 1
+
+required:
+  - compatible
+  - reg
+  - airoha,usb2-monitor-clk-sel
+  - '#phy-cells'
+
+additionalProperties: false
+
+examples:
+  - |
+    #include <dt-bindings/soc/airoha,scu-ssr.h>
+
+    phy@1fac0000 {
+        compatible = "airoha,an7581-usb-phy";
+        reg = <0x1fac0000 0x10000>;
+
+        airoha,usb2-monitor-clk-sel = <1>;
+        phys = <&scu AIROHA_SCU_SERDES_USB1>;
+
+        #phy-cells = <1>;
+    };
+
diff --git a/MAINTAINERS b/MAINTAINERS
index 70a11f2ff61d..0b9946c532af 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -785,6 +785,12 @@ S: Maintained
 F: Documentation/devicetree/bindings/spi/airoha,en7581-snand.yaml
 F: drivers/spi/spi-airoha-snfi.c

+AIROHA USB PHY DRIVER
+M: Christian Marangi <ansuelsmth@gmail.com>
+L: linux-arm-kernel@lists.infradead.org (moderated for non-subscribers)
+S: Maintained
+F: Documentation/devicetree/bindings/phy/airoha,an7581-usb-phy.yaml
+
 AIRSPY MEDIA DRIVER
 L: linux-media@vger.kernel.org
 S: Orphan
-- 
2.55.0

^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2026-10-07 18:50 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-10-07 12:28 [PATCH v2] checkpatch: report warning with files ending with blank lines Christian Marangi
2026-10-07 16:49 ` Joe Perches
2026-10-07 16:52   ` Christian Marangi
2026-10-07 17:50     ` Joe Perches
2026-10-07 17:54       ` Christian Marangi
2026-10-07 18:30         ` Joe Perches
2026-10-07 18:31           ` Christian Marangi
2026-10-07 18:48             ` Joe Perches
2026-10-07 18:50               ` Christian Marangi (Ansuel)
2026-10-07 17:58     ` Joe Perches

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®