[PATCH] From: Senthilnathan <ssenthil1490@xxxxxxxxx> Subject: [PATCH] checkpatch: remove incorrect IIO_DEV_ATTR_ permission-arg rule
From: Senthilnathan
Date: Mon Jun 22 2026 - 08:00:12 EST
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@xxxxxxxxx>
---
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