From patchwork Fri May 22 22:32:36 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 246330 List-Id: U-Boot discussion From: sjg at chromium.org (Simon Glass) Date: Fri, 22 May 2020 16:32:36 -0600 Subject: [PATCH 2/6] checkpatch.pl: Add a U-Boot option In-Reply-To: <20200522223240.187032-1-sjg@chromium.org> References: <20200522223240.187032-1-sjg@chromium.org> Message-ID: <20200522163226.2.I4aadaeb75b1f6d81a6e97d4aed405fb48f4bd7cd@changeid> Add an option to indicate that U-Boot-specific checks should be enabled. Add a function to house the code that will be added. Signed-off-by: Simon Glass --- .checkpatch.conf | 3 +++ scripts/checkpatch.pl | 12 ++++++++++++ 2 files changed, 15 insertions(+) diff --git a/.checkpatch.conf b/.checkpatch.conf index 95f19635d35..ed0c2150ba8 100644 --- a/.checkpatch.conf +++ b/.checkpatch.conf @@ -28,3 +28,6 @@ # A bit shorter of a description is OK with us. --min-conf-desc-length=2 + +# Extra checks for U-Boot +--u-boot diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl index cec09fbade8..93863c8f086 100755 --- a/scripts/checkpatch.pl +++ b/scripts/checkpatch.pl @@ -60,6 +60,7 @@ my $codespell = 0; my $codespellfile = "/usr/share/codespell/dictionary.txt"; my $conststructsfile = "$D/const_structs.checkpatch"; my $typedefsfile = ""; +my $u_boot = 0; my $color = "auto"; my $allow_c99_comments = 1; @@ -121,6 +122,7 @@ Options: --typedefsfile Read additional types from this file --color[=WHEN] Use colors 'always', 'never', or only when output is a terminal ('auto'). Default is 'auto'. + --u-boot Run additional checks for U-Boot -h, --help, --version display this help and exit When FILE is - read standard input. @@ -225,6 +227,7 @@ GetOptions( 'codespell!' => \$codespell, 'codespellfile=s' => \$codespellfile, 'typedefsfile=s' => \$typedefsfile, + 'u-boot' => \$u_boot, 'color=s' => \$color, 'no-color' => \$color, #keep old behaviors of -nocolor 'nocolor' => \$color, #keep old behaviors of -nocolor @@ -2235,6 +2238,11 @@ sub pos_last_openparen { return length(expand_tabs(substr($line, 0, $last_openparen))) + 1; } +# Checks specific to U-Boot +sub u_boot_line { + my ($realfile, $line, $herecurr) = @_; +} + sub process { my $filename = shift; @@ -3102,6 +3110,10 @@ sub process { "adding a line without newline at end of file\n" . $herecurr); } + if ($u_boot) { + u_boot_line($realfile, $line, $herecurr); + } + # check we are in a valid source file C or perl if not then ignore this hunk next if ($realfile !~ /\.(h|c|pl|dtsi|dts)$/);