[PATCH] checkpatch: fix IIO_DEV_ATTR false positives
From: Tudor Gheorghiu
Date: Wed Oct 02 2024 - 09:35:27 EST
The NON_OCTAL_PERMISSIONS checkpatch error can trigger false positives
when searching for the "IIO_DEV_ATTR_[A-Z_]+" pattern. The script checks
for any matching macros and reports an error if the first argument is a
literal and is not in octal notation.
There are a few other macros that match this pattern, in which the first
argument is not a file permission, therefore they don't necessarily need
to be matched by this condition.
The macros are all defined in include/linux/iio/sysfs.h:
> #define IIO_DEV_ATTR_SAMP_FREQ(_mode, _show, _store)
> #define IIO_DEV_ATTR_SAMP_FREQ_AVAIL(_show)
> #define IIO_DEV_ATTR_INT_TIME_AVAIL(_show)
> #define IIO_DEV_ATTR_TEMP_RAW(_show)
The script is fixed by matching IIO_DEV_ATTR_SAMP_FREQ exclusively.
Discovered by running checkpatch on some staging iio drivers:
https://lore.kernel.org/linux-iio/20241001202430.15874-2-tudor.reda@xxxxxxxxx/
Potential checkpatch issue identified and patch suggested:
https://lore.kernel.org/linux-iio/20241001225426.wUBOFdMi@xxxxxxxxxxxxx/
Signed-off-by: Tudor Gheorghiu <tudor.reda@xxxxxxxxx>
Suggested-by: Nam Cao <namcao@xxxxxxxxxxxxx>
---
scripts/checkpatch.pl | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
index 4427572b2477..2fb4549fede2 100755
--- a/scripts/checkpatch.pl
+++ b/scripts/checkpatch.pl
@@ -817,7 +817,7 @@ 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],
+ ["IIO_DEV_ATTR_SAMP_FREQ", 1],
["SENSOR_(?:DEVICE_|)ATTR_2", 2],
["SENSOR_TEMPLATE(?:_2|)", 3],
["__ATTR", 2],
--
2.43.0