[PATCH v2] checkpatch: recognize standard SI unit prefixes and symbols
Ariel Yu <[email protected]>
| Newsgroups | org.kernel.vger.linux-kernel |
|---|---|
| Message-ID | <010601a006991191-5959d04d-7d19-4128-b488-e51f6f97330e-000000@ap-northeast-1.amazonses.com> |
checkpatch flags identifiers containing valid SI units as CamelCase. Expand the SI unit ignore patterns to recognize standard Système International d'unités prefixes (u, m, k, M, G) and unit symbols (V, A, Hz, Ohm, C, K, s, W, etc.): - Allow mixed-case suffixes after the [a-z][A-Z] SI unit core, so derived units like _uV_per_C or _mV_per_K are no longer flagged. - Allow mixed-case prefixes in both the two-char and three-char SI patterns, so identifiers like clock_FREQ_kHz are recognized. - Add Ohm (with all standard prefixes: uOhm, mOhm, kOhm, MOhm, GOhm) to the three-char SI unit list. - Allow mixed-case suffixes after three-char SI units as well. Suggested-by: Andy Shevchenko <[email protected]> Closes: https://lore.kernel.org/linux-iio/[email protected]/ Assisted-by: opencode:deepseek-v4-pro Signed-off-by: Ariel Yu <[email protected]> --- Fixed false positives in check reports with SI units, like <AD7173_TEMP_SENSIIVITY_uV_per_C>, <SENSOR_uV_per_C>, <clock_FREQ_kHz>, <impedance_kOhm>. Now these naming conventions will now be considered PASS. --- Changes in v2: - Rewrite all regex. - Link to v1: https://patch.msgid.link/010601a000f8aa59-fa0e91fe-a069-4aaf-baa2-79737d25251a-000000@ap-northeast-1.amazonses.com --- scripts/checkpatch.pl | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl index 2b7a42bbdd..a55d7085c5 100755 --- a/scripts/checkpatch.pl +++ b/scripts/checkpatch.pl @@ -5937,9 +5937,9 @@ sub process { $var !~ /^ETHTOOL_LINK_MODE_/ && #Ignore SI style variants like nS, mV and dB #(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_]+)?$/ && + $var !~ /^(?:[a-zA-Z0-9_]*)?_?[a-z][A-Z](?:_[a-zA-Z0-9_]+)?$/ && #Ignore some three character SI units explicitly, like MiB and KHz - $var !~ /^(?:[a-z_]*?)_?(?:[KMGT]iB|[KMGT]?Hz)(?:_[a-z_]+)?$/) { + $var !~ /^(?:[a-zA-Z_]*?)_?(?:[KMGT]iB|[KMGT]?Hz|[umkMG]?Ohm)(?:_[a-zA-Z_]+)?$/) { 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: 20260816-commit2v-63337b4ffa2a Best regards, -- Ariel Yu <[email protected]>