Compare commits
No commits in common. "4ae1267b4393cb49e2c4dfb4227df33fe52ab32a" and "deb6fbd6c94b24b63f2ed5bae9017c0e9d52ec4b" have entirely different histories.
4ae1267b43
...
deb6fbd6c9
4 changed files with 6 additions and 16 deletions
|
|
@ -12,7 +12,3 @@
|
||||||
### Insert & remove
|
### Insert & remove
|
||||||
`sudo insmod demo_module.ko`
|
`sudo insmod demo_module.ko`
|
||||||
`sudo rmmod demo_module.ko`
|
`sudo rmmod demo_module.ko`
|
||||||
|
|
||||||
### Style
|
|
||||||
Check for style with:
|
|
||||||
`${LINUX_PATH}/scripts/checkpatch.pl -f ./file.c`
|
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,3 @@
|
||||||
// SPDX-License-Identifier: GPL-2.0
|
|
||||||
|
|
||||||
#include <linux/device.h>
|
#include <linux/device.h>
|
||||||
#include "my-ioctl.h"
|
#include "my-ioctl.h"
|
||||||
|
|
||||||
|
|
@ -16,7 +14,7 @@ static struct class *cls;
|
||||||
static long my_ioctl(struct file *filp, unsigned int cmd, unsigned long arg);
|
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 */
|
/* See: https://elixir.bootlin.com/linux/v6.14.5/source/include/linux/fs.h#L2131 */
|
||||||
static const struct file_operations fops = {
|
static struct file_operations fops = {
|
||||||
.owner = THIS_MODULE,
|
.owner = THIS_MODULE,
|
||||||
.unlocked_ioctl = my_ioctl,
|
.unlocked_ioctl = my_ioctl,
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -1,16 +1,14 @@
|
||||||
/* SPDX-License-Identifier: GPL-2.0 */
|
|
||||||
|
|
||||||
#ifndef MY_IOCTL_H
|
#ifndef MY_IOCTL_H
|
||||||
#define MY_IOCTL_H
|
#define MY_IOCTL_H
|
||||||
#include <linux/ioctl.h>
|
#include <linux/ioctl.h>
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Crucial point here, the kernel defines a set of macros for defining IOCTL numbers:
|
* Crucial point here, the kernel defines a set of macros for defining IOCTL numbers:
|
||||||
* _IO - No command
|
* _IO - No command
|
||||||
* _IOR - Read command
|
* _IOR - Read command
|
||||||
* _IOW - Write command
|
* _IOW - Write command
|
||||||
* _IORW - RW command
|
* _IORW - RW command
|
||||||
* _IOC - Basis of the others
|
* _IOC - Basis of the others
|
||||||
* These macros encode the data type passed to the ioctl.
|
* These macros encode the data type passed to the ioctl.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,3 @@
|
||||||
// SPDX-License-Identifier: GPL-2.0
|
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
// #include <stdlib.h>
|
// #include <stdlib.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue