Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.223.130]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id C94DE2628D for ; Fri, 17 Apr 2026 17:04:06 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=195.135.223.130 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1776445451; cv=none; b=XRElQvJmJqhJpMshuBnnkRd0szcmTxsHu1CY1UDJH0YmS9V3wrhxVa+rxAvufcGco1+SKl8ZCLE05tqBdZlc8X7TAP1RYEAhyKQd733gVYAMpTf6V5N7U9uMNqYAcf2RDpcmH6p0OgBZjyUPsHk7aPiX5WbOWeme72X54o9tGB8= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1776445451; c=relaxed/simple; bh=PWN1NWr6/Uc7fuDPeISPh/VuS+ztu27QZPptDilZn2s=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=JUbbTQ4sXuAdLmggrRaIspYPq+rgp3ZaZpGYGR7zDA801fO0onDeELEDS/MTd21em6cZt4VheQhdqZ1ZKNR+QohgCNV7E/PRS8Ay65BjlrdaiI5kpGHQggPa0ZfchGpbFjXvB71iuc2e1F00T+wa3WdlThRXOlLUji0MiLEQXeA= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=suse.cz; spf=pass smtp.mailfrom=suse.cz; dkim=pass (1024-bit key) header.d=suse.cz header.i=@suse.cz header.b=ZurcXs6w; dkim=permerror (0-bit key) header.d=suse.cz header.i=@suse.cz header.b=Ijdaf1f+; dkim=pass (1024-bit key) header.d=suse.cz header.i=@suse.cz header.b=ZurcXs6w; dkim=permerror (0-bit key) header.d=suse.cz header.i=@suse.cz header.b=Ijdaf1f+; arc=none smtp.client-ip=195.135.223.130 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=suse.cz Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=suse.cz Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=suse.cz header.i=@suse.cz header.b="ZurcXs6w"; dkim=permerror (0-bit key) header.d=suse.cz header.i=@suse.cz header.b="Ijdaf1f+"; dkim=pass (1024-bit key) header.d=suse.cz header.i=@suse.cz header.b="ZurcXs6w"; dkim=permerror (0-bit key) header.d=suse.cz header.i=@suse.cz header.b="Ijdaf1f+" Received: from imap1.dmz-prg2.suse.org (imap1.dmz-prg2.suse.org [IPv6:2a07:de40:b281:104:10:150:64:97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by smtp-out1.suse.de (Postfix) with ESMTPS id 0611D6A9CD; Fri, 17 Apr 2026 17:04:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_rsa; t=1776445444; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding; bh=3jmb7zfgKSwzWpM8qVe/a6fmO+FiGH9hyJGaTUhhk2M=; b=ZurcXs6wm5eAmnJ0PE8YE+OV9nwHktMurrYxrl1XGVoP/tuYWSAtVyWbOsw7nNznbCATxG 1J9tfpNGfzJ8Op4cEJzHQXr79QtoiIxoq+UED5KWyWGv/pLJbeRepkICS2+JJKr/KkkFRM yab1KDoSJphE9S5lWx736KUPtfWcVgo= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_ed25519; t=1776445444; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding; bh=3jmb7zfgKSwzWpM8qVe/a6fmO+FiGH9hyJGaTUhhk2M=; b=Ijdaf1f+7hDz5P7/SM/ewYZaMoqSPc5eUmcS1nG+FGS2K3dxhf39/qpjD82WAmuYgXrjyy /wHKfT4VII2eznDQ== Authentication-Results: smtp-out1.suse.de; dkim=pass header.d=suse.cz header.s=susede2_rsa header.b=ZurcXs6w; dkim=pass header.d=suse.cz header.s=susede2_ed25519 header.b=Ijdaf1f+ DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_rsa; t=1776445444; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding; bh=3jmb7zfgKSwzWpM8qVe/a6fmO+FiGH9hyJGaTUhhk2M=; b=ZurcXs6wm5eAmnJ0PE8YE+OV9nwHktMurrYxrl1XGVoP/tuYWSAtVyWbOsw7nNznbCATxG 1J9tfpNGfzJ8Op4cEJzHQXr79QtoiIxoq+UED5KWyWGv/pLJbeRepkICS2+JJKr/KkkFRM yab1KDoSJphE9S5lWx736KUPtfWcVgo= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_ed25519; t=1776445444; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding; bh=3jmb7zfgKSwzWpM8qVe/a6fmO+FiGH9hyJGaTUhhk2M=; b=Ijdaf1f+7hDz5P7/SM/ewYZaMoqSPc5eUmcS1nG+FGS2K3dxhf39/qpjD82WAmuYgXrjyy /wHKfT4VII2eznDQ== Received: from imap1.dmz-prg2.suse.org (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by imap1.dmz-prg2.suse.org (Postfix) with ESMTPS id BD299593AE; Fri, 17 Apr 2026 17:04:03 +0000 (UTC) Received: from dovecot-director2.suse.de ([2a07:de40:b281:106:10:150:64:167]) by imap1.dmz-prg2.suse.org with ESMTPSA id G4ARLQNo4mmHPgAAD6G6ig (envelope-from ); Fri, 17 Apr 2026 17:04:03 +0000 From: Petr Vorel To: linux-kernel@vger.kernel.org Cc: Petr Vorel , Joe Perches , Simon Glass , Dwaipayan Ray , Lukas Bulwahn Subject: [PATCH v5 1/2] checkpatch: Allow passing config directory Date: Fri, 17 Apr 2026 19:03:45 +0200 Message-ID: <20260417170346.448758-1-pvorel@suse.cz> X-Mailer: git-send-email 2.53.0 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spamd-Result: default: False [-1.51 / 50.00]; BAYES_HAM(-3.00)[100.00%]; SUSPICIOUS_RECIPS(1.50)[]; MID_CONTAINS_FROM(1.00)[]; NEURAL_HAM_LONG(-1.00)[-1.000]; R_MISSING_CHARSET(0.50)[]; R_DKIM_ALLOW(-0.20)[suse.cz:s=susede2_rsa,suse.cz:s=susede2_ed25519]; NEURAL_HAM_SHORT(-0.20)[-1.000]; MIME_GOOD(-0.10)[text/plain]; MX_GOOD(-0.01)[]; ARC_NA(0.00)[]; RCVD_VIA_SMTP_AUTH(0.00)[]; FREEMAIL_CC(0.00)[suse.cz,perches.com,chromium.org,gmail.com]; TO_DN_SOME(0.00)[]; MIME_TRACE(0.00)[0:+]; FREEMAIL_ENVRCPT(0.00)[gmail.com]; FUZZY_RATELIMITED(0.00)[rspamd.com]; RCVD_COUNT_TWO(0.00)[2]; FROM_EQ_ENVFROM(0.00)[]; FROM_HAS_DN(0.00)[]; TO_MATCH_ENVRCPT_ALL(0.00)[]; TAGGED_RCPT(0.00)[]; DKIM_SIGNED(0.00)[suse.cz:s=susede2_rsa,suse.cz:s=susede2_ed25519]; RCVD_TLS_ALL(0.00)[]; RCPT_COUNT_FIVE(0.00)[6]; DKIM_TRACE(0.00)[suse.cz:+] X-Rspamd-Action: no action X-Spam-Flag: NO X-Spam-Score: -1.51 X-Spam-Level: X-Rspamd-Server: rspamd1.dmz-prg2.suse.org X-Rspamd-Queue-Id: 0611D6A9CD checkpatch.pl searches for .checkpatch.conf in $CWD, $HOME and $CWD/.scripts. Allow passing a single directory via CHECKPATCH_CONFIG_DIR environment variable. This allows to directly use project configuration file for projects which vendored checkpatch.pl (e.g. LTP or u-boot). Although it'd be more convenient for user to add --conf-dir option (instead of using environment variable), code would get ugly because options from the configuration file needs to be read before processing command line options with Getopt::Long. While at it, document directories and environment variable in help. Signed-off-by: Petr Vorel --- Changes in v5 (all by sashiko agent): https://sashiko.dev/#/patchset/20260415143636.272605-1-pvorel%40suse.cz * Move warning to don't wrongly warn when $CHECKPATCH_CONFIG_DIR is not set (sigh). Link to v4: https://lore.kernel.org/lkml/20260415143636.272605-1-pvorel@suse.cz/ Link to v3: https://lore.kernel.org/lkml/20260408120603.54351-1-pvorel@suse.cz/ Link to v2: https://lore.kernel.org/lkml/20260224181623.89904-1-pvorel@suse.cz/ Link to v1: https://lore.kernel.org/lkml/20260202144221.76765-2-pvorel@suse.cz/ scripts/checkpatch.pl | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl index 0492d6afc9a1f..8f7a42da12869 100755 --- a/scripts/checkpatch.pl +++ b/scripts/checkpatch.pl @@ -57,6 +57,8 @@ my %ignore_type = (); my @ignore = (); my $help = 0; my $configuration_file = ".checkpatch.conf"; +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 $minimum_perl_version = 5.10.0; @@ -146,6 +148,11 @@ Options: -h, --help, --version display this help and exit When FILE is - read standard input. + +CONFIGURATION FILE +Default configuration options can be stored in $configuration_file, +search path: '$def_configuration_dirs' or in a directory specified by +\$$env_config_dir environment variable (fallback to the default search path). EOM exit($exitcode); @@ -237,7 +244,7 @@ sub list_types { exit($exitcode); } -my $conf = which_conf($configuration_file); +my $conf = which_conf($configuration_file, $env_config_dir, $def_configuration_dirs); if (-f $conf) { my @conf_args; open(my $conffile, '<', "$conf") @@ -1531,9 +1538,15 @@ sub which { } sub which_conf { - my ($conf) = @_; + my ($conf, $env_key, $paths) = @_; + my $env_dir = $ENV{$env_key}; + + if (defined($env_dir)) { + return "$env_dir/$conf" if (-e "$env_dir/$conf"); + warn "$P: Can't find a readable $conf in '$env_dir', fallback to default locations: $!\n"; + } - foreach my $path (split(/:/, ".:$ENV{HOME}:.scripts")) { + foreach my $path (split(/:/, $paths)) { if (-e "$path/$conf") { return "$path/$conf"; } -- 2.53.0