mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] checkpatch: recognize standard SI unit prefixes and symbols
@ 2026-08-14 15:51 Ariel Yu
  2026-08-14 22:21 ` Joe Perches
  2026-08-15 18:04 ` [PATCH v2] " Ariel Yu
  0 siblings, 2 replies; 4+ messages in thread
From: Ariel Yu @ 2026-08-14 15:51 UTC (permalink / raw)
  To: apw, joe; +Cc: linux-kernel

The CAMELCASE check currently uses a broad [a-z][A-Z] pattern to
skip SI-unit-style identifiers, which matches any lowercase-then-
uppercase pair rather than actual SI units.

Replace it with an explicit list of standard SI prefixes
(u, n, m, k, K, M, G, T) and units (V, A, Hz, Ohm, C, K, s, W),
while retaining the binary byte units (KiB, MiB, GiB) and dB.

Link: https://lore.kernel.org/linux-iio/F9A182CC-62C0-445C-BAF0-9CDB7FFB3868@gmail.com/
Assisted-by: opencode:deepseek-v4-pro
Signed-off-by: Ariel Yu <ariel@ariels.xyz>
---
 scripts/checkpatch.pl | 18 ++++++++++++++----
 1 file changed, 14 insertions(+), 4 deletions(-)

diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
index 2b7a42bbdd..ba76beafc3 100755
--- a/scripts/checkpatch.pl
+++ b/scripts/checkpatch.pl
@@ -5935,11 +5935,21 @@ sub process {
 			    $var !~ /^(?:Clear|Set|TestClear|TestSet|)Page[A-Z]/ &&
 #Ignore ETHTOOL_LINK_MODE_<foo> variants
 			    $var !~ /^ETHTOOL_LINK_MODE_/ &&
-#Ignore SI style variants like nS, mV and dB
+#Ignore SI style variants like mV, uA, kHz, dB, MiB etc.
 #(ie: max_uV, regulator_min_uA_show, RANGE_mA_VALUE)
-			    $var !~ /^(?:[a-z0-9_]*|[A-Z0-9_]*)?_?[a-z][A-Z](?:_[a-z0-9_]+|_[A-Z0-9_]+)?$/ &&
-#Ignore some three character SI units explicitly, like MiB and KHz
-			    $var !~ /^(?:[a-z_]*?)_?(?:[KMGT]iB|[KMGT]?Hz)(?:_[a-z_]+)?$/) {
+#
+#Recognized standard SI unit prefixes (case sensitive):
+#	u - micro (10^-6)	n - nano (10^-9)	m - milli (10^-3)
+#	k - kilo (10^3)		K - kilo (10^3)		M - mega (10^6)
+#	G - giga (10^9)		T - tera (10^12)
+#
+#Recognized units (optionally prefixed by the above):
+#	V - volt		A - ampere		Hz - hertz
+#	Ohm - ohm		C - coulomb		K - kelvin
+#	s - second		W - watt
+#Binary byte units: KiB, MiB, GiB (TiB)
+#Decibel: dB
+			    $var !~ /^(?:[a-z0-9_]*|[A-Z0-9_]*)?_?(?:[unmkKMGT]?(?:V|A|Hz|Ohm|C|K|s|W)|[KMG]iB|dB)(?:_[a-z0-9_]+|_[A-Z0-9_]+)?$/) {
 				while ($var =~ m{\b($Ident)}g) {
 					my $word = $1;
 					next if ($word !~ /[A-Z][a-z]|[a-z][A-Z]/);

---
base-commit: d58772d8520c7ef247c4b95c9bd76d3a25da9ff5
change-id: 20260814-ktodo-si-cad1bd45ca07

Best regards,
--  
Ariel Yu <ariel@ariels.xyz>


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

end of thread, other threads:[~2026-08-17  8:33 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-08-14 15:51 [PATCH] checkpatch: recognize standard SI unit prefixes and symbols Ariel Yu
2026-08-14 22:21 ` Joe Perches
2026-08-15 18:04 ` [PATCH v2] " Ariel Yu
2026-08-17  8:33   ` Andy Shevchenko

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®