mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Joe Perches <joe@perches.com>
To: Ariel Yu <ariel@ariels.xyz>, apw@canonical.com
Cc: linux-kernel@vger.kernel.org
Subject: Re: [PATCH] checkpatch: recognize standard SI unit prefixes and symbols
Date: Fri, 14 Aug 2026 15:21:31 -0700	[thread overview]
Message-ID: <b1033c9ecd319509341dacf74c9edbd9ca7b7cdc.camel@perches.com> (raw)
In-Reply-To: <010601a000f8aa59-fa0e91fe-a069-4aaf-baa2-79737d25251a-000000@ap-northeast-1.amazonses.com>

On Fri, 2026-08-14 at 15:51 +0000, Ariel Yu wrote:
> ```
> 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.

Why?  What does this complication do better?


> 
> Link: [https://lore.kernel.org/linux-iio/F9A182CC-62C0-445C-BAF0-9CDB7FFB3868@gmail.com/](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](mailto: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](mailto:ariel@ariels.xyz)>
> 
> 
> ```

  reply	other threads:[~2026-08-14 22:21 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-08-14 15:51 Ariel Yu
2026-08-14 22:21 ` Joe Perches [this message]
2026-08-15 18:04 ` [PATCH v2] " Ariel Yu
2026-08-17  8:33   ` Andy Shevchenko

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=b1033c9ecd319509341dacf74c9edbd9ca7b7cdc.camel@perches.com \
    --to=joe@perches.com \
    --cc=apw@canonical.com \
    --cc=ariel@ariels.xyz \
    --cc=linux-kernel@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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®