[PATCH v3 2/2] checkpatch: Add option to not force /* */ for SPDX

From: Petr Vorel

Date: Wed Apr 08 2026 - 08:06:27 EST


Add option --ignore-old-toolchain to not force /* */ for SPDX.

As documented in aa19a176df95d6, this is required for some old
toolchains still have older assembler tools which cannot handle C++
style comments. This allows avoid forcing this for for projects which
vendored checkpatch.pl (e.g. LTP or u-boot).

Signed-off-by: Petr Vorel <pvorel@xxxxxxx>
---
New in v3.

I suppose you will not want to add code which should not be used on
mainline. But it would help to not force other projects which vendored
checkpatch.pl to neither force /* */ nor carry extra patch.

I wonder if this rule is still relevant (are these old toolchains still
being used).

Kind regards,
Petr

scripts/checkpatch.pl | 7 ++++++-
1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
index 58f3d5a98204c..ec1e9670a0c1d 100755
--- a/scripts/checkpatch.pl
+++ b/scripts/checkpatch.pl
@@ -61,6 +61,7 @@ my $def_configuration_dirs = ".:$ENV{HOME}:.scripts";
my $env_config_dir = 'CHECKPATCH_CONFIG_DIR';
my $max_line_length = 100;
my $ignore_perl_version = 0;
+my $ignore_old_toolchain = 0;
my $minimum_perl_version = 5.10.0;
my $min_conf_desc_length = 4;
my $spelling_file = "$D/spelling.txt";
@@ -137,6 +138,9 @@ Options:
file. It's your fault if there's no backup or git
--ignore-perl-version override checking of perl version. expect
runtime errors.
+ --ignore-old-toolchain don't force C++ comments (/* */) for SPDX license
+ (required by old toolchains). NOTE: it should *not*
+ be used for Linux mainline.
--codespell Use the codespell dictionary for spelling/typos
(default:$codespellfile)
--codespellfile Use this codespell dictionary
@@ -346,6 +350,7 @@ GetOptions(
'fix!' => \$fix,
'fix-inplace!' => \$fix_inplace,
'ignore-perl-version!' => \$ignore_perl_version,
+ 'ignore-old-toolchain!' => \$ignore_old_toolchain,
'debug=s' => \%debug,
'test-only=s' => \$tst_only,
'codespell!' => \$codespell,
@@ -3812,7 +3817,7 @@ sub process {
} elsif ($rawline =~ /^\+/) {
my $comment = "";
if ($realfile =~ /\.(h|s|S)$/) {
- $comment = '/*';
+ $comment = $ignore_old_toolchain ? '//' : '/*';
} elsif ($realfile =~ /\.(c|rs|dts|dtsi)$/) {
$comment = '//';
} elsif (($checklicenseline == 2) || $realfile =~ /\.(sh|pl|py|awk|tc|yaml)$/) {
--
2.53.0