mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Senthilnathan <ssenthil1490@gmail.com>
To: linux-kernel@vger.kernel.org
Cc: joe@perches.com, Senthilnathan <ssenthil1490@gmail.com>
Subject: [PATCH] From: Senthilnathan <ssenthil1490@gmail.com> Subject: [PATCH] checkpatch: remove incorrect IIO_DEV_ATTR_ permission-arg rule
Date: Mon, 22 Jun 2026 17:29:34 +0530	[thread overview]
Message-ID: <20260622115934.1336588-1-ssenthil1490@gmail.com> (raw)

checkpatch's @mode_permission_funcs table assumes that for any macro
matching IIO_DEV_ATTR_[A-Z_]+, the permission/mode value is always
argument 1. This is incorrect: the IIO_DEV_ATTR_* macro family,
defined in drivers/staging/iio/frequency/dds.h, does not share a
consistent argument layout. For example:

  IIO_DEV_ATTR_FREQ(_channel, _num, _mode, _show, _store, _addr)
  IIO_DEV_ATTR_FREQSYMBOL(_channel, _mode, _show, _store, _addr)
  IIO_DEV_ATTR_OUTY_ENABLE(_channel, _output, _mode, _show, _store, _addr)

In IIO_DEV_ATTR_FREQ the mode is argument 3, while in
IIO_DEV_ATTR_FREQSYMBOL it is argument 2 -- there is no single
argument index that is correct for the whole family.

As a result, checkpatch.pl --file reports spurious NON_OCTAL_PERMISSIONS
errors against drivers/staging/iio/frequency/ad9834.c and ad9832.c,
flagging the _channel or _num argument (typically "0" or "1") as if it
were a malformed permission value, even though the actual mode
arguments (0200) are correctly formatted 4-digit octal values:

  $ ./scripts/checkpatch.pl --no-tree --file \
      drivers/staging/iio/frequency/ad9834.c
  ERROR: Use 4 digit octal (0777) not decimal permissions
  #315: FILE: drivers/staging/iio/frequency/ad9834.c:315:
  +static IIO_DEV_ATTR_FREQ(0, 0, 0200, NULL, ad9834_write, AD9834_REG_FREQ0);
  [... 8 more identical false positives ...]

Since no single fixed argument position is correct for every member
of this macro family, remove the rule rather than leave it pointing
at the wrong argument. The other entries in @mode_permission_funcs are
unaffected, and a genuine decimal-permission misuse (e.g.
DEVICE_ATTR(foo, 644, ...)) is still correctly flagged after this
change.

Signed-off-by: Senthilnathan <ssenthil1490@gmail.com>
---
 scripts/checkpatch.pl | 1 -
 1 file changed, 1 deletion(-)

diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
index 2b7a42b..0c6f8b9 100755
--- a/scripts/checkpatch.pl
+++ b/scripts/checkpatch.pl
@@ -854,7 +854,6 @@ our @mode_permission_funcs = (
 	["debugfs_create_(?:file|u8|u16|u32|u64|x8|x16|x32|x64|size_t|atomic_t|bool|blob|regset32|u32_array)", 2],
 	["proc_create(?:_data|)", 2],
 	["(?:CLASS|DEVICE|SENSOR|SENSOR_DEVICE|IIO_DEVICE)_ATTR", 2],
-	["IIO_DEV_ATTR_[A-Z_]+", 1],
 	["SENSOR_(?:DEVICE_|)ATTR_2", 2],
 	["SENSOR_TEMPLATE(?:_2|)", 3],
 	["__ATTR", 2],
--
2.43.0
---
 scripts/checkpatch.pl | 1 -
 1 file changed, 1 deletion(-)

diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
index 2b7a42bbdd94..0c6f8b92f168 100755
--- a/scripts/checkpatch.pl
+++ b/scripts/checkpatch.pl
@@ -854,7 +854,6 @@ our @mode_permission_funcs = (
 	["debugfs_create_(?:file|u8|u16|u32|u64|x8|x16|x32|x64|size_t|atomic_t|bool|blob|regset32|u32_array)", 2],
 	["proc_create(?:_data|)", 2],
 	["(?:CLASS|DEVICE|SENSOR|SENSOR_DEVICE|IIO_DEVICE)_ATTR", 2],
-	["IIO_DEV_ATTR_[A-Z_]+", 1],
 	["SENSOR_(?:DEVICE_|)ATTR_2", 2],
 	["SENSOR_TEMPLATE(?:_2|)", 3],
 	["__ATTR", 2],
-- 
2.34.1


                 reply	other threads:[~2026-06-22 12:00 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=20260622115934.1336588-1-ssenthil1490@gmail.com \
    --to=ssenthil1490@gmail.com \
    --cc=joe@perches.com \
    --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®