From: Tudor Gheorghiu <tudor.reda@gmail.com>
To: Andy Whitcroft <apw@canonical.com>, Joe Perches <joe@perches.com>,
Dwaipayan Ray <dwaipayanray1@gmail.com>,
Lukas Bulwahn <lukas.bulwahn@gmail.com>
Cc: linux-kernel@vger.kernel.org, Nam Cao <namcao@linutronix.de>,
Tudor Gheorghiu <tudor.reda@gmail.com>
Subject: [PATCH] checkpatch: fix IIO_DEV_ATTR false positives
Date: Wed, 2 Oct 2024 16:34:19 +0300 [thread overview]
Message-ID: <20241002133418.7924-2-tudor.reda@gmail.com> (raw)
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@gmail.com/
Potential checkpatch issue identified and patch suggested:
https://lore.kernel.org/linux-iio/20241001225426.wUBOFdMi@linutronix.de/
Signed-off-by: Tudor Gheorghiu <tudor.reda@gmail.com>
Suggested-by: Nam Cao <namcao@linutronix.de>
---
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
reply other threads:[~2024-10-02 13:35 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=20241002133418.7924-2-tudor.reda@gmail.com \
--to=tudor.reda@gmail.com \
--cc=apw@canonical.com \
--cc=dwaipayanray1@gmail.com \
--cc=joe@perches.com \
--cc=linux-kernel@vger.kernel.org \
--cc=lukas.bulwahn@gmail.com \
--cc=namcao@linutronix.de \
/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®