Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.223.131]) (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 9826836B05C for ; Mon, 2 Feb 2026 14:42:34 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=195.135.223.131 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1770043356; cv=none; b=lor7VNKcmQnHXciI965m3RqT6q4eNjr0E9vaMwrnexl1X32UBSytbsqPAEFqPmZk+L8/cm2k+ouvsaQBlb7NW1QIblzcBHJC8bbYK8gEJ9O/Z9ZUpijrFPI/XBueSKMWqS8qDB/lwJdXCrjdtEZE+6+cCHAlr9/4DpuoYLY9g5k= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1770043356; c=relaxed/simple; bh=4GvWL01YiiPxkw9tsOXkHAwttfYeS5W2x9PvchRS+BY=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=hI91WL1jXNowxZhEATjcocCpYBgCWOAVJ/TG3AF2bVoPrvgmx2L0qs7xkNxivxYkjzcVdIiiOzoIrNUCjRPTHjhQ0D9FhoVrgS1WPiddMDBloO6p9Al3UNVl25yLcaqJbF1IQAgPP+njCPnSz4q1S4fup/Q1ZwdBYGTqMQq/D8o= 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=wybCRPoc; dkim=permerror (0-bit key) header.d=suse.cz header.i=@suse.cz header.b=vopC6jnE; dkim=pass (1024-bit key) header.d=suse.cz header.i=@suse.cz header.b=wybCRPoc; dkim=permerror (0-bit key) header.d=suse.cz header.i=@suse.cz header.b=vopC6jnE; arc=none smtp.client-ip=195.135.223.131 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="wybCRPoc"; dkim=permerror (0-bit key) header.d=suse.cz header.i=@suse.cz header.b="vopC6jnE"; dkim=pass (1024-bit key) header.d=suse.cz header.i=@suse.cz header.b="wybCRPoc"; dkim=permerror (0-bit key) header.d=suse.cz header.i=@suse.cz header.b="vopC6jnE" Received: from imap1.dmz-prg2.suse.org (unknown [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-out2.suse.de (Postfix) with ESMTPS id 2E6305BD80; Mon, 2 Feb 2026 14:42:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_rsa; t=1770043352; 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: in-reply-to:in-reply-to:references:references; bh=WFcfW6qSJ4URfs5d739lvXVFCduvsCj4H2A1+DVYsb0=; b=wybCRPocasTjyaWayYjOWhiPgADnz8OljladE5o5GdudCSNs2Z0HfkXJOvigv5g2Bl+gN9 TMflR5a/davQp5IjtV7l48K/vo92lLZF9qjj2P0+7FP4gVXw9Sv6l1kWnZT2/lqHsjaaut EH/pCUOST8gMGrq22MXWoYJTpGeiF/Q= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_ed25519; t=1770043352; 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: in-reply-to:in-reply-to:references:references; bh=WFcfW6qSJ4URfs5d739lvXVFCduvsCj4H2A1+DVYsb0=; b=vopC6jnEhU723udeJS/FG2XFfks22f7f7lO1CtQkOtI8BeT0Pe4fJP1lUOx6W3qtFYvoMg nfQ74SohYiG1arBw== Authentication-Results: smtp-out2.suse.de; none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_rsa; t=1770043352; 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: in-reply-to:in-reply-to:references:references; bh=WFcfW6qSJ4URfs5d739lvXVFCduvsCj4H2A1+DVYsb0=; b=wybCRPocasTjyaWayYjOWhiPgADnz8OljladE5o5GdudCSNs2Z0HfkXJOvigv5g2Bl+gN9 TMflR5a/davQp5IjtV7l48K/vo92lLZF9qjj2P0+7FP4gVXw9Sv6l1kWnZT2/lqHsjaaut EH/pCUOST8gMGrq22MXWoYJTpGeiF/Q= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_ed25519; t=1770043352; 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: in-reply-to:in-reply-to:references:references; bh=WFcfW6qSJ4URfs5d739lvXVFCduvsCj4H2A1+DVYsb0=; b=vopC6jnEhU723udeJS/FG2XFfks22f7f7lO1CtQkOtI8BeT0Pe4fJP1lUOx6W3qtFYvoMg nfQ74SohYiG1arBw== 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 9E07A3EA63; Mon, 2 Feb 2026 14:42:31 +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 8KKnJNe3gGl8QgAAD6G6ig (envelope-from ); Mon, 02 Feb 2026 14:42:31 +0000 From: Petr Vorel To: linux-kernel@vger.kernel.org Cc: Petr Vorel , Andy Whitcroft , Joe Perches , Dwaipayan Ray , Lukas Bulwahn , Kory Maincent , Tom Rini , Simon Glass , Kuan-Wei Chiu Subject: [PATCH 2/2] checkpatch: Add --conf-dir option Date: Mon, 2 Feb 2026 15:42:21 +0100 Message-ID: <20260202144221.76765-2-pvorel@suse.cz> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20260202144221.76765-1-pvorel@suse.cz> References: <20260202144221.76765-1-pvorel@suse.cz> 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-Spam-Score: -1.30 X-Spamd-Result: default: False [-1.30 / 50.00]; BAYES_HAM(-3.00)[99.99%]; SUSPICIOUS_RECIPS(1.50)[]; NEURAL_HAM_LONG(-1.00)[-1.000]; MID_CONTAINS_FROM(1.00)[]; R_MISSING_CHARSET(0.50)[]; NEURAL_HAM_SHORT(-0.20)[-1.000]; MIME_GOOD(-0.10)[text/plain]; TO_MATCH_ENVRCPT_ALL(0.00)[]; MIME_TRACE(0.00)[0:+]; DKIM_SIGNED(0.00)[suse.cz:s=susede2_rsa,suse.cz:s=susede2_ed25519]; ARC_NA(0.00)[]; FUZZY_RATELIMITED(0.00)[rspamd.com]; FREEMAIL_CC(0.00)[suse.cz,canonical.com,perches.com,gmail.com,bootlin.com,konsulko.com]; RCVD_TLS_ALL(0.00)[]; RCVD_VIA_SMTP_AUTH(0.00)[]; FROM_EQ_ENVFROM(0.00)[]; FROM_HAS_DN(0.00)[]; TO_DN_SOME(0.00)[]; RCVD_COUNT_TWO(0.00)[2]; RCPT_COUNT_SEVEN(0.00)[10]; DBL_BLOCKED_OPENRESOLVER(0.00)[imap1.dmz-prg2.suse.org:helo,checkpatch.pl:url]; TAGGED_RCPT(0.00)[]; FREEMAIL_ENVRCPT(0.00)[gmail.com] X-Spam-Level: X-Spam-Flag: NO This allows to directly use project configuration file for projects which vendored checkpatch.pl (e.g. LTP or u-boot). Options from the configuration file has been read before processing command line options with Getopt::Long since the start (000d1cc1829f9) because options read from config file needs to be unshifted from command line arguments (@ARGV) before processing with Getopt::Long. Therefore parse --conf-dir with direct reading @ARGV. Signed-off-by: Petr Vorel --- @ARGV can be probably processed cleaner. Kind regards, Petr scripts/checkpatch.pl | 31 +++++++++++++++++++++++++++++-- 1 file changed, 29 insertions(+), 2 deletions(-) diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl index 8fffdf9e7f85f..7e19287d452d8 100755 --- a/scripts/checkpatch.pl +++ b/scripts/checkpatch.pl @@ -58,6 +58,7 @@ my @ignore = (); my $help = 0; my $configuration_file = ".checkpatch.conf"; my $def_configuration_dirs = ".:$ENV{HOME}:.scripts"; +my $configuration_dir = ""; my $max_line_length = 100; my $ignore_perl_version = 0; my $minimum_perl_version = 5.10.0; @@ -144,12 +145,14 @@ Options: is a terminal ('auto'). Default is 'auto'. --kconfig-prefix=WORD use WORD as a prefix for Kconfig symbols (default ${CONFIG_}) + --conf-dir=DIR directory with $configuration_file configuration file + (default:$def_configuration_dirs) -h, --help, --version display this help and exit When FILE is - read standard input. Script searches for a configuration file $configuration_file in path: -$def_configuration_dirs +$def_configuration_dirs (can be overwritten by --conf-dir) EOM exit($exitcode); @@ -241,7 +244,31 @@ sub list_types { exit($exitcode); } -my $conf = which_conf($configuration_file, $def_configuration_dirs); +# parse --conf-dir before the other options +my @argv; +while (@ARGV) { + my $arg = shift @ARGV; + if ($arg eq '--conf-dir') { + $configuration_dir = shift @ARGV; + die "--conf-dir requires value" unless ($configuration_dir); + } elsif ($arg =~ /^--conf-dir=(.+)$/) { + $configuration_dir = $1; + die "--conf-dir requires value" unless ($configuration_dir); + } else { + push @argv, $arg; + } +} +@ARGV = @argv; + +my $conf; +if ($configuration_dir) { + die "Dir. $configuration_dir does not exist" unless (-d $configuration_dir); + $conf = "$configuration_dir/$configuration_file"; + die "File $conf does not exist" unless (-f $conf); +} else { + $conf = which_conf($configuration_file, $def_configuration_dirs); +} + if (-f $conf) { my @conf_args; open(my $conffile, '<', "$conf") -- 2.51.0