Skip to contentSkip to conversation

checkpatch: remove incorrect IIO_DEV_ATTR_ permission-arg rule

PATCH New Senthilnathan 1 participant 1 message Jul 6 Checkpatch

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 checkpatch: remove incorrect IIO_DEV_ATTR_ permission-arg rule

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.

---
v2: Resend -- v1 had a mangled Subject line and a duplicated diff
caused by a commit-message formatting mistake. No code changes from v1.

 scripts/checkpatch.pl | 1 -
 1 file changed, 1 deletion(-)
scripts/checkpatch.pl +0 -1
index 2b7a42bbdd94..0c6f8b92f168 100755
@@ -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],
Signature · 1 line
2.34.1