Skip to content

Commit bc261fe

Browse files
author
Mete Durlu
committed
s390/diag: Create misc device /dev/diag
JIRA: https://issues.redhat.com/browse/RHEL-72676 commit 2478d43 Author: Sumanth Korikkar <[email protected]> Date: Thu Dec 12 17:17:18 2024 +0100 s390/diag: Create misc device /dev/diag Create a misc device /dev/diag to fetch diagnose specific information from the kernel and provide it to userspace. Reviewed-by: Heiko Carstens <[email protected]> Signed-off-by: Sumanth Korikkar <[email protected]> Signed-off-by: Alexander Gordeev <[email protected]> Signed-off-by: Mete Durlu <[email protected]>
1 parent 2f93fda commit bc261fe

File tree

2 files changed

+46
-0
lines changed

2 files changed

+46
-0
lines changed

arch/s390/kernel/diag/Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
obj-y := diag_misc.o

arch/s390/kernel/diag/diag_misc.c

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
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);

0 commit comments

Comments
 (0)