Commit 2cb3f45d authored by Philippe Gerum's avatar Philippe Gerum Committed by Jan Kiszka

cobalt/kernel: convert to proc_ops

Signed-off-by: Philippe Gerum's avatarPhilippe Gerum <rpm@xenomai.org>
[Jan: converted two more cases in analogy, indented consistently]
Signed-off-by: Jan Kiszka's avatarJan Kiszka <jan.kiszka@siemens.com>
parent a5499766
......@@ -173,6 +173,26 @@ devm_hwmon_device_register_with_groups(struct device *dev, const char *name,
#define mmap_write_unlock(__mm) up_write(&mm->mmap_sem)
#endif
#if LINUX_VERSION_CODE < KERNEL_VERSION(5,6,0)
#define DEFINE_PROC_OPS(__name, __open, __release, __read, __write) \
struct file_operations __name = { \
.open = (__open), \
.release = (__release), \
.read = (__read), \
.write = (__write), \
.llseek = seq_lseek, \
}
#else
#define DEFINE_PROC_OPS(__name, __open, __release, __read, __write) \
struct proc_ops __name = { \
.proc_open = (__open), \
.proc_release = (__release), \
.proc_read = (__read), \
.proc_write = (__write), \
.proc_lseek = seq_lseek, \
}
#endif
#if LINUX_VERSION_CODE < KERNEL_VERSION(5,8,0)
#define vmalloc_kernel(__size, __flags) __vmalloc(__size, GFP_KERNEL|__flags, PAGE_KERNEL)
#else
......
......@@ -340,13 +340,11 @@ ssize_t vfile_snapshot_write(struct file *file, const char __user *buf,
return ret;
}
static struct file_operations vfile_snapshot_fops = {
.open = vfile_snapshot_open,
.read = seq_read,
.write = vfile_snapshot_write,
.llseek = seq_lseek,
.release = vfile_snapshot_release,
};
static const DEFINE_PROC_OPS(vfile_snapshot_fops,
vfile_snapshot_open,
vfile_snapshot_release,
seq_read,
vfile_snapshot_write);
/**
* @fn int xnvfile_init_snapshot(const char *name, struct xnvfile_snapshot *vfile, struct xnvfile_directory *parent)
......@@ -592,13 +590,11 @@ ssize_t vfile_regular_write(struct file *file, const char __user *buf,
return ret;
}
static struct file_operations vfile_regular_fops = {
.open = vfile_regular_open,
.read = seq_read,
.write = vfile_regular_write,
.llseek = seq_lseek,
.release = vfile_regular_release,
};
static const DEFINE_PROC_OPS(vfile_regular_fops,
vfile_regular_open,
vfile_regular_release,
seq_read,
vfile_regular_write);
/**
* @fn int xnvfile_init_regular(const char *name, struct xnvfile_regular *vfile, struct xnvfile_directory *parent)
......
......@@ -95,12 +95,11 @@ static int a4l_proc_transfer_open(struct inode *inode, struct file *file)
return single_open(file, a4l_rdproc_transfer, PDE_DATA(inode));
}
static const struct file_operations a4l_proc_transfer_ops = {
.open = a4l_proc_transfer_open,
.read = seq_read,
.llseek = seq_lseek,
.release = single_release,
};
static const DEFINE_PROC_OPS(a4l_proc_transfer_ops,
a4l_proc_transfer_open,
single_release,
seq_read,
NULL);
int a4l_proc_attach(struct a4l_device_context * cxt)
{
......
......@@ -58,24 +58,22 @@ static int a4l_proc_devs_open(struct inode *inode, struct file *file)
return single_open(file, a4l_rdproc_devs, NULL);
}
static const struct file_operations a4l_proc_devs_ops = {
.open = a4l_proc_devs_open,
.read = seq_read,
.llseek = seq_lseek,
.release = single_release,
};
static const DEFINE_PROC_OPS(a4l_proc_devs_ops,
a4l_proc_devs_open,
single_release,
seq_read,
NULL);
static int a4l_proc_drvs_open(struct inode *inode, struct file *file)
{
return single_open(file, a4l_rdproc_drvs, NULL);
}
static const struct file_operations a4l_proc_drvs_ops = {
.open = a4l_proc_drvs_open,
.read = seq_read,
.llseek = seq_lseek,
.release = single_release,
};
static const DEFINE_PROC_OPS(a4l_proc_drvs_ops,
a4l_proc_drvs_open,
single_release,
seq_read,
NULL);
int a4l_init_proc(void)
{
......
......@@ -114,12 +114,11 @@ static int rtcan_mscan_proc_regs_open(struct inode *inode, struct file *file)
return single_open(file, rtcan_mscan_proc_regs, PDE_DATA(inode));
}
static const struct file_operations rtcan_mscan_proc_regs_ops = {
.open = rtcan_mscan_proc_regs_open,
.read = seq_read,
.llseek = seq_lseek,
.release = single_release,
};
static const DEFINE_PROC_OPS(rtcan_mscan_proc_regs_ops,
rtcan_mscan_proc_regs_open,
single_elease,
seq_read,
NULL);
int rtcan_mscan_create_proc(struct rtcan_device* dev)
{
......
......@@ -157,12 +157,11 @@ static int rtcan_proc_devices_open(struct inode *inode, struct file *file)
return single_open(file, rtcan_read_proc_devices, NULL);
}
static const struct file_operations rtcan_proc_devices_ops = {
.open = rtcan_proc_devices_open,
.read = seq_read,
.llseek = seq_lseek,
.release = single_release,
};
static const DEFINE_PROC_OPS(rtcan_proc_devices_ops,
rtcan_proc_devices_open,
single_release,
seq_read,
NULL);
static int rtcan_read_proc_sockets(struct seq_file *p, void *data)
{
......@@ -220,13 +219,11 @@ static int rtcan_proc_sockets_open(struct inode *inode, struct file *file)
return single_open(file, rtcan_read_proc_sockets, NULL);
}
static const struct file_operations rtcan_proc_sockets_ops = {
.open = rtcan_proc_sockets_open,
.read = seq_read,
.llseek = seq_lseek,
.release = single_release,
};
static const DEFINE_PROC_OPS(rtcan_proc_sockets_ops,
rtcan_proc_sockets_open,
single_release,
seq_read,
NULL);
static int rtcan_read_proc_info(struct seq_file *p, void *data)
{
......@@ -271,14 +268,11 @@ static int rtcan_proc_info_open(struct inode *inode, struct file *file)
return single_open(file, rtcan_read_proc_info, PDE_DATA(inode));
}
static const struct file_operations rtcan_proc_info_ops = {
.open = rtcan_proc_info_open,
.read = seq_read,
.llseek = seq_lseek,
.release = single_release,
};
static const DEFINE_PROC_OPS(rtcan_proc_info_ops,
rtcan_proc_info_open,
single_release,
seq_read,
NULL);
static int rtcan_read_proc_filter(struct seq_file *p, void *data)
{
......@@ -319,14 +313,11 @@ static int rtcan_proc_filter_open(struct inode *inode, struct file *file)
return single_open(file, rtcan_read_proc_filter, PDE_DATA(inode));
}
static const struct file_operations rtcan_proc_filter_ops = {
.open = rtcan_proc_filter_open,
.read = seq_read,
.llseek = seq_lseek,
.release = single_release,
};
static const DEFINE_PROC_OPS(rtcan_proc_filter_ops,
rtcan_proc_filter_open,
single_release,
seq_read,
NULL);
static int rtcan_read_proc_version(struct seq_file *p, void *data)
{
......@@ -341,13 +332,11 @@ static int rtcan_proc_version_open(struct inode *inode, struct file *file)
return single_open(file, rtcan_read_proc_version, NULL);
}
static const struct file_operations rtcan_proc_version_ops = {
.open = rtcan_proc_version_open,
.read = seq_read,
.llseek = seq_lseek,
.release = single_release,
};
static const DEFINE_PROC_OPS(rtcan_proc_version_ops,
rtcan_proc_version_open,
single_release,
seq_read,
NULL);
void rtcan_dev_remove_proc(struct rtcan_device* dev)
{
......
......@@ -50,12 +50,11 @@ static int rtcan_sja_proc_regs_open(struct inode *inode, struct file *file)
return single_open(file, rtcan_sja_proc_regs, PDE_DATA(inode));
}
static const struct file_operations rtcan_sja_proc_regs_ops = {
.open = rtcan_sja_proc_regs_open,
.read = seq_read,
.llseek = seq_lseek,
.release = single_release,
};
static const DEFINE_PROC_OPS(rtcan_sja_proc_regs_ops,
rtcan_sja_proc_regs_open,
single_release,
seq_read,
NULL);
int rtcan_sja_create_proc(struct rtcan_device* dev)
{
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment