File tree Expand file tree Collapse file tree 2 files changed +46
-0
lines changed Expand file tree Collapse file tree 2 files changed +46
-0
lines changed Original file line number Diff line number Diff line change
1
+ obj-y := diag_misc.o
Original file line number Diff line number Diff line change
1
+ // SPDX-License-Identifier: GPL-2.0
2
+ /*
3
+ * Provide diagnose information via misc device /dev/diag.
4
+ *
5
+ * Copyright IBM Corp. 2024
6
+ */
7
+
8
+ #include <linux/fs.h>
9
+ #include <linux/init.h>
10
+ #include <linux/ioctl.h>
11
+ #include <linux/kernel.h>
12
+ #include <linux/miscdevice.h>
13
+ #include <linux/types.h>
14
+
15
+ static long diag_ioctl (struct file * filp , unsigned int cmd , unsigned long arg )
16
+ {
17
+ long rc ;
18
+
19
+ switch (cmd ) {
20
+ default :
21
+ rc = - ENOIOCTLCMD ;
22
+ break ;
23
+ }
24
+ return rc ;
25
+ }
26
+
27
+ static const struct file_operations fops = {
28
+ .owner = THIS_MODULE ,
29
+ .open = nonseekable_open ,
30
+ .unlocked_ioctl = diag_ioctl ,
31
+ };
32
+
33
+ static struct miscdevice diagdev = {
34
+ .name = "diag" ,
35
+ .minor = MISC_DYNAMIC_MINOR ,
36
+ .fops = & fops ,
37
+ .mode = 0444 ,
38
+ };
39
+
40
+ static int diag_init (void )
41
+ {
42
+ return misc_register (& diagdev );
43
+ }
44
+
45
+ device_initcall (diag_init );
You can’t perform that action at this time.
0 commit comments