From 8d5f6aab173d17623260ec280b92481accc61cfa Mon Sep 17 00:00:00 2001 From: Imbus Date: Tue, 24 Feb 2026 13:57:41 +0100 Subject: [PATCH 1/2] Now passes checkpatch --- ioctl_chardev/my-ioctl.c | 4 +++- ioctl_chardev/my-ioctl.h | 12 +++++++----- ioctl_chardev/test.c | 2 ++ 3 files changed, 12 insertions(+), 6 deletions(-) diff --git a/ioctl_chardev/my-ioctl.c b/ioctl_chardev/my-ioctl.c index 78b2db0..e11696f 100644 --- a/ioctl_chardev/my-ioctl.c +++ b/ioctl_chardev/my-ioctl.c @@ -1,3 +1,5 @@ +// SPDX-License-Identifier: GPL-2.0 + #include #include "my-ioctl.h" @@ -14,7 +16,7 @@ static struct class *cls; static long my_ioctl(struct file *filp, unsigned int cmd, unsigned long arg); /* See: https://elixir.bootlin.com/linux/v6.14.5/source/include/linux/fs.h#L2131 */ -static struct file_operations fops = { +static const struct file_operations fops = { .owner = THIS_MODULE, .unlocked_ioctl = my_ioctl, }; diff --git a/ioctl_chardev/my-ioctl.h b/ioctl_chardev/my-ioctl.h index 56b61a4..e558707 100644 --- a/ioctl_chardev/my-ioctl.h +++ b/ioctl_chardev/my-ioctl.h @@ -1,14 +1,16 @@ +/* SPDX-License-Identifier: GPL-2.0 */ + #ifndef MY_IOCTL_H #define MY_IOCTL_H #include /* * Crucial point here, the kernel defines a set of macros for defining IOCTL numbers: - * _IO - No command - * _IOR - Read command - * _IOW - Write command - * _IORW - RW command - * _IOC - Basis of the others + * _IO - No command + * _IOR - Read command + * _IOW - Write command + * _IORW - RW command + * _IOC - Basis of the others * These macros encode the data type passed to the ioctl. */ diff --git a/ioctl_chardev/test.c b/ioctl_chardev/test.c index e379cd1..bf45789 100644 --- a/ioctl_chardev/test.c +++ b/ioctl_chardev/test.c @@ -1,3 +1,5 @@ +// SPDX-License-Identifier: GPL-2.0 + #include // #include #include From 4ae1267b4393cb49e2c4dfb4227df33fe52ab32a Mon Sep 17 00:00:00 2001 From: Imbus Date: Tue, 24 Feb 2026 13:59:04 +0100 Subject: [PATCH 2/2] Notes on checkpatch --- README.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/README.md b/README.md index d244eb2..f81709b 100644 --- a/README.md +++ b/README.md @@ -12,3 +12,7 @@ ### Insert & remove `sudo insmod demo_module.ko` `sudo rmmod demo_module.ko` + +### Style +Check for style with: +`${LINUX_PATH}/scripts/checkpatch.pl -f ./file.c`